Bad class file magic or version - android

I already know that question has been already asked very often and answers, but no one of the answers i found fixed my problem.
It's the error:
Error:Gradle: Execution failed for task ':ffcommunity:preDexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\Android SDK\sdk\build-tools\20.0.0\dx.bat --dex --output D:\Users\ReVo\Documents\IntelliJ IDEA\FFCommunity\ffcommunity\build\intermediates\pre-dexed\debug\bananaquery-2ee85432877a057e7414910b8127805535139d5d.jar D:\Users\ReVo\Documents\IntelliJ IDEA\FFCommunity\ffcommunity\libs\bananaquery.jar
Error Code:
1
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:665)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
...while parsing com/comuf/revonline/bananaquery/BananaInsert.class
1 error; aborting
The error is bad class file magic (cafebabe) or version (0034.0000).
I builded and execute the application without problems many times in the same day but now this fails everytime with this message.
Project SDK is Android API 19 Platform and project level is 1.7.
CompileSDK is 19 and buildToolsVersion is '20.0.0'.
Compile options:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
and in dependencies i have:
compile files('libs/bananaquery.jar')
The library is build with SDK Android API 19 Platform with project level 1.7.
My .jar file is inside libs/ folder.
I use IntelliJ IDEA 14 Preview, it could be the reason? With IntellIJ IDEA 13 it remains stuck at "Gradle sync"
compile files could be useless since i have compile fileTree(dir: 'libs', include: ['*.jar']) too

my JAVA_HOME variable changed to Java 1.8 and I got this error message when compiling a pure java module as a dependency of my android project.
build.gradle of the java module
apply plugin: 'java'
Solution #1: Quick an dirty
I fixed it by setting my JAVA_HOME back to 1.7:
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
Solution #2: change compiler version:
change back to 1.7 for this specific module in its build.gradle
apply plugin: 'java'
sourceCompatibility = 1.7
targetCompatibility = 1.7

Ok, my bad.
In the Project SDK section, when you add an Android SDK you should provide the Java SDK and all my Android SDKs uses Java 8 as SDK so it create the class files with the wrong version even if the Project level is 1.7 (i don't know why, i supposed that everything was choosed by Project level).
Now i changed the SDK (the java version "1.x.0" part.)
and it seems to compile fine.
The reason that worked before today was because my SDK was 1.8 and not Android API x

In case people find #Marco Acierno's answer to be a bit unclear, the solution is to ensure you're building with Java 7 and not a higher version.
For Android Studio, change File -> Project Structure -> SDK Location -> JDK Location to jdk1.7.x. For the command line, ensure java -version outputs java version "1.7.x".

Setting JAVA_HOME back to 1.7 worked for me.

change all your module java version to java 1.7 in every build.grade file.
in plugin which is library and application
compileOptions{
sourceCompatibility=JavaVersion.VERSION_1_7
targetCompatibility=JavaVersion.VERSION_1_7
}
and in java
sourceCompatibility= 1.7
targetCompatibility= 1.7

This problem occurs when you use a .jar file that is not using any feature of Java 6 or higher but was built using Java 6 or higher.
If you built that .jar file then you don't need to change anything in Gradle or ProGuardor Compiler Version. The solution is very simple, just build that .jar file again but using Java 5 or less.
More details.

I had a similar issue, i solved it by upgrading my proguard.
get your proguard version by this command
java -jar ~/android-sdks/tools/proguard/lib/proguard.jar
get the latest progaurd.jar file from here (http://proguard.sourceforge.net)
replace the existing android-sdks/tools/proguard/lib/proguard.jar with new .jar file.
Hopefully this should help you.
If u using java 8 then you should upgrade to proguard 5.x coz proguard 4.x does not support java 8.

had a similar issue when i tried to add a self made library from netbeans to android studio. setting the source- and target compatibility in android studio and source/binary format in netbeans (both!) to java 1.7 solved the problem.
in android studio:
Project Structure -> Modules/App -> Propreties -> Source- and Target to 1.7
in netbeans:
File -> Project Properties -> Sources -> Source/Binary Format to 1.7
then clean and build your netbeans projekt and copy the .jar from "NBProj/dist" to "app/libs"

share the solution of the case if only Java8 installed, just set Java compiler level to 1.7 and then rebuild the project should be OK.

I got the error when using a third party library. In accordance with the above-mentioned question, it was necessary to replace the library according to the above stack trace message:
...
...while parsing com/comuf/revonline/bananaquery/BananaInsert.class
...
with the appropriate version.
Corresponding to the question, bananaquery.jar is to be replaced by the Java-compatible version.

Related

Error of react-native-os and gradle versions in react-native project

So I'm using https://www.npmjs.com/package/#walletconnect/react-native-dapp library. The steps is clear I installed npx rn-nodeify --install --hack to have all important libraries for supporting wallet connect. And here is my "postinstall": "./node_modules/.bin/rn-nodeify --install 'crypto,buffer,react-native-randombytes,stream,os' --hack, patch-package". And of course os added react-native-os lib on my package.json too.
Project works perfectly on IOS but I got error running on android. Here is the error
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Where:
Build file '/Users/name/Workspace/projectName/node_modules/react-native-os/android/build.gradle' line: 47
What went wrong:
A problem occurred evaluating project ':react-native-os'.
Could not find method compile() for arguments [com.facebook.react:react-native:+] on object of type org.gradle.ap
and here is the node_modules/react-native-os/android/build.gradle' line: 47 which I got error
46: dependencies {
47: compile 'com.facebook.react:react-native:+'
48: }
So I did a well research and find out that compile function has been deprecated since Gradle 4.10 (Aug 27, 2018), and were finally removed in Gradle 7.0 (Apr 9, 2021).
The aforementioned configurations should be replaced by implementation.
My project's gradle version is 7.2.1. And definitely I can't always go to react-native-os/android/build.gradle file and change the compile word to implementation!! And I can't downgrade my project's gradle version.
I tried to use patch-package lib which let me to modify files in node modules. But after that I see more deprecated stuff and errors. So what can I do?

cardslib error resource android:attr/foregroundInsidePadding is private while targeting SDK 26

Okay, I have created a completely new project in Android Studio 3.0. Gradle build works fine in this newly instantiated project, until I insert the following lines in my module's build.gradle
dependencies {
...
compile 'com.github.gabrielemariotti.cards:cardslib-core:2.1.0'
compile 'com.github.gabrielemariotti.cards:cardslib-cards:2.1.0'
compile 'com.github.gabrielemariotti.cards:cardslib-recyclerview:2.1.0'
}
Here is the error I get in the Build log
/home/sparker0i/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.0.1.aar/e06e09188fb79d4d895b39247477d1c1/res/values/values.xml
Error:(246, 5) resource android:attr/foregroundInsidePadding is private
When I double click on it, I get a values.xml file (merged one), where the pointer is at
<dimen name="abc_action_bar_content_inset_material">16dp</dimen>
My minimum SDK version is 16, target SDK is 26. I am using Android Studio 3.0 Beta 2, build tools version is 26.0.1. Gradle plugin 3.0.0-beta2.
I bet this is because of a slightly outdated Cardslib library. Is there no way to fix this? (Removing those lines from dependencies works fine)
Try disabling the AAPT2 by adding android.enableAapt2=false to your gradle.properties file.
Builds may fail while AAPT2 is enabled. Additionally, AAPT2 is
currently not compatible with Robelectric. If your build fails due to
an AAPT2 resource processing issue or you want to use Roboelectric,
you can disable AAPT2 by setting android.enableAapt2=false in your
gradle.properties file and restarting the Gradle daemon by running
./gradlew --stop from the command line.
Reference : here
I was using Android studio 3.0 beta 5 In which I disabled the AAPT2 and it resolved my error.
UPDATE: 28 March 2018
With Android Studio 3.1.1 this might not work. One of your library might be using android's private resource. You need to find the error causing library and replace android:attr/foregroundInsidePadding with foregroundInsidePadding and import it to your project.
Clone the library repo in your local.
Open repository in Android Studio find xml having
<attr name="android:foregroundInsidePadding" /> and replace it with
<attr name="foregroundInsidePadding" /> and Build.
Open your project and import that repository as dependency into your project.
Remove library compile statements from app level build.gradle.
Now you might be able to use AAPT2 so try changing android.enableAapt2=false to true in gradle.properties if present.
This is because you shouldn't use the 'android' namespace for this resource. To resolve this issue, replace android:foregroundInsidePadding with foregroundInsidePadding.
More info on the Android Studio AAPT2 migration guide.
I updated my dependencies from :
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:appcompat-v7:19.1.0'
to
compile 'com.android.support:support-v4:21.0.1'
compile 'com.android.support:appcompat-v7:21.0.1'
And it worked for me
Try this: Disable AAPT2 by adding android.enableAapt2=false in gradle-properties. Also ensure you have the compileSdkVersion and targetSdkVersion are the same version. Mine is 28 with android studio 3.2.1.
Rebuild your project it should work.

Android Studio App not opening on Physical Device [duplicate]

When I try to render a layout preview in Android Studio I get error:
Unsupported major.minor version 52.0
Check your JAVA_HOME to use jdk 1.8
Also check : the parameter in Android Studio in order to change at
File->Other Settings->Default Project Structure->SDKs
This is bug in Android Studio.
Usually you get error: Unsupported major.minor version 52.0
WORKAROUND: If you have installed Android N, change Android rendering version with older one and the problem will disappear.
SOLUTION: Install Android SDK Tools 25.1.3 (tools) or higher
I've all done, setting JAVA_HOME, JAVA8_HOME, ... and i had always the error.
For me the solution was to set the version 2.1.0 of gradle to work with Jdk 1.8.0_92 and android studio 2.11
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
//classpath 'com.android.tools.build:gradle:2.+'
}
For those of you, who are still facing this.
I got this problem after I upgraded to Android Studio to 2.1.2.
I was stuck at this problem for about an hour, I tried these solutions:
multidexEnabled true
increasing the memory for deamon thread
upgraded to Java 8
I double checked the gradle scripts and found this:
compileSdkVersion 23
buildToolsVersion "24.0.0"
changed to:
compileSdkVersion 23
buildToolsVersion "23.0.3"
I don't know how this caused the error, but this did the trick for me.
Please let me know how this worked if you know the answer.
Thanks
Unsupported major.minor version 52.0
When a higher JDK is used for compilation it creates class file with
higher version and when a lower JDK is used to run the program it
found that higher version of class file not supported at JVM level and
results in java.lang.UnsupportedClassVersionError.
How to fix
Increase the JAVA version you are using to run your program
You can follow some tricks
Call stable version classpath 'com.android.tools.build:gradle:2.1.0' // 2.3.0
Configuring Gradle
To enable the Java 8 language features and Jack for your project, enter the following in your module-level build.gradle file:
android {
...
defaultConfig {
...
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Courtesy goes to Java 8 Language Features
Just select "API 23: Android 6.0" from preview section .
If you're seeing this error and you just upgraded to Android Studio 2.2+ you need to update your JDK in "Project Structure" options.
On OSX, this is found under File > Project Structure > SDK. Or from the welcome screen in Configure > Project Defaults > Project Structure.
Select the Use the embedded JDK (recommended) option instead of using your own JDK.
Google's docs aren't yet updated to reflect this change. See: http://tools.android.com/tech-docs/configuration/osx-jdk
Im my case I had to change the dependencies of the build.gradle file to:
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
(originally was 2.2.2)
I guess this was generated by get several people working in the same project with different versions of gradle. So check your gradle version and edit this file properly.
Good vibes!
With the latest version, you are recommended to switch to the embedded JDK like in the image below, and this will solve your error
I also got the same error message of 'Unsupported major.minor version 52.0' when running ./gradlew makeJar to create a jar library by Android Studio 2.2.3.
After moving down the version of gradle plugin in build.gradle from 2.2.2 to 2.1.3, the error message disappeared and all worked well.
classpath 'com.android.tools.build:gradle:2.1.3'
I don't know how the higer version of gradle plugin caused the error, but this did the trick for me. please let me know how this worked if you know the answer, thanks
1、make sure Gradle Gradle JVM Version
2、make sure ProjectSettings SDKs Veriosn
For me, updating the Android Studio to the latest version solved the problem.
I tried to find solution to this problem.I tried most of the solutions mentioned in this thread. However, I am not very sure why this was occurring. Probably a bug in Android Studio. Anyhow, this is what solved the problem:
In Application level build.gradle,
removed:
classpath 'com.android.tools.build:gradle:2.2.0-beta1'
replaced with:
classpath 'com.android.tools.build:gradle:2.0.0'
This occur due to incompatible java version you are using in android studio and the java version that was used with your imported project.
Go to
File->Project structure->Change jdk 1.7 to jdk 1.8 .After that Go to File->click on Invalidate cache and Restart.
Hope this helps..
And change the dependency classpath in gradle file
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Changing to Java SDK to Java 8 worked for me.
Android Studio settings: File -> other settings ->Default project structure -> JDK location -> jdk1.8.0_71.jdk/Contents/Home
Make sure to do a clean build after changing a version of Java. As it turns out Android Studio does some work when you switch the JDK but doesn't clean the workspace and creates confusion ¯\_(ツ)_/¯
This error "Unsupported major.minor version 52.0" refers to the java compiler, although the string "major.minor" looks very similar to the Android SDK version format.
On Windows platform, asides updating jdk to 1.8, make sure JAVA_HOME point to where your jdk 1.8 is installed (i.e. C:\Program Files\Java\jdk1.8.0_91).
I had to update Java version to JDK 8 at Jenkins->Manage Jenkins->Global Tool Configuration->JDK.
Changing to Java SDK to Java 8 and worked for me
Android Studio settings:
File > other settings > Default project structure > JDK location > jdk1.8.0_71.jdk/Contents/Home
Android Studio behaves weird in the case. Even though you set the JDK version in File -> Project Structure -> SDK Location, Android Studio only uses this for compiling the files. When it runs these files it, for some reason, looks at the PATH variable to find where java is installed.
If you have an older version of java installed on your system, then your PATH variable will be pointing to that older version of java.
So you have to set your PATH to point to the same version of java that have set in your Android studio project settings.
In your ~/.bashrc or corresponding profile file add this:
export PATH="/Applications/studio.app/Contents/jre/jdk/Contents/Home/bin:$PATH"
In my case my project was configured to use java 1.8, but my system wide installation of java was java 1.7. This was causing the issue.
For my case, my original Android SDK Build-tools version is 24 and Andoid SDK Tools version is 25.1.7. I install Android SDK Build-tools version 23.0.3 by Andoird SDK manager.
Modify these 2 lines to:
buildToolsVersion "23.0.3"
compileSdkVersion 24
Then it works!
Download latest JDK and install. Go toVS2015 Tools > Options > Xamarin and change the java to the latest JDK location
Also, if issue appears while executing ./gradlew command, setting java home in gradle.properties file, solves this issue:
org.gradle.java.home=/usr/java/jdk1.8.0_45/
For me the problem was that the version of gradle in build.gradle was not same as the actual gradle version I had installed.
dependencies {
classpath('com.android.tools.build:grade:2.2.0') {
force = true}
Check your installed gradle versions at /Contents/gradle/m2repository/com/android/tools/build/gradle/
and change the above build.gradle file with
classpath('com.android.tools.build:grade:1.5.1') or <>
I had got the same error and I had JDK 8 set as JAVA_HOME. It turned out that I had Android SDK Build-tools rev 25.0.2 installed. I removed this and installed 23.0.2 instead and it worked for me.
change to
buildToolsVersion "23.0.2" in app gradle file.

Unsupported major.minor version 52.0 when rendering in Android Studio

When I try to render a layout preview in Android Studio I get error:
Unsupported major.minor version 52.0
Check your JAVA_HOME to use jdk 1.8
Also check : the parameter in Android Studio in order to change at
File->Other Settings->Default Project Structure->SDKs
This is bug in Android Studio.
Usually you get error: Unsupported major.minor version 52.0
WORKAROUND: If you have installed Android N, change Android rendering version with older one and the problem will disappear.
SOLUTION: Install Android SDK Tools 25.1.3 (tools) or higher
I've all done, setting JAVA_HOME, JAVA8_HOME, ... and i had always the error.
For me the solution was to set the version 2.1.0 of gradle to work with Jdk 1.8.0_92 and android studio 2.11
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
//classpath 'com.android.tools.build:gradle:2.+'
}
For those of you, who are still facing this.
I got this problem after I upgraded to Android Studio to 2.1.2.
I was stuck at this problem for about an hour, I tried these solutions:
multidexEnabled true
increasing the memory for deamon thread
upgraded to Java 8
I double checked the gradle scripts and found this:
compileSdkVersion 23
buildToolsVersion "24.0.0"
changed to:
compileSdkVersion 23
buildToolsVersion "23.0.3"
I don't know how this caused the error, but this did the trick for me.
Please let me know how this worked if you know the answer.
Thanks
Unsupported major.minor version 52.0
When a higher JDK is used for compilation it creates class file with
higher version and when a lower JDK is used to run the program it
found that higher version of class file not supported at JVM level and
results in java.lang.UnsupportedClassVersionError.
How to fix
Increase the JAVA version you are using to run your program
You can follow some tricks
Call stable version classpath 'com.android.tools.build:gradle:2.1.0' // 2.3.0
Configuring Gradle
To enable the Java 8 language features and Jack for your project, enter the following in your module-level build.gradle file:
android {
...
defaultConfig {
...
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Courtesy goes to Java 8 Language Features
Just select "API 23: Android 6.0" from preview section .
If you're seeing this error and you just upgraded to Android Studio 2.2+ you need to update your JDK in "Project Structure" options.
On OSX, this is found under File > Project Structure > SDK. Or from the welcome screen in Configure > Project Defaults > Project Structure.
Select the Use the embedded JDK (recommended) option instead of using your own JDK.
Google's docs aren't yet updated to reflect this change. See: http://tools.android.com/tech-docs/configuration/osx-jdk
Im my case I had to change the dependencies of the build.gradle file to:
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
(originally was 2.2.2)
I guess this was generated by get several people working in the same project with different versions of gradle. So check your gradle version and edit this file properly.
Good vibes!
With the latest version, you are recommended to switch to the embedded JDK like in the image below, and this will solve your error
I also got the same error message of 'Unsupported major.minor version 52.0' when running ./gradlew makeJar to create a jar library by Android Studio 2.2.3.
After moving down the version of gradle plugin in build.gradle from 2.2.2 to 2.1.3, the error message disappeared and all worked well.
classpath 'com.android.tools.build:gradle:2.1.3'
I don't know how the higer version of gradle plugin caused the error, but this did the trick for me. please let me know how this worked if you know the answer, thanks
1、make sure Gradle Gradle JVM Version
2、make sure ProjectSettings SDKs Veriosn
For me, updating the Android Studio to the latest version solved the problem.
I tried to find solution to this problem.I tried most of the solutions mentioned in this thread. However, I am not very sure why this was occurring. Probably a bug in Android Studio. Anyhow, this is what solved the problem:
In Application level build.gradle,
removed:
classpath 'com.android.tools.build:gradle:2.2.0-beta1'
replaced with:
classpath 'com.android.tools.build:gradle:2.0.0'
This occur due to incompatible java version you are using in android studio and the java version that was used with your imported project.
Go to
File->Project structure->Change jdk 1.7 to jdk 1.8 .After that Go to File->click on Invalidate cache and Restart.
Hope this helps..
And change the dependency classpath in gradle file
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Changing to Java SDK to Java 8 worked for me.
Android Studio settings: File -> other settings ->Default project structure -> JDK location -> jdk1.8.0_71.jdk/Contents/Home
Make sure to do a clean build after changing a version of Java. As it turns out Android Studio does some work when you switch the JDK but doesn't clean the workspace and creates confusion ¯\_(ツ)_/¯
This error "Unsupported major.minor version 52.0" refers to the java compiler, although the string "major.minor" looks very similar to the Android SDK version format.
On Windows platform, asides updating jdk to 1.8, make sure JAVA_HOME point to where your jdk 1.8 is installed (i.e. C:\Program Files\Java\jdk1.8.0_91).
I had to update Java version to JDK 8 at Jenkins->Manage Jenkins->Global Tool Configuration->JDK.
Changing to Java SDK to Java 8 and worked for me
Android Studio settings:
File > other settings > Default project structure > JDK location > jdk1.8.0_71.jdk/Contents/Home
Android Studio behaves weird in the case. Even though you set the JDK version in File -> Project Structure -> SDK Location, Android Studio only uses this for compiling the files. When it runs these files it, for some reason, looks at the PATH variable to find where java is installed.
If you have an older version of java installed on your system, then your PATH variable will be pointing to that older version of java.
So you have to set your PATH to point to the same version of java that have set in your Android studio project settings.
In your ~/.bashrc or corresponding profile file add this:
export PATH="/Applications/studio.app/Contents/jre/jdk/Contents/Home/bin:$PATH"
In my case my project was configured to use java 1.8, but my system wide installation of java was java 1.7. This was causing the issue.
For my case, my original Android SDK Build-tools version is 24 and Andoid SDK Tools version is 25.1.7. I install Android SDK Build-tools version 23.0.3 by Andoird SDK manager.
Modify these 2 lines to:
buildToolsVersion "23.0.3"
compileSdkVersion 24
Then it works!
Download latest JDK and install. Go toVS2015 Tools > Options > Xamarin and change the java to the latest JDK location
Also, if issue appears while executing ./gradlew command, setting java home in gradle.properties file, solves this issue:
org.gradle.java.home=/usr/java/jdk1.8.0_45/
For me the problem was that the version of gradle in build.gradle was not same as the actual gradle version I had installed.
dependencies {
classpath('com.android.tools.build:grade:2.2.0') {
force = true}
Check your installed gradle versions at /Contents/gradle/m2repository/com/android/tools/build/gradle/
and change the above build.gradle file with
classpath('com.android.tools.build:grade:1.5.1') or <>
I had got the same error and I had JDK 8 set as JAVA_HOME. It turned out that I had Android SDK Build-tools rev 25.0.2 installed. I removed this and installed 23.0.2 instead and it worked for me.
change to
buildToolsVersion "23.0.2" in app gradle file.

Gradle build failure (incompatible magic value)

It seems like without any reason the Gradle refuses to build the project in Android Studio. I haven't change anything in the configurations and I can't find any reason of this error. The output is the following
Error:A problem occurred configuring project ':app'.
java.lang.ClassFormatError: Incompatible magic value 931269604 in class file build_f63dreec96sk8elmstb53lfie
No any Android library is recognized. So maybe there might be some problems with sdk but I have checked the dependencies and the path was set correctly. Here is a screenshot of my build.gradle.
I have already tried
1) rebuilding and cleaning the project.
2) File -> invalidate caches and restart
Are there any other ideas about fixing this problem. Thanks in advance
For anyone who finds this in future.
I had this issue and resolved it by typing:
gradlew --recompile-scripts
The problem was that Gradle had a precompiled build script from a previous version of Java. The .class file for that script was invalid, hence the error. You need to recompile that script.
Basically, you have a project or module that was compiled using a source JRE version less than a dependency.
Try the following
sourceCompatibility = 1.6
targetCompatibility = 1.6
More information is here
Gradle sourceCompatibility has no effect to subprojects

Categories

Resources