今天集成极光推送:遇到报错信息:
1.建议minSdkVersion 16改为17
2.
Running Gradle task 'assembleDebug'... Running Gradle task 'assembleDebug'... Done 11.0s [!] The shrinker may have failed to optimize the Java bytecode. To disable the shrinker, pass the``flag to this command. To learn more, see: https://developer.android.com/studio/build/shrink-code Gradle task assembleDebug failed with exit code 1
1
解决1:
1.我找到了android / app / build.gradle文件
2.然后访问了gradle文件中的以下代码
buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug } }
并将其更改为
buildTypes { debug { minifyEnabled true // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug } }
该应用程序能够在Android模拟器中运行
2.您只需要将minsdkversion更改为21而不是16
defaultConfig { applicationId "com.company.example" minSdkVersion 16 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" }
改为:
defaultConfig { applicationId "com.company.example" minSdkVersion 21 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" }
这个问题有两种不同的答案,但我认为最合适的是第二种解决方案。
这是Google的官方解释:
原文:
If you get an error, make sure that the indentation in your dependencies block is exactly as shown above, using two spaces (not a tab).
(If developing on Android…) Update minSdkVersion
Firebase plugins for Flutter on Android require a slightly higher version of the Android SDK than a default Flutter application.
If you’re developing your application on Android, you’ll need to bump its minSdkVersion to 21 for the app to keep compiling after you add the cloud_firestore dependency:
In your IDE or editor, open the android/app/build.gradle file. Locate the defaultConfig section, which will contain a minSdkVersion entry, and set it to 21:
defaultConfig { ... minSdkVersion 21 # updated minSdkVersion 16 ... }
翻译:对Android构建失败进行故障排除:
如果您打算使用Android设备或仿真器进行开发,则需要处理multidex支持-否则,您的构建将因“无法在单个dex文件中容纳请求的类”而失败。
默认情况下,Flutter支持Android SDK v16(Jelly Bean,2012年发布),但multidex并不真正适用于Jelly Bean(尽管有可能)。配置Jelly Bean正常工作超出了此代码实验室的范围,因此我们将最低目标SDK版本从v16更改为v21(Lollipop,2014年发布)。
要更改最低目标SDK版本:
打开android / app / build.gradle,然后找到显示minSdkVersion 16的行。
将该行更改为minSdkVersion 21。
保存文件。