Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi! I created new react native project and I can't build on android #26625

Closed
lichcse opened this issue Sep 28, 2019 · 22 comments
Closed

Hi! I created new react native project and I can't build on android #26625

lichcse opened this issue Sep 28, 2019 · 22 comments
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@lichcse
Copy link

lichcse commented Sep 28, 2019

React Native version:
"dependencies": { "react": "16.9.0", "react-native": "0.61.1" }

MacOS: 10.14.6
Java JDK: 13

Action:

  1. react-native init AwesomeProject
  2. cd AwesomeProject
  3. react-native run-android

Error:
FAILURE: Build failed with an exception.

  • Where:
    Settings file '/Users/lichtv/workspace/react/src/FristApp/android/settings.gradle'

  • What went wrong:
    Could not compile settings file '/Users/lichtv/workspace/react/src/FristApp/android/settings.gradle'.

startup failed:
General error during semantic analysis: Unsupported class file major version 57

java.lang.IllegalArgumentException: Unsupported class file major version 57
at groovyjarjarasm.asm.ClassReader.(ClassReader.java:184)
at groovyjarjarasm.asm.ClassReader.(ClassReader.java:166)
at groovyjarjarasm.asm.ClassReader.(ClassReader.java:152)
at groovyjarjarasm.asm.ClassReader.(ClassReader.java:273)
at org.codehaus.groovy.ast.decompiled.AsmDecompiler.parseClass(AsmDecompiler.java:81)
at org.codehaus.groovy.control.ClassNodeResolver.findDecompiled(ClassNodeResolver.java:254)
at org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:192)
................ ETC .........................
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.base/java.lang.Thread.run(Thread.java:830)

1 error

  • 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 432ms

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

  • Where:
    Settings file '/Users/lichtv/workspace/react/src/FristApp/android/settings.gradle'
    .......

HELP ME PLEASE

@lichcse lichcse added the Bug label Sep 28, 2019
@react-native-bot react-native-bot added the Platform: Android Android applications. label Sep 28, 2019
@dulmandakh
Copy link
Contributor

could you please share what's in the Users/lichtv/workspace/react/src/FristApp/android/settings.gradle file?

@lichcse
Copy link
Author

lichcse commented Sep 28, 2019

Sure bro,
rootProject.name = 'AwesomeProject'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'

@cjtaylor1990
Copy link

cjtaylor1990 commented Sep 28, 2019

I'm having the same issue I believe.

[Update]: Solved my issue. I initiated the app using version 0.57 rather than 0.61, and that got me over the gradle issue. I then ran it, and got a new error about my JDK version. I switch to OpenJDK8 rather than JDK 13 and that seemed to work. Seems to work.

@LMestre14
Copy link

LMestre14 commented Sep 29, 2019

@lichcse

In your android/build.gradle, do you have maven { url "https://jitpack.io" }?

If so change it to maven { url "https://www.jitpack.io" } an try running the project again.

@lichcse
Copy link
Author

lichcse commented Sep 29, 2019

Hi @LMestre14
I did your recommend and I got same error.
Hi @cjtaylor1990
I switched to JDK 1.8 and it worked. (keep react-native 0.61.1)
Hi @dulmandakh
I think this is a bug with java version 13.

Thanks to all bro

@cjtaylor1990
Copy link

Hi @LMestre14
I did your recommend and I got same error.
Hi @cjtaylor1990
I switched to JDK 1.8 and it worked. (keep react-native 0.61.1)
Hi @dulmandakh
I think this is a bug with java version 13.

Thanks to all bro

No problem, @lichcse Took me all afternoon of messing around to finally figure that out. Yeah, since JDK 13 is really new, it wouldn't surprise me if something broke. Yeah, once I switched to the older JDK, 0.61 worked fine. Glad I could help! =)

@razr130
Copy link

razr130 commented Oct 2, 2019

Hello @cjtaylor1990 could you tell me how to switch from java 13 to openJDK8 in mac? I did some uninstall and reinstall and not seems to succesed on switching the version. Thanks

@lichcse
Copy link
Author

lichcse commented Oct 2, 2019

@razr130
You can download JDK 1.8 at https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Next step switch version: https://stackoverflow.com/questions/21964709/how-to-set-or-change-the-default-java-jdk-version-on-os-x

Good luck to you

@akashmohan
Copy link

Hello @cjtaylor1990 could you tell me how to switch from java 13 to openJDK8 in mac? I did some uninstall and reinstall and not seems to succesed on switching the version. Thanks

I don't know in the case of mac. i just changed the JAVA_HOME path variable to old JDK installation and it worked

@ameyackherodkar
Copy link

Hi @LMestre14
I did your recommend and I got same error.
Hi @cjtaylor1990
I switched to JDK 1.8 and it worked. (keep react-native 0.61.1)
Hi @dulmandakh
I think this is a bug with java version 13.

Thanks to all bro

This Solution Actually works (Y) , JDK13 is buggy

@paldepind
Copy link
Contributor

This issue is regarding OSX, but I ran into the same problem using Arch Linux. In case anyone else does as well here's is how I fixed it:

pacman -S jdk11-openjdk
archlinux-java set java-11-openjdk

This will downgrade from JDK13 to JDK11.

@dantasfiles
Copy link

dantasfiles commented Nov 15, 2019

Same issue @lichcse had on MacOS, I had on Windows.
React Native v.0.61.4, JDK v.13.0.1.
Downgrading JDK to 11 removed the issue.

@nosduco
Copy link

nosduco commented Nov 17, 2019

@paldepind You don't see a fix specifically for Arch Linux very frequently. Thanks man :)

@MaffooBristol
Copy link

Go to android/gradle/wrapper/gradle-wrapper.properties

Change the following line:

- distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
+ distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip

That's what worked for me with the latest versions of everything on MacOS

@zzantares
Copy link

For others reading, it's not that JDK 13 is buggy, it's that the packaged version of gradle doesn't support it, you either have to downgrade your JDK version, or as @MaffooBristol suggested instruct the build to use a newer version of gradle that does support Java 13.

@slhck
Copy link

slhck commented Jan 9, 2020

Are there any downsides to manually changing this version? After all, it's a major version change that RN itself would probably make itself in an upcoming release. What if there are conflicts on a future RN upgrade?

@LordDraagonLive
Copy link

Does JDK 12 works?

@vicary
Copy link
Contributor

vicary commented Jan 28, 2020

If you have Android Studio installed, JDK is already bundled inside the app. You don't have to install it separately.

Simply set these two path when compiling should work,

  1. /Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
  2. ~/Library/Android/sdk

@geiz
Copy link

geiz commented Mar 5, 2020

Go to android/gradle/wrapper/gradle-wrapper.properties

Change the following line:

- distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
+ distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip

That's what worked for me with the latest versions of everything on MacOS

I was getting react-native version mismatch 60.5/61.5 after that change at first.
After reinstalling java it seemed to have worked.
brew install homebrew/cask/java

@meetparikh112
Copy link

I just emptied the C:\Users[USER].gradle\wrapper\dists\gradle-6.0.1-all folder and rebuild it. It worked for me ....

@MahmudHasanMenon
Copy link

@MaffooBristol
Thanks man. Your solution save my time. It worked for me

@rajat-madaan
Copy link

If the react-native version is 0.64.0 then the distributionUrl should be https://services.gradle.org/distributions/gradle-6.7-all.zip

@facebook facebook locked as resolved and limited conversation to collaborators Oct 3, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests