直接切入正題,正常情況下打包 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中,
- 通過將版本 3.50 => 5.6.4
- 下面這個解決辦法
android{
lintOptions {
checkReleaseBuilds false
}
}
最后附上so 參考資料 https://stackoverflow.com/questions/62394034/flutter-can-not-build-android-apk
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/224282.html
標籤:其他
