簡體   English   中英

flutter 發布 apk 錯誤:任務 ':app:lintVitalRelease' 執行失敗

[英]flutter release apk error :Execution failed for task ':app:lintVitalRelease'

我不能再發布我的應用程序了。 我正在使用 AndroidStudio 4.0 和 flutter sdk 版本 1.17.5。 上個月我兩次發布了我的應用程序,但現在我真的不知道錯誤的原因是什么。 當我在終端中鍵入flutter build apk --release時,會出現以下錯誤:

        Running Gradle task 'assembleRelease'...


FAILURE: Build failed with an exception.



* What went wrong:

Execution failed for task ':app:lintVitalRelease'.

> Could not resolve all artifacts for configuration ':app:profileRuntimeClasspath'.

   > Failed to transform libs.jar to match attributes {artifactType=processed-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.

      > Execution failed for JetifyTransform: ....\build\app\intermediates\flutter\profile\libs.jar.

         > Failed to transform '....\build\app\intermediates\flutter\profile\libs.jar' using Jetifier. Reason: FileNotFoundException, message: ....\build\app\intermediates\flutter\profile\libs.jar (The system cannot find the path specified). (Run with --stacktrace for more details.)

           Please file a bug at http://issuetracker.google.com/issues/new?component=460323.



* 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



BUILD FAILED in 42s
Running Gradle task 'assembleRelease'...                           43.4s
Gradle task assembleRelease failed with exit code 1

如果錯誤是關於profile/libs.jar ,請在終端中執行以下操作:

flutter build apk --profile

接着

flutter build apk --release  

解決了這個問題。

如果錯誤是關於debug/libs.jar

flutter build apk --debug

接着

flutter build apk --release  

會解決問題

對我來說,僅以這種方式工作:

First: flutter build apk --debug
Then: flutter build apk --profile
In the end: flutter build apk --release

我已經升級了我的 gradle 構建工具 3.5.0 -> 4.0.1。 之后我不是無法發布 apk。 看起來升級 gradle 構建工具破壞了一些 lints。

以下解決方案對我有用

Go 在 android 文件夾->應用程序->打開 build.gradle 細搜索 lintOptions 並添加checkReleaseBuilds 錯誤示例:

lintOptions {
  disable 'InvalidPackage'
  checkReleaseBuilds false //Insert this line
}

為我工作

1- flutter build apk --debug

2- flutter build apk --profile
3-  flutter build apk --release

就我而言,我必須按照以下順序添加風味名稱:

flutter build apk --debug --flavor <dev-flavor>
flutter build apk --debug --flavor <prod-flavor>
flutter build apk --profile --flavor <dev-flavor>
flutter build apk --profile --flavor <prod-flavor>
flutter build apk --release --flavor <dev-flavor>
flutter build apk --release --flavor <prod-flavor>

我知道問題可能已經解決了,但是我不喜歡建議的解決方案提出的解決問題的方式。 在我看來,以下是更正確的解決方案:

確保這里的一切都是正確的: https://flutter.dev/docs/deployment/android#shrinking-your-code-with-r8

請務必檢查使用的每個參數和版本。 這適用於我的所有應用程序,無需賭博。

檢查android\app\build.gradle中是否如下:

buildTypes {
       release {
           signingConfig signingConfigs.release
           minifyEnabled true
           shrinkResources true
           useProguard true
           proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
       }
   }

檢查android\build.gradle中是否如下:

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath 'com.google.gms:google-services:4.3.4'
    }
}

檢查android\gradle.properties中是否如下:

org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true

檢查android\gradle\wrapper\gradle-wrapper.properties中是否如下:

#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

現在您可以運行命令: flutter run apkflutter run appbundle應該可以工作。

如果有人遇到同樣的問題,請按照以下步驟操作

  1. Go 到終端寫入以下行
  2. flutter clean
  3. flutter pub get
  4. flutter build apk --profile
  5. flutter build apk --release

希望它能解決問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM