转自:https://blog.csdn.net/liaosongmao1/article/details/124844528
1、make idegen
build completed successfully (32 seconds)
2、执行 development/tools/idegen/idegen.sh脚本
test@test-Lenovo:~/aosp$ development/tools/idegen/idegen.sh
find: 'out/target/product/emulator_x86_64/root/d': Permission denied
这里大家看到这里Permission denied很多同学可能就立即停止了然后用sudo命令:
sudo development/tools/idegen/idegen.sh
结果报错如下:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread “main” java.lang.UnsupportedClassVersionError: Main has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader1. r u n ( U R L C l a s s L o a d e r . j a v a : 363 ) a t j a v a . s e c u r i t y . A c c e s s C o n t r o l l e r . d o P r i v i l e g e d ( N a t i v e M e t h o d ) a t j a v a . n e t . U R L C l a s s L o a d e r . f i n d C l a s s ( U R L C l a s s L o a d e r . j a v a : 362 ) a t j a v a . l a n g . C l a s s L o a d e r . l o a d C l a s s ( C l a s s L o a d e r . j a v a : 418 ) a t s u n . m i s c . L a u n c h e r 1.run(URLClassLoader.java:363) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:362) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher1.run(URLClassLoader.java:363)atjava.security.AccessController.doPrivileged(NativeMethod)atjava.net.URLClassLoader.findClass(URLClassLoader.java:362)atjava.lang.ClassLoader.loadClass(ClassLoader.java:418)atsun.misc.LauncherAppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)
大概看者报错意思就是idegen.jar的编译java版本是 version 53.0即java 9
但是执行时候是 versions up to 52.0即java8 这个到底为啥?
我们看看当前java版本是不是java8
test@test-Lenovo:~/aosp$ java -version
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment Android_PDK (build 11.0.4+0-6508549)
OpenJDK 64-Bit Server VM Android_PDK (build 11.0.4+0-6508549, mixed mode)
这里明明展示是11啊,完全可以啊,为啥呢?
这里我们想想,我们因为是以sudo来执行的,所以是不是sudo这个用户导致问题:
test@test-Lenovo:~/aosp$ sudo java -version
[sudo] password for test:
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-8u312-b07-0ubuntu1~20.04-b07)
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)
哦哦这里一看果然是这样
那么解决办法目前就采用
直接执行 . development/tools/idegen/idegen.sh (注意多了.空格哦)忽略Permission denied 其实也是可以正常生成对应.iml 和 ipr文件
test@test-Lenovo:~/aosp$ . development/tools/idegen/idegen.sh
find: 'out/target/product/emulator_x86_64/root/d': Permission denied
Read excludes: 16ms
Traversed tree: 120376ms
标签:java,URLClassLoader,ClassLoader,idegen,version,报错,test,android From: https://www.cnblogs.com/onelikeone/p/16612515.html