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
https://stackoverflow.com/questions/60745249/flutter-the-shrinker-may-have-failed-to-optimize-the-java-bytecode
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模拟器中运行
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"
}
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:
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设备或仿真器进行开发,则需要处理multidex支持-否则,您的构建将因“无法在单个dex文件中容纳请求的类”而失败。
默认情况下,Flutter支持Android SDK v16(Jelly Bean,2012年发布),但multidex并不真正适用于Jelly Bean(尽管有可能)。配置Jelly Bean正常工作超出了此代码实验室的范围,因此我们将最低目标SDK版本从v16更改为v21(Lollipop,2014年发布)。
要更改最低目标SDK版本:
联系客服