1、 打正式包 运行报错 No pending exception expected: java.lang.ClassNotFoundException: Didn’t find class “

1、可能需要配置相关SDK 混淆规则,曾遇到没有配置百度SDK混淆规则导致报错

百度SDK混淆正确配置

  1. -keep class com.baidu.** {*;} ///保持com.baidu.**这个包里面的所有类和所有方法不被混淆。
  2. -keep class mapsdkvi.com.** {*;}
  3. -dontwarn com.baidu.** #忽略警告

导致错误的配置

  1. -keep class com.baidu.** {*;}
  2. -keep class vi.com.** {*;} ///配置错误行
  3. -dontwarn com.baidu.**

2、或者把混淆关了(最好不要这样做)

  1. release {
  2. minifyEnabled false
  3. }

/

2、Gradle task assembleRelease failed with exit code - Removing unused resources requires unused code shrinking to be turned on

详细错误

  1. You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
  2. If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the
  3. APK size.
  4. To generate an app bundle, run:
  5. flutter build appbundle --target-platform android-arm,android-arm64,android-x64
  6. Learn more on: https://developer.android.com/guide/app-bundle
  7. To split the APKs per ABI, run:
  8. flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
  9. Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
  10. FAILURE: Build failed with an exception.
  11. * Where:
  12. Build file '/Users/sunpc/Desktop/kxp_flutter/android/build.gradle' line: 30
  13. * What went wrong:
  14. A problem occurred evaluating root project 'android'.
  15. > A problem occurred configuring project ':app'.
  16. > Removing unused resources requires unused code shrinking to be turned on. See http://d.android.com/r/tools/shrink-resources.html for more information.
  17. * Try:
  18. 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.
  19. * Get more help at https://help.gradle.org
  20. BUILD FAILED in 765ms
  21. Running Gradle task 'assembleRelease'...
  22. Running Gradle task 'assembleRelease'... Done 1.5s
  23. Gradle task assembleRelease failed with exit code 1

处理
buildTypes - release, 添加 shrinkResources true

  1. buildTypes {
  2. release {
  3. signingConfig signingConfigs.release
  4. //移除无用的resource文件
  5. shrinkResources true
  6. //混淆开关
  7. minifyEnabled true
  8. useProguard true
  9. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  10. }
  11. }