[英]Android build with ant in Jenkins: unable to resolve target
Trying to build an android-project with ant in Jenkins, but I get an exception. 试图在詹金斯(Jenkins)中用ant构建一个android-project,但是我遇到了一个例外。
I can reproduce this error with "sudo -u jenkins ant debug" in console. 我可以在控制台中使用“ 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)
One is obviously led to believe that the cause of this is that it can't find the sdk for 'android-17', but when I run the same command with my regular user (yes I run jenkins on my dev machine right now to make sure it works) it compiles fine. 显然有人认为这是因为它找不到“ android-17”的sdk,但是当我用普通用户运行相同的命令时(是的,我现在在开发机器上运行jenkins来确保它可以正常工作)。
Full log of the Jenkins build: 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
Oh, I finally figured it out. 哦,我终于明白了。
I had the wrong permissions on ANDROID_HOME/platforms 我对ANDROID_HOME / platforms的权限错误
I just encounter the same problem with you. 我只是遇到了同样的问题。 But I figure it out that because I remove the build.prop,framework.aidl,sdk.properties from android-15 folder(My project denpends on it.), revert these files solves my problem. 但是我发现,因为我从android-15文件夹中删除了build.prop,framework.aidl,sdk.properties(我的项目在此关闭),还原这些文件可以解决我的问题。
goto your ANDROID_HOME directory and set read write permission for user with which your are tryiny. 转到您的ANDROID_HOME目录,并为您的tryiny用户设置读写权限。 ieAndroid sdk directory. ieAndroid sdk目录。 (In Jenkins case you need to give read/write permission to Jenkins user. If you are not sure with the user then set read/write permission for everyone) for eg: In my case ANDROID_HOME= users/localUser/android_sdk_macosx 1) goto android_sdk_macosx folder and set read/write permission for this and sub-folders. (在Jenkins情况下,您需要向Jenkins用户授予读/写权限。如果不确定该用户,则为所有人设置读/写权限)例如:在我的情况下,ANDROID_HOME = users / localUser / android_sdk_macosx 1)转到android_sdk_macosx文件夹,并为此文件夹和子文件夹设置读/写权限。 or you can set it for everyone too. 或者您也可以为所有人设置它。 2) goto jenkins and try to build again. 2)转到jenkins,然后尝试再次构建。 It should work. 它应该工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.