尝试在Jenkins中使用ant构建一个android项目,但是我得到了一个例外。
我可以在控制台中使用“sudo -u jenkins ant debug”重现此错误。
/opt/android-sdk-mac_x86/tools/ant/build.xml:539: Unable to resolve project target 'android-17'
at com.android.ant.GetTargetTask.execute(GetTargetTask.java:160)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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 org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:809)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
显然有一个人认为原因是它无法找到'android-17'的sdk,但当我和我的普通用户运行相同的命令时(是的,我在我的开发机器上运行jenkins)现在确保它有效)它编译得很好。
Jenkins构建的完整日志:
Buildfile: /Users/Shared/Jenkins/Home/jobs/test1/workspace/build.xml
-check-env:
[checkenv] Android SDK Tools Revision 21
[checkenv] Installed at /opt/android-sdk-mac_x86
-setup:
[echo] Project Name: <ProjectName>
[gettype] Project Type: Application
-pre-clean:
clean:
[delete] Deleting directory /Users/Shared/Jenkins/Home/jobs/test1/workspace/bin
[delete] Deleting directory /Users/Shared/Jenkins/Home/jobs/test1/workspace/gen
[getlibpath] Library dependencies:
[getlibpath] No Libraries
[subant] No sub-builds to iterate on
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 21
[checkenv] Installed at /opt/android-sdk-mac_x86
-setup:
[echo] Project Name: <ProjectName>
[gettype] Project Type: Application
-set-debug-mode:
-debug-obfuscation-check:
-build-setup:
[echo] Resolving Build Target for <ProjectName>...
BUILD FAILED
/opt/android-sdk-mac_x86/tools/ant/build.xml:5309 Unable to resolve project target 'android-17'
Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
答案 0 :(得分:4)
哦,我终于明白了。
我在ANDROID_HOME / platforms
上拥有错误的权限答案 1 :(得分:0)
我刚遇到同样的问题。但我想通了,因为我从android-15文件夹中移除了build.prop,framework.aidl,sdk.properties(我的项目依赖它。),还原这些文件解决了我的问题。
答案 2 :(得分:0)
转到您的ANDROID_HOME目录并为您尝试使用的用户设置读写权限。 ieAndroid sdk目录。 (在Jenkins案例中,您需要为Jenkins用户提供读/写权限。如果您不确定该用户,则为每个人设置读/写权限) 例如: 在我的情况下,ANDROID_HOME = users / localUser / android_sdk_macosx 1)转到android_sdk_macosx文件夹并为此子文件夹和子文件夹设置读/写权限。或者你也可以为每个人设置它。 2)转到jenkins并尝试再次构建。它应该工作。