Skip to content

Commit 25877db

Browse files
committed
[Android] update gradle to 8.4
1 parent 340ef00 commit 25877db

27 files changed

Lines changed: 155 additions & 296 deletions

Android/APIExample/agora-simple-filter/build.gradle

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 32
5-
buildToolsVersion "32.0.0"
4+
namespace "io.agora.extension"
5+
compileSdk 35
66

77
defaultConfig {
8-
minSdkVersion 21
9-
targetSdkVersion 32
8+
minSdkVersion 24
9+
targetSdkVersion 35
1010
versionCode 1
1111
versionName "1.0"
1212

@@ -29,6 +29,10 @@ android {
2929
}
3030
}
3131

32+
buildFeatures {
33+
buildConfig true
34+
}
35+
3236
externalNativeBuild {
3337
cmake {
3438
path "src/main/cpp/CMakeLists.txt"
@@ -41,8 +45,8 @@ android {
4145

4246
dependencies {
4347
api fileTree(dir: "libs", include: ["*.jar", "*.aar"])
44-
implementation 'androidx.appcompat:appcompat:1.1.0'
45-
testImplementation 'junit:junit:4.12'
46-
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
47-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
48+
implementation 'androidx.appcompat:appcompat:1.7.0'
49+
testImplementation 'junit:junit:4.13.2'
50+
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
51+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
4852
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="io.agora.extension">
1+
<manifest>
32

43
</manifest>

Android/APIExample/agora-stream-encrypt/build.gradle

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 32
5-
buildToolsVersion "32.0.0"
4+
namespace "io.agora.encrypt"
5+
compileSdk 35
66

77
defaultConfig {
8-
minSdkVersion 21
9-
targetSdkVersion 32
8+
minSdkVersion 24
9+
targetSdkVersion 35
1010
versionCode 1
1111
versionName "1.0"
1212

@@ -28,6 +28,9 @@ android {
2828
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2929
}
3030
}
31+
buildFeatures {
32+
buildConfig true
33+
}
3134

3235
externalNativeBuild {
3336
cmake {
@@ -41,8 +44,8 @@ android {
4144

4245
dependencies {
4346
api fileTree(dir: "libs", include: ["*.jar", "*.aar"])
44-
implementation 'androidx.appcompat:appcompat:1.1.0'
45-
testImplementation 'junit:junit:4.12'
46-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
47-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
47+
implementation 'androidx.appcompat:appcompat:1.7.0'
48+
testImplementation 'junit:junit:4.13.2'
49+
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
50+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
4851
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<manifest package="io.agora.api.streamencrypt">
1+
<manifest>
22

33
</manifest>

Android/APIExample/app/build.gradle

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,16 @@ def localSdkPath= "${rootProject.projectDir.absolutePath}/../../sdk"
1515

1616

1717
android {
18-
compileSdkVersion 32
19-
buildToolsVersion "32.0.0"
18+
namespace "io.agora.api.example"
19+
compileSdk 35
2020

2121
defaultConfig {
2222
applicationId "io.agora.api.example"
23-
minSdkVersion 21
24-
targetSdkVersion 32
23+
minSdkVersion 24
24+
targetSdkVersion 35
2525
versionCode 1
2626
versionName "1.0"
2727
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
28-
manifestPlaceholders = [
29-
AppId: "${applicationId}"
30-
]
3128
ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86-64'
3229
}
3330

@@ -57,8 +54,8 @@ android {
5754
}
5855

5956
compileOptions {
60-
sourceCompatibility JavaVersion.VERSION_1_8
61-
targetCompatibility JavaVersion.VERSION_1_8
57+
sourceCompatibility JavaVersion.VERSION_17
58+
targetCompatibility JavaVersion.VERSION_17
6259
}
6360

6461
sourceSets {
@@ -72,16 +69,13 @@ android {
7269

7370
buildFeatures{
7471
viewBinding true
72+
buildConfig true
7573
}
7674

7775
packagingOptions {
7876
pickFirst 'lib/*/libc++_shared.so'
7977
}
8078

81-
buildFeatures{
82-
viewBinding true
83-
}
84-
8579
applicationVariants.all {
8680
variant ->
8781
variant.outputs.all { output ->
@@ -121,24 +115,24 @@ dependencies {
121115
}
122116

123117

124-
implementation 'androidx.appcompat:appcompat:1.5.0'
118+
implementation 'androidx.appcompat:appcompat:1.7.0'
125119
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
126120

127121
// Java language implementation
128-
implementation "androidx.navigation:navigation-fragment:2.5.0"
129-
implementation "androidx.navigation:navigation-ui:2.5.0"
122+
implementation "androidx.navigation:navigation-fragment:2.7.0"
123+
implementation "androidx.navigation:navigation-ui:2.7.0"
130124

131125
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
132-
implementation 'androidx.recyclerview:recyclerview:1.2.1'
126+
implementation 'androidx.recyclerview:recyclerview:1.3.2'
133127
if (simpleFilter.toBoolean()) {
134128
implementation project(path: ':agora-simple-filter')
135129
}
136130
if (streamEncrypt.toBoolean()) {
137131
implementation project(path: ':agora-stream-encrypt')
138132
}
139-
testImplementation 'junit:junit:4.12'
140-
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
141-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
133+
testImplementation 'junit:junit:4.13.2'
134+
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
135+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
142136

143137
implementation 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:1.2.0'
144138
implementation 'de.javagl:obj:0.2.1'
@@ -155,5 +149,5 @@ dependencies {
155149
implementation 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8'
156150
implementation 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8'
157151

158-
implementation 'com.google.android.exoplayer:exoplayer-core:2.16.0'
152+
implementation 'com.google.android.exoplayer:exoplayer-core:2.18.5'
159153
}

Android/APIExample/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4-
package="io.agora.api.example">
3+
xmlns:tools="http://schemas.android.com/tools">
54

65
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
76
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
87
<uses-permission android:name="android.permission.CAMERA" />
98
<uses-permission android:name="android.permission.INTERNET" />
109
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
11-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
1210
<uses-permission android:name="android.permission.RECORD_AUDIO" />
1311
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
1412
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
@@ -19,9 +17,6 @@
1917
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
2018
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
2119

22-
<!-- <permission-group android:name="io.agora.api.example.andpermission"/>-->
23-
<permission-group android:name="${AppId}.andpermission"/>
24-
2520
<uses-sdk tools:overrideLibrary="com.softsugar.hardwarebuffer" />
2621

2722
<application

Android/APIExample/app/src/main/java/io/agora/api/example/common/BaseBrowserFragment.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,13 @@ public void onPageFinished(WebView view, String url) {
200200
@Override
201201
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
202202
super.onReceivedError(view, request, error);
203-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
204-
new AlertDialog.Builder(view.getContext())
205-
.setTitle("Error")
206-
.setMessage(String.format(Locale.US, "%s\n\ncode:%d", error.getDescription().toString(), error.getErrorCode()))
207-
.setPositiveButton(R.string.refresh, (dialog, which) -> {
208-
mWebView.reload();
209-
})
210-
.show();
211-
}
203+
new AlertDialog.Builder(view.getContext())
204+
.setTitle("Error")
205+
.setMessage(String.format(Locale.US, "%s\n\ncode:%d", error.getDescription().toString(), error.getErrorCode()))
206+
.setPositiveButton(R.string.refresh, (dialog, which) -> {
207+
mWebView.reload();
208+
})
209+
.show();
212210
}
213211
});
214212

Android/APIExample/app/src/main/java/io/agora/api/example/common/floatwindow/FloatWindowHelper.java

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,6 @@ public static void destroyFloatView(@NonNull AVCallFloatView floatView) {
9595
*/
9696
public static boolean checkPermission(Context context) {
9797
//6.0 版本之后由于 google 增加了对悬浮窗权限的管理,所以方式就统一了
98-
if (Build.VERSION.SDK_INT < 23) {
99-
if (RomUtils.checkIsMiuiRom()) {
100-
return miuiPermissionCheck(context);
101-
} else if (RomUtils.checkIsMeizuRom()) {
102-
return meizuPermissionCheck(context);
103-
} else if (RomUtils.checkIsHuaweiRom()) {
104-
return huaweiPermissionCheck(context);
105-
} else if (RomUtils.checkIs360Rom()) {
106-
return qikuPermissionCheck(context);
107-
} else if (RomUtils.checkIsOppoRom()) {
108-
return oppoROMPermissionCheck(context);
109-
}
110-
}
11198
return commonROMPermissionCheck(context);
11299
}
113100

@@ -117,21 +104,7 @@ public static boolean checkPermission(Context context) {
117104
* @param context the context
118105
*/
119106
public static void applyPermission(Context context) {
120-
if (Build.VERSION.SDK_INT < 23) {
121-
if (RomUtils.checkIsMiuiRom()) {
122-
miuiROMPermissionApply(context);
123-
} else if (RomUtils.checkIsMeizuRom()) {
124-
meizuROMPermissionApply(context);
125-
} else if (RomUtils.checkIsHuaweiRom()) {
126-
huaweiROMPermissionApply(context);
127-
} else if (RomUtils.checkIs360Rom()) {
128-
rom360Permissionapply(context);
129-
} else if (RomUtils.checkIsOppoRom()) {
130-
oppoROMPermissionApply(context);
131-
}
132-
} else {
133-
commonROMPermissionApply(context);
134-
}
107+
commonROMPermissionApply(context);
135108
}
136109

137110
/**
@@ -173,14 +146,12 @@ private static boolean commonROMPermissionCheck(Context context) {
173146
return meizuPermissionCheck(context);
174147
} else {
175148
Boolean result = true;
176-
if (Build.VERSION.SDK_INT >= 23) {
177-
try {
178-
Class clazz = Settings.class;
179-
Method canDrawOverlays = clazz.getDeclaredMethod("canDrawOverlays", Context.class);
180-
result = (Boolean) canDrawOverlays.invoke(null, context);
181-
} catch (Exception e) {
182-
Log.e(TAG, Log.getStackTraceString(e));
183-
}
149+
try {
150+
Class clazz = Settings.class;
151+
Method canDrawOverlays = clazz.getDeclaredMethod("canDrawOverlays", Context.class);
152+
result = (Boolean) canDrawOverlays.invoke(null, context);
153+
} catch (Exception e) {
154+
Log.e(TAG, Log.getStackTraceString(e));
184155
}
185156
return result;
186157
}
@@ -222,15 +193,13 @@ private static void commonROMPermissionApply(final Context context) {
222193
if (RomUtils.checkIsMeizuRom()) {
223194
meizuROMPermissionApply(context);
224195
} else {
225-
if (Build.VERSION.SDK_INT >= 23) {
226-
showConfirmDialog(context, () -> {
227-
try {
228-
commonROMPermissionApplyInternal(context);
229-
} catch (Exception e) {
230-
Log.e(TAG, Log.getStackTraceString(e));
231-
}
232-
});
233-
}
196+
showConfirmDialog(context, () -> {
197+
try {
198+
commonROMPermissionApplyInternal(context);
199+
} catch (Exception e) {
200+
Log.e(TAG, Log.getStackTraceString(e));
201+
}
202+
});
234203
}
235204
}
236205

Android/APIExample/app/src/main/java/io/agora/api/example/common/floatwindow/rom/HuaweiUtils.java

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
*/
44
package io.agora.api.example.common.floatwindow.rom;
55

6-
import android.annotation.TargetApi;
76
import android.app.AppOpsManager;
87
import android.content.ActivityNotFoundException;
98
import android.content.ComponentName;
109
import android.content.Context;
1110
import android.content.Intent;
1211
import android.os.Binder;
13-
import android.os.Build;
1412
import android.util.Log;
1513
import android.widget.Toast;
1614

@@ -33,11 +31,7 @@ private HuaweiUtils() {
3331
* @return the boolean
3432
*/
3533
public static boolean checkFloatWindowPermission(Context context) {
36-
final int version = Build.VERSION.SDK_INT;
37-
if (version >= 19) {
38-
return checkOp(context, 24); //OP_SYSTEM_ALERT_WINDOW = 24;
39-
}
40-
return true;
34+
return checkOp(context, 24); //OP_SYSTEM_ALERT_WINDOW = 24;
4135
}
4236

4337
/**
@@ -94,20 +88,14 @@ public static void applyPermission(Context context) {
9488
}
9589
}
9690

97-
@TargetApi(Build.VERSION_CODES.KITKAT)
9891
private static boolean checkOp(Context context, int op) {
99-
final int version = Build.VERSION.SDK_INT;
100-
if (version >= 19) {
101-
AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
102-
try {
103-
Class clazz = AppOpsManager.class;
104-
Method method = clazz.getDeclaredMethod("checkOp", int.class, int.class, String.class);
105-
return AppOpsManager.MODE_ALLOWED == (int) method.invoke(manager, op, Binder.getCallingUid(), context.getPackageName());
106-
} catch (Exception e) {
107-
Log.e(TAG, Log.getStackTraceString(e));
108-
}
109-
} else {
110-
Log.e(TAG, "Below API 19 cannot invoke!");
92+
AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
93+
try {
94+
Class clazz = AppOpsManager.class;
95+
Method method = clazz.getDeclaredMethod("checkOp", int.class, int.class, String.class);
96+
return AppOpsManager.MODE_ALLOWED == (int) method.invoke(manager, op, Binder.getCallingUid(), context.getPackageName());
97+
} catch (Exception e) {
98+
Log.e(TAG, Log.getStackTraceString(e));
11199
}
112100
return false;
113101
}

0 commit comments

Comments
 (0)