Could not open settings generic class cache for settings file Flutter - flutter

When I clone the project from GitHub and execute the program it throws this error
Please help all thanks
BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 61

"Unsupported class file major version 61" indicates java 17, which is used by Gradle.
https://stackabuse.com/bytes/fix-java-error-unsupported-class-file-major-version-63/
This indicates major class version and corresponding Java versions.
https://docs.gradle.org/7.3/release-notes.html
Per this link, Java 17 support was added circa Gradle 7.3, so either upgrade to a more recent version of Gradle, or change your settings to use an earlier version of Java (such as JAVA_HOME if using the CLI).

If you run flutter doctor, you probably will see:
[!] Android Studio (version 2022.1)
✗ Unable to find bundled Java version.
https://github.com/flutter/flutter/issues/118502 seems to be the latest issue in which this crops up. https://github.com/flutter/flutter/issues/106674 notes they reverted a buggy change, but it hasn't hit stable yet, so you'll have to symlink the bundled JRE folder as a workaround til the next AS update.
e.g. for mac, you can use:
cd /Applications/AndroidStudio.app/Contents
ln -s jbr jre

Related

Flutter application not working due to Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8

I am trying to make a flutter application but I constantly get this error :
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`
I followed this question : Android Studio Error "Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8"
and this was the output :
------------------------------------------------------------
Gradle 7.4
------------------------------------------------------------
Build time: 2022-02-08 09:58:38 UTC
Revision: f0d9291c04b90b59445041eaa75b2ee744162586
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 13.0.7 (Private Build 13.0.7+5-Ubuntu-0ubuntu120.04)
OS: Linux 5.4.0-125-generic amd64
JVM points to 13.0.7. What can be issue and how can it be resolved? Thankyou
In your Android Studio IDE, go to ~
Preferences → Build, Execution, Deployment → Build Tools → Gradle → *Gradle JDK
and choose the appropriate JDK version and apply. Try to take the embedded JDK as that would be IDE version appropriate. After this sync project and run.
Check your version of Android Studio and update to Dolphin (2021.3.x).
There are plenty of answers to this question out there that simply ask you to point to the right SDK. None of them appreciate that in some 4.x versions of Android Studio, you can be pointing to the right SDK, but Android Studio keeps pointing to the v1.8, even if you have a version >11 installed and selected in:
Project Structure, or
Preferences
It's possible that: C:*\java -version --> Results in jre/jvm >11, your 'flutter doctor -v' still says: jre/jvm-1.8.
If you don't see the above screen posted by GeekyChick in settings (i.e., "it's a location that only opens up a checkbox where its written generate *.iml files"), than you probably have Android Studio v4.x, rather than a 2021.x or greater.
Upgrade your Android Studio to Dolphin, and re-follow the instructions to choose the right SDK in Project Structure (not Settings).

Could not open settings generic class cache for settings file '

I reinstalled my android studio since the sdk was not found and so on. After re installing java jdk and android studio , everything worked well until I got an error saying 'Could not initialize class org.codehaus.groovy.runtime.InvokerHelper' which I solved by changing the Gradle version. And now the error is 'Type 'FlutterTask' property 'assets' is missing an input or output annotation.'
FAILURE: Build failed with an exception.
What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\loran\ASProjects\xylophone-flutter\android\settings.gradle' (C:\Users\loran.gradle\caches\6.8.2\scripts\4mawlyb2l5e9tefyvnpxva1kg).
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 46s
Exception: Gradle task assembleDebug failed with exit code 1
I also had this problem So I did install java 8
You might have Java 13 So install Java 8
Java JDK 16 is the one that seems to lead to this issue try downgrading by downloading a lower version of JDK preferable JDK 8 or 11
To future individuals who will run to this error. Here is the link to download the JDK enjoy your coding experience don't forget to change the path too.
https://www.oracle.com/java/technologies/javase-downloads.html
mainly you have jdk16 i tried to install java 8 and set env to java 8 it worked for me
Try installing the latest Gradle package gradle-7.1.1, if you are using Java JDK 16 installed. To do this open android/gradle/wrapper/gradle-wrapper.properties file and under distribution url, update the gradle version to 7.1.1 (or the latest). After that, inside your Flutter project directory, run the following command in the terminal:
cd android && ./gradlew
I removed the JAVA_HOME path to the JAVA download and changed JAVA_HOME path to the following:
C:\Program Files\Android\Android Studio\jre
I am now coding
FOUND IT !
No need to change your JDK version, follow the steps to resolve the issue:
check your java version and remember it, use "java -version" in terminal
go to your android studio path installation
then in: Android Studio/jre/ open the file named "release"
take attention of the value of JAVA_VERSION field
if it's not the same as the java version on your computer, just change it with the version installed on your computer.
That's it, i hope it will resolve your issue like it resolves mine.
Try it and give a feedback.
Try this!
Remove package android from the top of settings.gradle. This helped me out.
If this error occurs, this might because you have installed the latest JDK such as JDK 16. You download and install JDK 8 and uninstall JDK 16. Then restart the desktop/laptop and try launch and run flutter run again. It should be working fine.
In my case, on Windows 10, my JAVA_HOME was set to JAVA SE 16 C:\Program Files\Java\jdk-16 and when I looked at the release file in java jre in android studio, C:\Program Files\Android\Android Studio\jre\release, I found that the the JAVA_VERSION WAS "11.0.10" (java 11) for short. So I changed the java installation on my PC to Java 11, update JAVA_HOME in my environment variables to point to the new java (C:\Program Files\Java\jdk-11.0.12) and restarted android studio, Then everything worked.
You can get your java 11 from here.
https://www.oracle.com/java/technologies/javase-jdk11-downloads.html. Change 11 to 8, 16 etc to get the download link for the java version you need.
The problem has to do with having Java 13 or 16 installed on your computer. The current version of Flutter does not work with Java 13 and 16. Just uninstall either of these that you may have installed and installed Java 8 or Java 11. Restart your computer to effect the update. Everything should be fine afterwards
I got this error when using flutter. I fixed it ensuring the android-studio-dir path was set correctly.
You set it up using flutter config --android-studio-dir="android studio path".
Then run flutter doctor and ensure flutter can see Android Studio
In 'adnroid/gradle/wrapper/gradle-wrapper.properties'
Change distributionUrl to version 7.0.1
In 'android/build.gradle'
Change 'com.android.tools.build:gradle' to version 4.2.0
Java 11 is the only supported version by Flutter as for now. It compiles and installs.
Previously I had this error using Java 19 and Java 8.
You might want update your gradle version.
Check the supported gradle <-> kotlin <-> java version on their page.
You can try this, it works for me.
Open the android module to a new window and automatically download all necessary libraries after successfully building finished run the app.
Simply go to your Android Studio path -> C:\Program Files\Android\Android Studio
open jbr folder -> copy all files -> then go back -> paste all the files in the jre folder and "replace the files in the destination".
It works for me in two different laptops. I have latest jdk version - 19.0.2
The error message you're seeing is related to the flutter build process and it occurs when a required input or output annotation is missing from the assets property of the FlutterTask.
task buildFlutter(type: FlutterTask) {
// Add the #Input annotation to the assets property
#Input List<String> assets = ["assets/images/", "assets/fonts/"]
}
Try to disable AVAST, check system vatiables path for JDK and SDK, clear cache with yarn.

No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi

I was working on a Flutter project and everything was working fine until I updated My Android Studio and some of the SDK tools. Then when I was trying to run my project, I was getting the Error below:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi
* 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](https://help.gradle.org)
BUILD FAILED in 1m 4s
Exception: Gradle task assembleDebug failed with exit code 1
So what have gone wrong? What should I do?
The main reason is that NDK 23 has different toolchain than the previous versions of NDK (22-), so the old version of AGP (Android Gradle Plugin) has not idea where to find the executables for different ABIs.
For me, simply update the AGP version in the build.gradle in your Android project root to 4.0+, such as
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
...
This will resolve the problem.
Note: You will need to set the environment variable ANDROID_NDK_HOME to your NDK 22- location, even Google's document does not require that or says it is deprecated.
If you want to stick to the current version of AGP, there is another work around, simply add this
android {
android.ndkVersion "21.4.7075529" // (or whichever NDK 22- version you have installed)
...
to your module's build.gradle (not the build.gradle of your project)
Some other ways to work around this can be found here, Configure the NDK for the Android Gradle plugin
Well I solved the issue in 2 different ways:
A. I downgraded my NDK from version 23.0.7123448 to 22.0.7026061 by simple steps below:
1.Open SDK Manager from tool bar of android studio or from settings menu (File --> Settings --> Appearance and Behavior --> System Settings --> Android SDK).
Select the SDK Tools tab and from the Bottom Right of the window check the Show package details. Then simply uncheck any version you want to delete and select Apply.
(For me removing version 23.0.7123448 and get to 22.0.7026061 solved the problem. But if you are still having the Error above try to lower the NDK version. The most stable NDK version is 20.1.5948944)
If you have done all the steps before, you will see the following window popping up. Hit OK and you are all set.
B. This approach might look simple but yet it does the trick. Simply create a new Flutter project and get all you work (lib folder, assets, etc) to the new project.
Environment
OS : Big Sur 11.1
npm 7.24.0
node v14.15.5
react-native-cli: 2.0.1
react-native: 0.63.4
Command
react-native run-android
Error
*What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi
Fix
Checking Android SDK Tools, NDK (side-by-side):
In the android toolbar go to:
Tools >> SDK Manager
![Tools-SDK][1]
Then in the popup aside navigation go to:
Appearance & Behavior >> System Settings >> Android SDK

Click “SDK Tools”
Check the box next to show package details

Solution:
Downgrade
References
Idea for downgrade: Taba's solution
Here's what worked for me
I updated AGP to 4.1+ in my Android Project root build.gradle
dependencies {
classpath "com.android.tools.build:gradle:4.1.0"
...
AGP 4.1+ supports only gradle version gradle-6.5 above
so I updated the distributionUrl in gradle-wrapper.properties file located in gradle/wrapper folder
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
Get more info here
what worked for me was
I change my Gradle dependencies from 3.5.1 to 4.0.1
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
}
which is under build.gradle
The minimum Gradle support for Gradle dependencies(gradle:4.0.1) is gradle-6.1.1
if your gradle version for the project is below that you will have to change it by downloading a higher version or if you have it and you're using a wrapper, you will have to change the distribution to the one higher or same as the 6.1.1 version.
which is under >gradle >wrapple >gradle-wrapple.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
You might most likely need to add to your NDK
for Gradle-6.7 the supported NDK is NDK(side by side) version 21.0.6113669
which is under >tools >sdk manager(android SDK) >sdk tools >ndk side by side
click show package details click and download the appropriate one for you
I clean all SDK folders in c:\Users\User\AppData\Local\Android\Sdk\ndk\
Recent AppCenter android dependencies changes caused my android builds to fail with this error:
No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi
Our solution was to upgrade the gradle version from 3.5.4 to 4.0.1 in the root build.gradle file:
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
Additional answer for #gwang and #TillyJonesy:
When running Gradle command with --info(AGP 3.5.4 for me), you will see that when no NDK version was given, AGP will try to use the highest NDK version.
And from the docs of Android NDK guidance, AGP <= 3.5 has no default NDK version.
See: https://developer.android.com/studio/projects/install-ndk#default-ndk-per-agp
Solution for native android developers
Go to File->Settings->Appearance & Behaviour->System Settings->Android SDK-> then select SDK Tools and check 'Show Package Details' from bottom.
in Dropdown of NDK(Side by Side) ,check 22.1.7171670 and uncheck remaining then apply and click ok.

Unity - Failed to compile resources with the following parameters:

I'm working on adding Google Play Game Services to a Unity project.
Started getting these errors recently, however not sure if it is because of the Game Services, or could be I updated my machine.
The following in Console output:
Failed to compile resources with the following parameters:
-bootclasspath "/Users/alex/development/adt-bundle-mac-x86_64-20131030/sdk/platforms/android-21/android.jar"
-d "/Users/alex/Documents/development/unity/Maze/Maze/Temp/StagingArea/bin/classes"
-source 1.6 -target 1.6 -encoding UTF-8 "com/facebook/android/R.java" "com/google/android/gms/R.java"
"com/google/example/games/basegameutils/R.java"
"com/google/example/games/mainlibproj/R.java"
"com/mildspring/maze/R.java" warning:
java/lang/Object.class(java/lang:Object.class): major version 51 is
newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded. 1 warning
UnityEditor.HostView:OnGUI()
Error building Player: UnityException: Resource compilation failed!
Failed to recompile android resource files. See the Console for
details.
Got my answer, the issue was that "major version 51" is java 1.7, "version 50" is java 1.6. The solution was to install Java 1.7 and set path accordingly with the following command.
sudo ln -nsf /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
For me, changing the JDK path at Preferences => External Tools => JDK finally resolved this issue. Creating the symbolic link wasn't enough or possibly not even needed.
I would just re-install or update JDK , And its work
http://www.oracle.com/technetwork/java/javase/downloads/index.html

Android studio:import NDK project from eclipse

I exported project from Eclipse(windows) and imported it to android studio V 0.4.2(ubuntu).
The project include working NDK library.
I get this error when try to run my app:
Execution failed for task ':app:compileDebugNdk'.
NDK not configured
From others stackoverflow posts, I understand that it is an issue.
But get no workaround for this.
Should i proceed the development with eclipse for now, or is that the a lazy option ?
EDIT :
I run this command:
export NDK=~/Downloads/android-ndk-r9c
and then :
and then go to my app directory and run this:
ndk-build
And i get this:
yarinkos-u#yarinkosu-MSI-Notebook-EX600:~/AndroidStudioProjects/AndEngineEXperimental$ ndk-build
/home/yarinkos-u/Downloads/android-ndk-r9c/ndk-build: 1: /home/yarinkos-u/Downloads/android-ndk-r9c/ndk-build: dirname: not found
/home/yarinkos-u/Downloads/android-ndk-r9c/ndk-build: 132: /home/yarinkos-u/Downloads/android-ndk-r9c/ndk-build: uname: not found
ERROR: Unknown host operating system:
What i did wrong?
It seems that the script running,but i miss something there.
EDIT 2:
i mistakenly runing this also :
export PATH=~/Downloads/android-ndk-r9c
so i get the error above.
If i running onlt this :
export NDK=~/Downloads/android-ndk-r9c
I get ndk-build not found error.
NDK Support is introduced from Android Studio 0.4.1 only, so make sure you are running AS 0.4.1 or above.
Android gradle plugin must be 0.7.+ in build.gradle file and also new NDK integration requires NDK r9c .
Lines from Developer tools blog under Release 0.4.1
Supports importing NDK projects. If the imported project contains NDK
sources, these are imported into the jni/ source set of the project,
the module name is inferred from the Makefile and stored in the Gradle
file, and the ndk.dir property is defined in local.properties.
Check more about it here :
http://tools.android.com/recent
you need to download the NDK for your operatings system # https://developer.android.com/tools/sdk/ndk/index.html once it's downloaded, install it it'll extract the contents to the correct file system it needs to be in it'll take some time, also make sure you are running the latest android studio. it worked for me. good luck.