关与android studio 4.0 flutter 打包情况出错问题

直接切入正题,正常情况下打包 flutter build apk release包也就生成了,可是当AS升级到4.0的情况下,再去编译运行该命令就会编译失败。
如:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform libs.jar to match attributes {artifactType=processed-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: E:\FlutterSpace\xxxx\build\app\intermediates\flutter\debug\libs.jar.
         > Transform's input file does not exist: E:\FlutterSpace\xxxx\build\app\intermediates\flutter\debug\libs.jar. (See https://issuetracker.google.com/
issues/158753935)

* 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

莫名其妙的错误,而且无从下手,一顿google后,发现在StackOverflow上有人做出了这样的解释,大致意思:

With Android plugin 4.0 there may be specific problem either end with debug/libs.jar or profile/libs.jar. This indicates which apk you need to build first. In this case it is debug/libs.jar so building --debug first and then --release worked. In my case, it was profile/libs.jar so building --profile and then --release will work. If you want not to follow all three steps, build signed apk or appbudle with Android Studio, opeing android directory in.

有了Android 4.0的插件可能有特定的问题,或者与最终debug/libs.jar还是profile/libs.jar。这表明apk您需要先构建哪个。在这种情况下,首先要debug/libs.jar构建–debug然后再–release工作。以我为例,它是profile/libs.jar如此构建–profile,然后–release将起作用。如果你想不遵循这三个步骤,构建签署apk或appbudle与Android工作室,opeingandroid directory

意思是每次打包都要按照以下三个步骤去执行,才能获取release包
Step 1. flutter build apk --debug

Step 2. flutter build apk --profile

Step 3. flutter build apk --release

太繁琐了,解决方方法有2中,

  1. 通过将版本 3.50 => 5.6.4
  2. 下面这个解决办法
android{
	lintOptions {
        checkReleaseBuilds false
    }
}

最后附上so 参考资料 https://stackoverflow.com/questions/62394034/flutter-can-not-build-android-apk

猜你喜欢

转载自blog.csdn.net/telencool/article/details/109735704