21

I can not release my app any more . I'm using AndroidStudio 4.0 and flutter sdk version 1.17.5 . I had been released my app two times last month but now I really don't know whats the reason of error. when I type flutter build apk --release in terminal then these errors occure:

        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
Zahra
  • 2,231
  • 3
  • 21
  • 41

7 Answers7

53

If error is about profile/libs.jar , do following in terminal :

flutter build apk --profile

and then

flutter build apk --release  

solves the issue.

and if error is about debug/libs.jar

flutter build apk --debug

and then

flutter build apk --release  

will solve the problem

Zahra
  • 2,231
  • 3
  • 21
  • 41
  • 1
    That's what I get after running `flutter build apk --profile`: `Gradle build failed to produce an .apk file. It's likely that this file was generated under ~/dev/flutter/discover_rudy/build, but the tool couldn't find it` – Bartek Pacia Jul 25 '20 at 18:44
17

For me worked this way only:

First: flutter build apk --debug
Then: flutter build apk --profile
In the end: flutter build apk --release
wahid anvary
  • 392
  • 3
  • 11
  • while @Zahra answer is leading, this answer is the only one that helped me. make sure to do exactly those steps at the same order. – genericUser Mar 10 '21 at 18:30
15

I have upgraded my gradle build tools 3.5.0 -> 4.0.1. After that I am not was not able to make release apk. Looks like upgrading gradle build tools broke some lints.

Below solution worked for me

Go in android folder->app->open build.gradle fine Search for lintOptions and add checkReleaseBuilds false example:

lintOptions {
  disable 'InvalidPackage'
  checkReleaseBuilds false //Insert this line
}
Pål Brattberg
  • 4,568
  • 29
  • 40
Sachin Tanpure
  • 1,068
  • 11
  • 12
  • 1
    make sure to move lintOptions to the android section of your Gradle file: https://developer.android.com/reference/tools/gradle-api/4.1/com/android/build/api/dsl/LintOptions but also it seems not to be recommended approach: https://stackoverflow.com/questions/24098494/applintvitalrelease-error-when-generating-signed-apk – Mando Jul 15 '21 at 18:19
2

In my case, I had to add the flavor name as well following this sequence:

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>
0

Worked for me

1- flutter build apk --debug

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

I know that the problem may have already been solved, however I did not like the way the proposed solutions propose to solve the problem. In my view, the following is a more correct solution:

Make sure everything here is correct: https://flutter.dev/docs/deployment/android#shrinking-your-code-with-r8

Be sure to check each parameter and version used. This works in all my apps and without gambling.

Check if in android\app\build.gradle is as below:

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

Check if in android\build.gradle is as below:

buildscript {
    repositories {
        google()
        jcenter()
    }

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

Check if in android\gradle.properties is as below:

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

Check if in android\gradle\wrapper\gradle-wrapper.properties is as below:

#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

Now you can run the commands: flutter run apk or flutter run appbundle should work.

Edeson Bizerril
  • 1,595
  • 1
  • 11
  • 12
0

Follow these steps if anyone encounter same issue

  1. Go to Terminal write following lines
  2. flutter clean
  3. flutter pub get
  4. flutter build apk --profile
  5. flutter build apk --release

hope it will solve the issue