[英]Error with react-native run-android after upgrade to react-native version 0.60.4
I am upgrading react-native from 0.59.5 to 0.60.4 with my existing application.我正在使用我现有的应用程序将 react-native 从 0.59.5 升级到 0.60.4。 But facing a problem as below
但面临如下问题
* Where:
Build file '/home/bingl/Projects/blackstar/frontend/android/app/build.gradle'
* What went wrong:
Could not compile build file '/home/bingl/Projects/blackstar/frontend/android/app/build.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.<init>(ClassReader.java:184)
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:166)
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:152)
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:273)
at org.codehaus.groovy.ast.decompiled.AsmDecompiler.parseClass(AsmDecompiler.java:81)
at org.codehaus.groovy.control.ClassNodeResolver.findDecompiled(ClassNodeReso
And my build.gradle is我的 build.gradle 是
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.frontend"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
I have absolutely no clue what this error is about and could not find much helpful articles.我完全不知道这个错误是关于什么的,也找不到太多有用的文章。 Please help me out.
请帮帮我。
For those who are here for java.lang.IllegalArgumentException: Unsupported class file major version 60
对于那些在这里为
java.lang.IllegalArgumentException: Unsupported class file major version 60
的人
One of the reason for the same is:原因之一是:
Java version 16 installed which is not yet supported by react-native.已安装 Java 版本 16,但 react-native 尚不支持。
So For MacOS,所以对于 MacOS,
cd /Library/Java/JavaVirtualMachines
ls
Check the available JDKs检查可用的 JDK
Remove the jdk-16 if present using this, sudo rm -rf jdk-16.jdk/
删除 jdk-16(如果存在),使用
sudo rm -rf jdk-16.jdk/
Basically, you can remove JDKs other than adoptopenjdk-8.jdk
which will be present if you followed React-Native Env Setup .基本上,您可以删除除
adoptopenjdk-8.jdk
之外的 JDK,如果您遵循React-Native Env Setup将会出现这些 JDK。
在这个文件中android/gradle/wrapper/gradle-wrapper.properties在这个distributionUrl=https://services.gradle.org/distributions/gradle-6.0-all.zip上更改distributionUrl
Looks like Gradle is currently erroring on builds using openJDK-13.看起来 Gradle 目前在使用 openJDK-13 构建时出错。
Here's a Github issue thread.这是一个Github 问题线程。
Check the version of Java and JDK versions on your system by running the following command on in your terminal:通过在终端中运行以下命令来检查系统上的 Java 和 JDK 版本:
file /etc/alternatives/java /etc/alternatives/javac
OR或者
file `which java javac`
This will list the current installations on your system.这将列出您系统上的当前安装。 If you see
openjdk-13
anywhere, you'll have to downgrade to openjdk-8
.如果您在任何地方看到
openjdk-13
,则必须降级到openjdk-8
。
Also, you can use this super lightweight utility jEnv to manage multiple versions of Java on your machine.此外,您可以使用这个超级轻量级的实用程序jEnv来管理您机器上的多个 Java 版本。 I've used it for many years with good results.
我已经使用了很多年,效果很好。
$ jenv add /usr/lib/jvm/java-8-openjdk-amd64/
openjdk64-1.8.0.292 added
1.8.0.292 added
1.8 added
$ jenv add /usr/lib/jvm/java-16-openjdk-amd64/
openjdk64-16.0.1 added
16.0.1 added
16.0 added
16 added
Then place a file at android/.java-version
with the contents:然后在
android/.java-version
放置一个文件,内容如下:
1.8
Answer : .答案: 。
Activity.main
活动主
Toast.makeText(this, "Your message, Toast.LENGTH_SHORT).show();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.