diff --git a/build_logic/proguard-rules.pro b/build_logic/proguard-rules.pro index 6cac61efe..dd69a5eb3 100644 --- a/build_logic/proguard-rules.pro +++ b/build_logic/proguard-rules.pro @@ -1,3 +1,9 @@ +##################################################################### +# +# 混淆文件因为模块下没有导包,所以会报错,但不影响 +# +##################################################################### +#noinspection ShrinkerUnresolvedReference #基线包使用,生成mapping.txtt -printmapping mapping.txt #补丁包使用,应用mapping.txt @@ -20,6 +26,7 @@ ## EventBus https://github.com/greenrobot/EventBus -keepattributes *Annotation* -keepclassmembers class * { + #noinspection ShrinkerUnresolvedReference @org.greenrobot.eventbus.Subscribe ; } -keep enum org.greenrobot.eventbus.ThreadMode { *; } @@ -93,6 +100,7 @@ -keep class * implements com.google.gson.JsonSerializer -keep class * implements com.google.gson.JsonDeserializer -keepclassmembers,allowobfuscation class * { + #noinspection ShrinkerUnresolvedReference @com.google.gson.annotations.SerializedName ; } -keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken @@ -123,6 +131,13 @@ ## hotfix +## Sophix https://help.aliyun.com/document_detail/61082.html +#基线包使用,生成mapping.txt +-printmapping mapping.txt +#生成的mapping.txt在app/build/outputs/mapping/release路径下,移动到/app路径下 +#修复后的项目使用,保证混淆结果一致 +#-applymapping mapping.txt +#hotfix -keep class com.taobao.sophix.**{*;} -keep class com.ta.utdid2.device.**{*;} -dontwarn com.alibaba.sdk.android.utils.** @@ -130,6 +145,7 @@ -dontoptimize +# =============== # Rx -dontwarn sun.misc.** @@ -143,6 +159,7 @@ -dontwarn io.rx_cache.internal.** #ucrop +#ucrop https://github.com/Yalantis/uCrop -dontwarn com.yalantis.ucrop** -keep class com.yalantis.ucrop** { *; } -keep interface com.yalantis.ucrop** { *; } @@ -151,15 +168,20 @@ -keep class com.nineoldandroids.** { *; } +# =============== # renderscript -keep class android.support.v8.renderscript.** { *; } # 高德地图 +# 高德地图 https://lbs.amap.com/api/android-sdk/guide/create-project/dev-attention # 3D 地图 -keep class com.amap.api.maps.**{*;} -keep class com.autonavi.**{*;} -keep class com.amap.api.trace.**{*;} +-keep class com.amap.api.maps.**{*;} +-keep class com.autonavi.**{*;} +-keep class com.amap.api.trace.**{*;} # 定位 -keep class com.amap.api.location.**{*;} @@ -255,10 +277,12 @@ public static ** valueOf(java.lang.String); } -keepclasseswithmembers class * { + #noinspection ShrinkerUnresolvedReference public (android.content.Context, android.util.AttributeSet); public (android.content.Context, android.util.AttributeSet, int); } -keep class * implements android.os.Parcelable { + #noinspection ShrinkerUnresolvedReference public static final android.os.Parcelable$Creator *; } -keepclassmembers class * implements java.io.Serializable { @@ -280,6 +304,7 @@ #---------------------------------webview------------------------------------ -keepclassmembers class * extends android.webkit.WebViewClient { + #noinspection ShrinkerUnresolvedReference public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap); public boolean *(android.webkit.WebView, java.lang.String); } @@ -304,6 +329,7 @@ -keep class com.uc.** {*;} -keepclassmembers class * { + #noinspection ShrinkerUnresolvedReference public (org.json.JSONObject); } -keepclassmembers enum * { @@ -332,3 +358,4 @@ public static final int *; } -keep,allowshrinking class org.android.agoo.service.* {*;} -keep,allowshrinking class org.android.spdy.**{*;} + diff --git a/build_logic/src/main/kotlin/com.redrock.app.gradle.kts b/build_logic/src/main/kotlin/com.redrock.app.gradle.kts index 9160e6895..64007992b 100644 --- a/build_logic/src/main/kotlin/com.redrock.app.gradle.kts +++ b/build_logic/src/main/kotlin/com.redrock.app.gradle.kts @@ -40,7 +40,7 @@ android { //多渠道包的输出目录,默认为new File(project.buildDir,"channel") outputDir = File(project.buildDir,"channel") //多渠道包的命名规则,默认为:${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}-${buildTime} - apkNameFormat ="\${appName}-\${versionName}-\${versionCode}-\${flavorName}-\${buildType}-\${buildTime}" + apkNameFormat ="\${appName}-\${versionName}-\${versionCode}-\${flavorName}-\${buildType}" //快速模式:生成渠道包时不进行校验(速度可以提升10倍以上,默认为false) fastMode = false //buildTime的时间格式,默认格式:yyyyMMdd-HHmmss @@ -65,7 +65,7 @@ android { isMinifyEnabled = true isZipAlignEnabled = true isShrinkResources = true - proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "${rootDir}/build_logic/proguard-rules.pro") signingConfig = signingConfigs.getByName("config") diff --git a/build_logic/src/main/kotlin/cyxbs.library-base.gradle.kts b/build_logic/src/main/kotlin/cyxbs.library-base.gradle.kts index 8e81b94ab..ffae31609 100644 --- a/build_logic/src/main/kotlin/cyxbs.library-base.gradle.kts +++ b/build_logic/src/main/kotlin/cyxbs.library-base.gradle.kts @@ -1,4 +1,5 @@ import ext.get +import gradle.kotlin.dsl.accessors._11b1f85c87a6b4d0c16534be4db6fa46.ext import org.gradle.api.JavaVersion import org.gradle.kotlin.dsl.kotlin import versions.AGP @@ -14,7 +15,14 @@ android { publishing { singleVariant("debug") } - + signingConfigs { + create("config") { + keyAlias = project.ext["secret"]["sign"]["RELEASE_KEY_ALIAS"] as String + keyPassword = project.ext["secret"]["sign"]["RELEASE_KEY_PASSWORD"] as String + storePassword = project.ext["secret"]["sign"]["RELEASE_STORE_PASSWORD"] as String + storeFile = file("$rootDir/build_logic/secret/key-cyxbs") + } + } defaultConfig { minSdk = AGP.mineSdk targetSdk = AGP.targetSdk @@ -31,7 +39,19 @@ android { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "${rootDir}/build_logic/proguard-rules.pro") + signingConfig = signingConfigs.getByName("config") + + ndk { + // 修改安装包的架构要记得同步修改上面的 Bugly 的 ndk 依赖 + abiFilters += listOf("arm64-v8a") + } + } + } kotlinOptions { jvmTarget = "1.8" } diff --git a/gradle.properties b/gradle.properties index 557f05260..3bc54753d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ # 配置jvm堆大小,采用并行Gc提速 # https://developer.android.com/studio/build/optimize-your-build?utm_source=android-studio#configure-the-jvm-garbage-collector # https://docs.gradle.org/current/userguide/performance.html#adjust_the_daemons_heap_size -org.gradle.jvmargs=-Xmx2048m -XX:+UseParallelGC +org.gradle.jvmargs=-Xmx4096m -XX:+UseParallelGC # 并行编译提速 # https://docs.gradle.org/current/userguide/performance.html#parallel_execution diff --git a/module_app/src/main/java/com/mredrock/cyxbs/App.kt b/module_app/src/main/java/com/mredrock/cyxbs/App.kt index a1b619fae..38c177a32 100644 --- a/module_app/src/main/java/com/mredrock/cyxbs/App.kt +++ b/module_app/src/main/java/com/mredrock/cyxbs/App.kt @@ -1,6 +1,7 @@ package com.mredrock.cyxbs import android.app.Application +import androidx.annotation.Keep import com.mredrock.cyxbs.common.BaseApp import com.mredrock.cyxbs.spi.SdkService import com.mredrock.cyxbs.spi.SdkManager @@ -9,6 +10,7 @@ import java.util.* /** * Created By jay68 on 2018/8/8. */ +@Keep class App : BaseApp(), SdkManager { private val loader = ServiceLoader.load(SdkService::class.java) diff --git a/module_app/src/main/java/com/mredrock/cyxbs/CySophixApplication.java b/module_app/src/main/java/com/mredrock/cyxbs/CySophixApplication.java index efeb740cc..9eb0d8005 100644 --- a/module_app/src/main/java/com/mredrock/cyxbs/CySophixApplication.java +++ b/module_app/src/main/java/com/mredrock/cyxbs/CySophixApplication.java @@ -17,6 +17,7 @@ * 注意原先Application里不需要再重复初始化Sophix,并且需要避免混淆原先Application类。 * 如有其它自定义改造,请咨询官方后妥善处理。 */ + public class CySophixApplication extends SophixApplication { private final String TAG = "SophixStubApplication"; diff --git a/module_discover/src/main/java/com/mredrock/cyxbs/discover/utils/MoreFunctionProvider.kt b/module_discover/src/main/java/com/mredrock/cyxbs/discover/utils/MoreFunctionProvider.kt index 616770ae0..f3c68892a 100644 --- a/module_discover/src/main/java/com/mredrock/cyxbs/discover/utils/MoreFunctionProvider.kt +++ b/module_discover/src/main/java/com/mredrock/cyxbs/discover/utils/MoreFunctionProvider.kt @@ -23,10 +23,10 @@ object MoreFunctionProvider { Function(R.drawable.discover_ic_other_course, R.string.discover_title_other_course, R.string.discover_detail_other_course, StartActivityAfterLogin("同学课表", DISCOVER_OTHER_COURSE)), Function(R.drawable.discover_ic_map, R.string.discover_title_map, R.string.discover_detail_map, StartActivityImpl(DISCOVER_MAP)), Function(R.drawable.discover_ic_todo,R.string.discover_title_todo, R.string.discover_detail_todo, StartActivityImpl(DISCOVER_TODO_MAIN)), + Function(R.drawable.discover_ic_bus_track, R.string.discover_title_bus_track, R.string.discover_detail_bus_track, StartActivityImpl(DISCOVER_SCHOOL_CAR)), Function(R.drawable.discover_ic_empty_classroom, R.string.discover_title_empty_classroom, R.string.discover_detail_empty_classroom, StartActivityImpl(DISCOVER_EMPTY_ROOM)), Function(R.drawable.discover_ic_my_exam, R.string.discover_title_my_exam, R.string.discover_detail_my_exam, StartActivityAfterLogin("我的考试", DISCOVER_GRADES)), Function(R.drawable.discover_ic_no_class, R.string.discover_title_no_class, R.string.discover_detail_no_class, StartActivityAfterLogin("没课约", DISCOVER_NO_CLASS)), - Function(R.drawable.discover_ic_bus_track, R.string.discover_title_bus_track, R.string.discover_detail_bus_track, StartActivityImpl(DISCOVER_SCHOOL_CAR)), Function(R.drawable.discover_ic_school_calendar, R.string.discover_title_school_calendar, R.string.discover_detail_school_calendar, StartActivityImpl(DISCOVER_CALENDAR)), Function(R.drawable.discover_ic_more_function, R.string.discover_title_more_function, R.string.discover_detail_more_function, StartActivityImpl(DISCOVER_MORE_FUNCTION)))