The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app

silsly
2 min readApr 19, 2019

If you find the error like this..

FAILURE: Build failed with an exception.* What went wrong:
Execution failed for task ‘:location:compileDebugJavaWithJavac’.
> Compilation failed; see the compiler error output for details.
* 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.orgBUILD FAILED in 42s
Finished with error: Gradle task assembleDebug failed with exit code 1
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://goo.gl/CP92wY for more information on the problem and how to fix it.
*******************************************************************************************

or like this..

Running Gradle task ‘assembleDebug’…
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

or like this..

It may be happened when you have multiple gradle in one project, the solution is just recheck your gradle.properties, delete the old one, and use the newest one

gradle-4.10.1

Next, follow this steps :

  1. Use the newest gradle version and delete the others
  2. File > Invalidate Caches, Restart
  3. Build > Clean Project or flutter clean
  4. File > Sync with All System
  5. Add this path in gradle-wrapper.properties distributionUrl=https://services.gradle.org/distributions/gradle-4.10.1-all.zip
  6. See the logcat and find the error, in the above we can see that library PackageInfo has deprecated (PackageInfo.java uses unchecked or unsafe operations). So, fix it by using the newest version of that library (check in https://pub.dartlang.org). Use and install it. Run packages get. Done.
  7. Now run again the project

--

--