试图在 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