我正在尝试设置一个处理Android的开发环境。
我按照SDK安装和处理的所有说明进行操作,但我仍然无法编译内置示例。
在Linux中我得到:
BUILD FAILED
/home/poko/android-studio/sdk/tools/ant/build.xml:962: The following error occurred while executing this line:
/home/poko/android-studio/sdk/tools/ant/build.xml:973: The following error occurred while executing this line:
/home/poko/android-studio/sdk/tools/ant/build.xml:313: com.android.sdklib.build.ApkCreationException: Failed to create key: Cannot run program "/home/poko/Downloads/software/processing-2.1/java/bin/keytool": error=2, No such file or directory
JAVA_HOME is set to: /home/poko/Downloads/software/processing-2.1/java
Update it if necessary, or manually execute the following command:
/home/poko/Downloads/software/processing-2.1/java/bin/keytool -genkey -alias AndroidDebugKey -keyalg RSA -dname "CN=Android Debug,O=Android,C=US" -validity 10950 -keypass android -keystore /home/poko/.android/debug.keystore -storepass android
at com.android.sdklib.build.ApkBuilder.getDebugKey(ApkBuilder.java:300)
at com.android.sdklib.build.ApkBuilder.<init>(ApkBuilder.java:392)
at com.android.ant.ApkBuilderTask.execute(ApkBuilderTask.java:334)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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:291)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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:398)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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:291)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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:291)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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:291)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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:398)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at processing.mode.android.AndroidBuild.antBuild(AndroidBuild.java:415)
at processing.mode.android.AndroidBuild.build(AndroidBuild.java:73)
at processing.mode.android.AndroidMode.handleRunDevice(AndroidMode.java:220)
at processing.mode.android.AndroidEditor$14.run(AndroidEditor.java:310)
Total time: 14 seconds
注意两件事:JAVA_HOME设置为我的linux盒子上的jdk目录。但处理说JAVA_HOME设置为:/home/poko/Downloads/software/processing-2.1/java,这是自己的处理java发行版。 第二件事是在处理自己的java分发时不存在keytool命令。
提前致谢。
答案 0 :(得分:1)
我遇到了同样的问题。
解决方法是手动执行keytool命令。因为它只需要完成一次。请注意输出告诉你:
, or manually execute the following command:
/home/poko/Downloads/software/processing-2.1/java/bin/keytool -genkey -alias AndroidDebugKey -keyalg RSA -dname "CN=Android Debug,O=Android,C=US" -validity 10950 -keypass android -keystore /home/poko/.android/debug.keystore -storepass android
您只需将路径更改为正确的java路径即可 从:
/home/poko/Downloads/software/processing-2.1/java
To(如果在系统中正确设置,则使用JAVA_HOME)
$JAVA_HOME/bin/keytool -genkey -alias AndroidDebugKey -keyalg RSA -dname "CN=Android Debug,O=Android,C=US" -validity 10950 -keypass android -keystore /home/poko/.android/debug.keystore -storepass android
或者只用正确的java路径替换$ JAVA_HOME。在我的例子中是/ usr / lib / jvm / default-java,我使用的是基于Ubuntu 12.04.3 LTS的KXStudio。
不知道如何以ATM方式更清洁。如果我能弄明白的话会告诉你的。