2

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

3 回答 3

4

哦,我终于想通了。

我在 ANDROID_HOME/platforms 上的权限错误

于 2012-11-29T13:48:59.260 回答
0

转到您的 ANDROID_HOME 目录并为您尝试使用的用户设置读写权限。即Android sdk 目录。(在 Jenkins 情况下,您需要向 Jenkins 用户授予读/写权限。如果您不确定用户,则为每个人设置读/写权限)例如:在我的情况下 ANDROID_HOME= users/localUser/android_sdk_macosx 1)转到 android_sdk_macosx文件夹并为此文件夹和子文件夹设置读/写权限。或者你也可以为每个人设置它。2)转到詹金斯并尝试再次构建。它应该工作。

于 2014-06-30T14:51:07.047 回答
0

我刚遇到你同样的问题。但我发现因为我从 android-15 文件夹中删除了 build.prop,framework.aidl,sdk.properties(我的项目依赖于它。),恢复这些文件解决了我的问题。

于 2013-03-31T05:48:53.073 回答