我想知道是否有人可以帮助解决这个问题。清理和构建最简单的项目时会发生错误。(见下文)
导致错误的步骤:
作为一名新员工,因此是不超过 4 个月的机器上的新用户,我首先打开 NetBeans 8.2 - 一周前为我安装了 NetBeans 和 Android Studio(用于 sdk)。
但是没有安装Android插件,所以我实现了nbandroid更新中心来安装插件。然后,我将位于 users\user.user1\AppData\local\android 文件夹中的 sdk 连接到 NetBeans。
为了运行某个项目的正确 Android 版本(4.2.2),我首先在 Android Studio/SDK Manager 中安装了版本 4 及更高版本,然后在 NetBeans 中选择了 4.2.2。
在 NetBeans 中打开本地版本之前,我继续将一个 android 项目从共享文件服务器复制到我的本地计算机。
执行清理和构建后出现以下错误(您可能会注意到存在与上述不同的文件夹结构。这是由于测试不同的配置以找到可能的解决方案):
Current build type is different than previous build: forced apkbuilder run.
Creating Test-debug-unaligned.apk and signing it with a debug key...
C:\AndroidSDK\tools\ant\build.xml:958: The following error occurred while executing this line:
C:\AndroidSDK\tools\ant\build.xml:969: The following error occurred while executing this line:
C:\AndroidSDK\tools\ant\build.xml:312:
java.lang.InternalError: Could not obtain X500Principal access
at sun.security.x509.X500Name.<clinit>(X500Name.java:1399)
at com.android.sdklib.internal.build.SignedJarBuilder.writeSignatureBlock(SignedJarBuilder.java:384)
at com.android.sdklib.internal.build.SignedJarBuilder.close(SignedJarBuilder.java:273)
at com.android.sdklib.build.ApkBuilder.sealApk(ApkBuilder.java:795)
at com.android.ant.ApkBuilderTask.execute(ApkBuilderTask.java:371)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor147.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor147.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor147.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at com.android.ant.IfElseTask.execute(IfElseTask.java:124)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor147.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at com.android.ant.IfElseTask.execute(IfElseTask.java:124)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor147.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor147.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor147.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:286)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:555)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
Caused by: java.security.PrivilegedActionException: java.lang.NoSuchMethodException: javax.security.auth.x500.X500Principal.<init>(sun.security.x509.X500Name)
at java.security.AccessController.doPrivileged(Native Method)
at sun.security.x509.X500Name.<clinit>(X500Name.java:1392)
... 63 more
Caused by: java.lang.NoSuchMethodException: javax.security.auth.x500.X500Principal.<init>(sun.security.x509.X500Name)
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.getDeclaredConstructor(Class.java:2178)
at sun.security.x509.X500Name$1.run(X500Name.java:1384)
at sun.security.x509.X500Name$1.run(X500Name.java:1380)
这真的很奇怪,因为我的同事在他的 PC 上编译没有问题(几乎相同的 PC 除了使用 NetBeans 8.1 和 Jdk8u91 而不是我最新的 java)
已咨询的解决方案:
- 更改 Android SDK、JDK 和所有相关应用程序的位置,
- ANT_HOME、JAVA_HOME 和 ANDROID_HOME 等环境变量的插入,
安装所有插件和安卓版本,
将环境变量路径插入到 Jdk,
在android studio中单独安装4.2.2版本的android,
以 PC 管理员身份彻底卸载并重新安装 NetBeans、Android Studio、JDK、Android SDK,
使用我的同事作为用户,
清理和构建一个简单的启动项目,
设置与我同事相同的 NetBeans 输入,
探索谷歌的深度
我已经检查了权限并稍微了解了 Java 主体和工具,但不是 100% 确定我在做什么。
以为我会在尝试其他任何事情之前先咨询堆栈。任何帮助表示赞赏。