1、 打正式包 运行报错 No pending exception expected: java.lang.ClassNotFoundException: Didn’t find class “
1、可能需要配置相关SDK 混淆规则,曾遇到没有配置百度SDK混淆规则导致报错
百度SDK混淆正确配置
-keep class com.baidu.** {*;} ///保持com.baidu.**这个包里面的所有类和所有方法不被混淆。
-keep class mapsdkvi.com.** {*;}
-dontwarn com.baidu.** #忽略警告
导致错误的配置
-keep class com.baidu.** {*;}
-keep class vi.com.** {*;} ///配置错误行
-dontwarn com.baidu.**
2、或者把混淆关了(最好不要这样做)
release {
minifyEnabled false
}
/
2、Gradle task assembleRelease failed with exit code - Removing unused resources requires unused code shrinking to be turned on
详细错误
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the
APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/sunpc/Desktop/kxp_flutter/android/build.gradle' line: 30
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Removing unused resources requires unused code shrinking to be turned on. See http://d.android.com/r/tools/shrink-resources.html for more information.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 765ms
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 1.5s
Gradle task assembleRelease failed with exit code 1
处理
buildTypes - release, 添加 shrinkResources true
buildTypes {
release {
signingConfig signingConfigs.release
//移除无用的resource文件
shrinkResources true
//混淆开关
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}