105

Why I get this error I try to clean and rebuild application and make application release true and I get same error

Error:Execution failed for task ':app:lintVitalRelease'. java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "x.x.x"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 95
        versionName '5'

        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }

}
K.Dᴀᴠɪs
  • 9,945
  • 11
  • 33
  • 43
elpatrue diab
  • 1,051
  • 2
  • 7
  • 7

16 Answers16

101

Based off this Post

Edit: I removed the link because the thread is no longer there

What you need to do is add this chunk of code to your build.gradle file in the android{} section

lintOptions { 
    checkReleaseBuilds false
}

So like this

android {
    ...
    lintOptions {
        checkReleaseBuilds false
    }
}

Update:

Here is another post talking about a similar problem. It seems like there are various reasons this error can occur. While disabling the checkReleaseBuilds will work. It's recommended to find what the problem is and fix it. Most common error seems to be missing translations in the strings.xml file.

I recommend checking out this post for more help

Error when generate signed apk

nickc
  • 1,193
  • 1
  • 6
  • 15
  • 7
    Why disable checking the release builds? – Slick Slime May 20 '18 at 05:40
  • @SlickSlime The same question I was about asking, I think doing this for a single build if you don't have time to figure out what is wrong is okay but it's best practice to spend time figuring out the real problem, this can lead to some issues in production. – Daniel Barde Dec 22 '19 at 06:55
  • In my case build failed because issues on fragment XMLs like missing attributes. After fixed then my APK built without issues. – joseluisq Sep 05 '21 at 20:55
91

To find out why lint fails do this:

  1. Run lintVitalRelease

You can do it from Gradle window

enter image description here

  1. Under Run tab, you will see error logs

enter image description here

For me, it was wrong constraint in ConstraintLayout XML.

enter image description here

Kaaveh Mohamedi
  • 1,399
  • 1
  • 15
  • 36
Ilia Grabko
  • 1,119
  • 1
  • 8
  • 13
  • I tried this solution and found some missing ID in resource files which had constraint dependency, removed the ID and tried to create build and it worked. Thanks – Zahid Ali Jan 06 '21 at 14:12
  • Also check this https://stackoverflow.com/a/54962373/1179638 – Atul Bhardwaj Mar 11 '21 at 18:19
  • 2
    For those who cannot see the above `lintVitalRelease` option, Just click on Gradle->Execute Gradle Task Icon-> type in `lintVitalRelease` and press enter. It will show what is wrong. – Reejesh Dec 09 '22 at 13:49
26

Open your build.gradle file and add the code below under android:

android {

    lintOptions { 
      checkReleaseBuilds false 
    }
Dharman
  • 30,962
  • 25
  • 85
  • 135
23

The error report is saved to [app module]/build/reports/lint-results-yourBuildName-fatal.html. You can open this file in a browser to read about the errors.

src: https://stackoverflow.com/a/50239165/365229

Behrouz.M
  • 3,445
  • 6
  • 37
  • 64
21
lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
Makvin
  • 3,475
  • 27
  • 26
  • 5
    but why it is happens? – Pavel Poley Aug 21 '18 at 08:43
  • @PavelPoley With 0.7.0 there comes extended support for Lint, however, it does not work always properly. – Makvin Aug 21 '18 at 09:13
  • 29
    Do not turn off the lint checks, they're there for a reason. – Chandler Sep 19 '18 at 10:28
  • Thanks for solution. but is any problem occurs if we set false ? – Vrajesh Dec 13 '18 at 11:18
  • 1
    there seems to be no bad side effects when we disable the `lint`, but do NOT disable it and repeat trying to build until you find the real issue, for example I was about to disable it, because it did just hang for me, but after retrying a really verbose error message showed what the error was (a `*.jar` file was missing in my local m2 repository, but since the `*.pom` file did exist, `gradle` did fail instead of simply downloading again both `*.jar` and `*.pom` files) – Top-Master Apr 15 '19 at 04:58
17

Simple and Working

Solution 1

android {
        lintOptions {
            checkReleaseBuilds false
            // Or, if you prefer, you can continue to check for errors in release builds,
            // but continue the build even when errors are found:
            abortOnError false
        }
    }

Solution 2

android {
        lintOptions {
            checkReleaseBuilds false
            abortOnError false
        }
    }

Solution 3

 android {
        lintOptions {
           disable 'MissingTranslation'
           abortOnError false
        }
    }

Notes: There are two type uses option ->

1

 lintOptions {
        //TODO
    }

2

android {
        lintOptions {
           // TODO
        }
    }

Thank You

Kumar Santanu
  • 603
  • 1
  • 7
  • 14
5

File > Invalidate Caches/Restart... worked for me.

Kamran Riyaz
  • 79
  • 2
  • 3
5

I have solved this by updating my gradle-wrapper.properties and build.gradle.

in gradle-wrapper.properties update distributionUrl:

distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip

and android/build.gradle change the gradle version from 4.1.0 to 7.1.2

classpath 'com.android.tools.build:gradle:7.1.2'

Hope it will help.

2

If you have tried everything on Google but still can't build the release. You can follow my approach:

Firstly, If the Android Studio error log contains the phrase "debug/libs.jar", then you need to build --debug then --release:

flutter build apk --debug
flutter build apk --release

What if "profile/libs.jar" appears , build --profile then --release:

flutter build apk --profile
flutter build apk --release

If there is an error when building debug or profile, then you continue to find that error on Google and fix it. In my case I had to remove the permission_handler library because it was causing the error.

Doan Bui
  • 3,572
  • 25
  • 36
1

I was also getting an error like

         > Failed to transform '/Users/michaelbui/Projects/counter/build/app/intermediates/flutter/debug/libs.jar' using Jetifier. Reason: FileNotFoundException, message: /Users/michaelbui/Projects/counter/build/app/intermediates/flutter/debug/libs.jar (No such file or directory). (Run with --stacktrace for more details.)

while building the app after the latest update, but then I disabled the lint task in android/app/build.gradle

lintOptions {
    disable 'InvalidPackage'
    checkReleaseBuilds false
}

and this worked for me.

Anshul Kataria
  • 956
  • 8
  • 8
1

In my opinion don't use "checkReleaseBuilds false". This broke my whole release build and I only saw a white screen.

A current workaround is running:

flutter run --profile
flutter run --debug
flutter run --release

Currently that's the only thing that worked for me. There is an open issue here: https://issuetracker.google.com/issues/158753935

novas1r1
  • 1,803
  • 21
  • 28
1

In my case it was happening because I was using an invalid(not existing) id to constraint a view, and when I tried to create a build, it gave me the error. What you can do is execute task,

./gradlew assembleRelease --stacktrace

This will give you the following options,

To proceed, either fix the issues identified by lint, or modify your build script as follows:

...
android {
lintOptions {
    checkReleaseBuilds false
    // Or, if you prefer, you can continue to check for errors in release builds,
    // but continue the build even when errors are found:
    abortOnError false
}
}

If you choose,

checkReleaseBuilds false

It will not check for errors in the release build and create a build,

and if you choose,

abortOnError false

It will create a build, and as well list down the error(s).

This way you can actually correct the errors.

Anubhav
  • 1,984
  • 22
  • 17
  • Can you please read other answers before posting yet another duplicate answer?! On top of that, why do you even disable lint checks? – Farid Apr 22 '22 at 05:49
0

Make sure to have jcenter() in both buildscript and allprojects in your build.gradle android{} section

0

In my case there was some typos in the manifest that caused the error, just corrected them and it compiled

Cramos50
  • 1
  • 1
0

I had some missing jars and behind a corporate firewall and there was an attempt to download them during lintVitalRelease. I disconnected from VPN, re-run, which downloaded the missing jars and all returned to normal.

I knew it has to be something like that because other answers mention where error reports are generated but I had nothing generated there so it was stuck somewhere for me.

Silviu Burcea
  • 5,103
  • 1
  • 29
  • 43
0

Cleaning and rebuilding worked for me

flutter clean
flutter build apk --release
Peter Kreinz
  • 7,979
  • 1
  • 64
  • 49