打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
集成极光推送遇到的问题

文章目录


今天集成极光推送:遇到报错信息:

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:

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:

  1. 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版本:

  1. 打开android / app / build.gradle,然后找到显示minSdkVersion 16的行。
  2. 将该行更改为minSdkVersion 21。
  3. 保存文件。
    链接
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
源码解读Flutter run原理
Flutter Android 打包App
Android studio之编译出现 Error:null value in entry: outputDirectory=null
Android Project和app中两个build.gradle配置的区别
利用 Android Gradle 瘦身 apk
Flutter完整开发实战详解(十四、混合开发打包 Android 篇)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服