Gradle error while running flutter app in Android Studio - flutter

Anytime I try to run the default flutter app in android studio, I get an error saying this
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\NAME\StudioProjects\first_app\android\build.gradle' line: 24
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Could not open proj generic class cache for build file 'C:\Users\Jonat\StudioProjects\first_app\android\app\build.gradle' (C:\Users\Jonat\.gradle\caches\6.7\scripts\9jolsr12r2iru3ssdih8as3s3).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 60
* 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 1s
Exception: Gradle task assembleDebug failed with exit code 1
I tried searching for an answer but I did not find a solution. I decided to open my command prompt and type in Gradle and this is what I see,
I don't know what to do or where to start since I am new to android studio. Is there a way to get rid of this error?
UPDATE
I went to the folder that was mentioned in the first error and all I needed to do was update the Gradle and it loaded everything. But now I'm receiving a new error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module #77e838c
* 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.
would anyone know how to go about this error?

Related

Flutter - audio_session - Could not load compiled classes for build file build.gradle from cache

I am trying to run my flutter project but facing this issue.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':audio_session'.
> Could not load compiled classes for build file 'C:\flutter_2.5.2\.pub-cache\hosted\pub.dartlang.org\audio_session-0.1.6+1\android\build.gradle' from cache.
* 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 1s
Exception: Gradle task assembleDebug failed with exit code 1
I have tried deleting audio_session-0.1.6+1 from the path C:\flutter_2.5.2\.pub-cache\hosted\pub.dartlang.org\ but it didn't work. It is creating the package folder again and again when I build the APK.

FAILURE: Build failed with an exception, In my flutter project how can i solve it?

FAILURE: Build failed with an exception.
Where:
Build file 'C:\flutterproject\firstproject\android\untitled\android\build.gradle' line: 27
What went wrong:
A problem occurred evaluating root project 'android'.
A problem occurred configuring project ':app'.
Failed to notify project evaluation listener.
> 'org.gradle.api.file.DirectoryProperty org.gradle.api.file.ProjectLayout.directoryProperty(org.gradle.api.provider.Provider)'
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 6s
Exception: Gradle task assembleDebug failed with exit code 1
File → Settings → Build, Execution, Deployment → Instant Run and
uncheck Enable Instant Run.
Hope it works.

imagepicker won't let me run my app on android, on IOS it works fine

When I run my app in ios simulation everything works fine, but on android I have an error I think with image picker and gradle here is the error :
I tried the mutlidex solution but it does not seem to work.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':image_picker: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.org
BUILD FAILED in 44s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to
try using Jetfier to solve the incompatibility.
Building plugin image_picker...
> Configure project :
WARNING: The option setting 'android.enableR8=true' is experimental and unsupported.
The current default is 'false'
Consider disabling R8 by removing 'android.enableR8=true' from your gradle.properties before
publishing your app.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'imagepicker'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with
an ANDROID_HOME environment variable.
* 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 7s
Exception: The plugin image_picker could not be built due to the issue above.

Flutter build error: A problem occurred configuring root project 'bidirectional_scroll_view'

I am trying to build my project to APK file, but I am stuck with this error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'bidirectional_scroll_view'.
> Failed to notify project evaluation listener.
> org.gradle.api.tasks.compile.CompileOptions.setBootClasspath(Ljava/lang/String;)V
* 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 910ms
The plugin bidirectional_scroll_view could not be built due to the issue above.
The command I had run is this: flutter build apk --split-per-abi.
If someone would help me I would be glad! :D
I was just using an old version of bidirectional_scroll_view package.

ionic 3: FAILURE: Build failed with an exception

I am trying to create Android App Bundle for an ionic 3 project. When running the command ./gradlew bundle I get the error below. In the .bash_profile file I have added the following:
export ANDROID_HOME=/Users/dome/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH/:$ANDROID_HOME/platform-tools
The Gradle version is: 4.4.1.
ERROR
iMac:android dome$ ./gradlew bundle
> Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The onesignal-gradle-plugin MUST be before com.android.application!
Please put onesignal-gradle-plugin first OR update to com.android.tools.build:gradle:3.0.0 or newer!
An exception occurred while trying to find the Android build tools.
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
* Where:
Script '/Users/dome/myAPP/platforms/android/CordovaLib/cordova.gradle' line: 121
* What went wrong:
A problem occurred evaluating project ':app'.
> Unable to determine Android SDK directory.
* 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 0s
iMac:android dome$
After adding the exports below, I didn't close and reopen the terminal hence the issues. Now sorted.
export ANDROID_HOME=/Users/dome/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH/:$ANDROID_HOME/platform-tools