Skip to content

Commit 05ad194

Browse files
author
xiannian.mu
committed
发布新版本
1 parent 1004ae9 commit 05ad194

5 files changed

Lines changed: 83 additions & 49 deletions

File tree

app/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ dependencies {
3838
//如果你需要使用okhttp作为你的下载器 你需要自主引入okhttp的依赖
3939
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
4040

41+
// FileDownloader dependency - needed for AutoUpdate library
42+
implementation 'com.liulishuo.filedownloader:library:1.7.6'
43+
4144
// 测试依赖
4245
testImplementation 'junit:junit:4.13.2'
4346
androidTestImplementation 'androidx.test.ext:junit:1.1.5'

app/proguard-rules.pro

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@
1515
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
1616
# public *;
1717
#}
18+
19+
# Keep FileDownloader classes to prevent NoClassDefFoundError
20+
-keep class com.liulishuo.filedownloader.** { *; }
21+
-keepclassmembers class com.liulishuo.filedownloader.** { *; }
22+
23+
# Keep AutoUpdate library classes
24+
-keep class com.cretin.www.cretinautoupdatelibrary.** { *; }
25+
-keepclassmembers class com.cretin.www.cretinautoupdatelibrary.** { *; }

cretinautoupdatelibrary/build.gradle

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
defaultConfig {
99
minSdkVersion 21
1010
targetSdkVersion 35
11-
versionCode 27
12-
versionName "2.0.7"
11+
versionCode 28
12+
versionName "2.0.8"
1313

1414
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1515

@@ -44,44 +44,44 @@ repositories {
4444
mavenCentral()
4545
}
4646

47-
// JitPack 发布配置
48-
afterEvaluate {
49-
publishing {
50-
publications {
51-
maven(MavenPublication) {
52-
groupId = 'com.github.MZCretin'
53-
artifactId = 'cretinautoupdatelibrary'
54-
version = '2.0.7'
47+
// JitPack 发布配置 - 使用现代组件发布以包含依赖信息
48+
publishing {
49+
publications {
50+
maven(MavenPublication) {
51+
groupId = 'com.github.MZCretin'
52+
artifactId = 'cretinautoupdatelibrary'
53+
version = '2.0.8'
54+
55+
// 使用组件发布,这会自动包含依赖信息
56+
// afterEvaluate {
57+
// from components.release
58+
// }
59+
60+
pom {
61+
name = 'CretinAutoUpdateLibrary'
62+
description = 'Android Auto Update Library'
63+
url = 'https://github.com/MZCretin/AutoUpdateProject'
5564

56-
// 在发布前确保 AAR 已构建
57-
artifact(bundleReleaseAar)
58-
59-
pom {
60-
name = 'CretinAutoUpdateLibrary'
61-
description = 'Android Auto Update Library'
62-
url = 'https://github.com/MZCretin/AutoUpdateProject'
63-
64-
licenses {
65-
license {
66-
name = 'The Apache License, Version 2.0'
67-
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
68-
}
65+
licenses {
66+
license {
67+
name = 'The Apache License, Version 2.0'
68+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
6969
}
70-
71-
developers {
72-
developer {
73-
id = 'cretin'
74-
name = 'Cretin'
75-
email = 'mxnzp_life@163.com'
76-
}
77-
}
78-
79-
scm {
80-
connection = 'scm:git:git://github.com/MZCretin/AutoUpdateProject.git'
81-
developerConnection = 'scm:git:ssh://github.com/MZCretin/AutoUpdateProject.git'
82-
url = 'https://github.com/MZCretin/AutoUpdateProject'
70+
}
71+
72+
developers {
73+
developer {
74+
id = 'cretin'
75+
name = 'Cretin'
76+
email = 'mxnzp_life@163.com'
8377
}
8478
}
79+
80+
scm {
81+
connection = 'scm:git:git://github.com/MZCretin/AutoUpdateProject.git'
82+
developerConnection = 'scm:git:ssh://github.com/MZCretin/AutoUpdateProject.git'
83+
url = 'https://github.com/MZCretin/AutoUpdateProject'
84+
}
8585
}
8686
}
8787
}

cretinautoupdatelibrary/proguard-rules.pro

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,18 @@
1515
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
1616
# public *;
1717
#}
18+
19+
# Keep FileDownloader classes to prevent NoClassDefFoundError
20+
-keep class com.liulishuo.filedownloader.** { *; }
21+
-keepclassmembers class com.liulishuo.filedownloader.** { *; }
22+
23+
# Keep all public classes and methods in this library
24+
-keep public class com.cretin.www.cretinautoupdatelibrary.** { *; }
25+
26+
# Keep all classes with annotations
27+
-keep class ** {
28+
@com.cretin.www.cretinautoupdatelibrary.** *;
29+
}
30+
31+
# Keep all callback interfaces and listeners
32+
-keep interface com.cretin.www.cretinautoupdatelibrary.interfaces.** { *; }

cretinautoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/utils/AppUtils.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import android.net.Uri;
1111
import android.os.Build;
1212
import android.os.Environment;
13+
import android.provider.Settings;
14+
import android.widget.Toast;
15+
1316
import androidx.core.content.FileProvider;
1417
import androidx.appcompat.app.AlertDialog;
1518

@@ -36,17 +39,22 @@ public class AppUtils {
3639
*/
3740
public static void installApkFile(Context context, File file) {
3841
// Android 8.0及以上版本需要检查REQUEST_INSTALL_PACKAGES权限
39-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
40-
if (!context.getPackageManager().canRequestPackageInstalls()) {
41-
// 没有安装权限,需要引导用户开启
42-
return;
43-
}
44-
}
45-
42+
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
43+
// if (!context.getPackageManager().canRequestPackageInstalls()) {
44+
// // 没有安装权限,需要引导用户开启
45+
// // 跳转到 "安装未知应用" 设置页面
46+
// Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES);
47+
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
48+
// intent.setData(Uri.parse("package:"+context.getPackageName()));
49+
// context.startActivity(intent);
50+
// return;
51+
// }
52+
// }
53+
4654
Intent intent = new Intent(Intent.ACTION_VIEW);
4755
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
4856
Uri uri = null;
49-
57+
5058
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
5159
// Android 7.0及以上使用FileProvider
5260
uri = FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", file);
@@ -55,15 +63,15 @@ public static void installApkFile(Context context, File file) {
5563
} else {
5664
uri = Uri.fromFile(file);
5765
}
58-
66+
5967
intent.setDataAndType(uri, "application/vnd.android.package-archive");
60-
68+
6169
// 添加Android 15兼容性检查
6270
if (Build.VERSION.SDK_INT >= 35) {
6371
// Android 15特定的处理
6472
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6573
}
66-
74+
6775
if (context.getPackageManager().queryIntentActivities(intent, 0).size() > 0) {
6876
context.startActivity(intent);
6977
}
@@ -83,7 +91,7 @@ public static int dp2px(float dpValue) {
8391
*
8492
* @return
8593
*/
86-
public static String getAppLocalPath(Context context,String versionName) {
94+
public static String getAppLocalPath(Context context, String versionName) {
8795
// apk 保存名称
8896
String apkName = AppUtils.getAppName(AppUpdateUtils.getInstance().getContext());
8997
return getAppRootPath(context) + "/" + apkName + "_" + versionName + ".apk";
@@ -97,7 +105,7 @@ public static String getAppLocalPath(Context context,String versionName) {
97105
public static String getAppRootPath(Context context) {
98106
//构建下载路径
99107
String packageName = AppUpdateUtils.getInstance().getContext().getPackageName();
100-
return context.getExternalCacheDir()+ "/" + packageName + "/apks";
108+
return context.getExternalCacheDir() + "/" + packageName + "/apks";
101109
}
102110

103111
/**

0 commit comments

Comments
 (0)