Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
以编程方式编译Android项目_Android_Ant_Compilation_Project - Fatal编程技术网

以编程方式编译Android项目

以编程方式编译Android项目,android,ant,compilation,project,Android,Ant,Compilation,Project,我想从代码中编译一个现有的Android项目。 如果只是在我的控制台中键入antdebug,它就可以工作,但如果我试图从代码构建它,它就会失败 我尝试运行脚本: 日志(更新的日志位于末尾): 从控制台呼叫: $ ant debug Buildfile: /home/axi/workspace/Tripwire/AndroidCalculatorTest/build.xml -set-mode-check: -set-debug-files: -set-debug-mode: -debug

我想从代码中编译一个现有的Android项目。 如果只是在我的控制台中键入
antdebug
,它就可以工作,但如果我试图从代码构建它,它就会失败

我尝试运行脚本:

日志(更新的日志位于末尾):

从控制台呼叫:

$ ant debug
Buildfile: /home/axi/workspace/Tripwire/AndroidCalculatorTest/build.xml

-set-mode-check:

-set-debug-files:

-set-debug-mode:

-debug-obfuscation-check:

-setup:
     [echo] Gathering info for AndroidCalculatorTest...
    [setup] Android SDK Tools Revision 16
    [setup] Project Target: Android 2.2
    [setup] API level: 8
    [setup] 
    [setup] ------------------
    [setup] Resolving library dependencies:
    [setup] No library dependencies.
    [setup] 
    [setup] ------------------
    [setup] 
    [setup] WARNING: Attribute minSdkVersion in AndroidManifest.xml (7) is lower than the project target API level (8)

-build-setup:
     [echo] Creating output directories if needed...

-pre-build:

-code-gen:
     [echo] ----------
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
[renderscript] No RenderScript files to compile.
     [echo] ----------
     [echo] Handling Resources...
     [aapt] No changed resources. R.java and Manifest.java untouched.

-pre-compile:

-compile:

-post-compile:

-obfuscate:

-dex:
      [dex] Converting compiled files and external libraries into /home/axi/workspace/Tripwire/AndroidCalculatorTest/bin/classes.dex...

-crunch:
   [crunch] Crunching PNG Files in source dir: /home/axi/workspace/Tripwire/AndroidCalculatorTest/res
   [crunch] To destination dir: /home/axi/workspace/Tripwire/AndroidCalculatorTest/bin/res
   [crunch] Processing image to cache: /home/axi/workspace/Tripwire/AndroidCalculatorTest/res/drawable-hdpi/ic_launcher.png => /home/axi/workspace/Tripwire/AndroidCalculatorTest/bin/res/drawable-hdpi/ic_launcher.png
   [crunch]   (processed image to cache entry /home/axi/workspace/Tripwire/AndroidCalculatorTest/bin/res/drawable-hdpi/ic_launcher.png: 0% size of source)
   [crunch] Processing image to cache: /home/axi/workspace/Tripwire/AndroidCalculatorTest/res/drawable-ldpi/ic_launcher.png => /home/axi/workspace/Tripwire/AndroidCalculatorTest/bin/res/drawable-ldpi/ic_launcher.png
   [crunch]   (processed image to cache entry /home/axi/workspace/Tripwire/AndroidCalculatorTest/bin/res/drawable-ldpi/ic_launcher.png: 0% size of source)
   [crunch] Processing image to cache: /home/axi/workspace/Tripwire/AndroidCalculatorTest/res/drawable-mdpi/ic_launcher.png => /home/axi/workspace/Tripwire/AndroidCalculatorTest/bin/res/drawable-mdpi/ic_launcher.png
   [crunch]   (processed image to cache entry /home/axi/workspace/Tripwire/AndroidCalculatorTest/bin/res/drawable-mdpi/ic_launcher.png: 0% size of source)
   [crunch] Crunched 3 PNG files to update cache

-package-resources:
     [aapt] Creating full resource package...

-package:
[apkbuilder] Current build type is different than previous build: forced apkbuilder run.
[apkbuilder] Creating AndroidCalculatorTest-debug-unaligned.apk and signing it with a debug key...

-do-debug:
 [zipalign] Running zip align on final apk...
     [echo] Debug Package: /home/axi/workspace/Tripwire/AndroidCalculatorTest/bin/AndroidCalculatorTest-debug.apk

debug:
[propertyfile] Creating new property file: /home/axi/workspace/Tripwire/AndroidCalculatorTest/bin/build.prop
[propertyfile] Updating property file: /home/axi/workspace/Tripwire/AndroidCalculatorTest/bin/build.prop
[propertyfile] Updating property file: /home/axi/workspace/Tripwire/AndroidCalculatorTest/bin/build.prop
[propertyfile] Updating property file: /home/axi/workspace/Tripwire/AndroidCalculatorTest/bin/build.prop

BUILD SUCCESSFUL
Total time: 6 seconds

如果我加上:

project.setProperty("key.store", "/home/axi/.android/debug.keystore");
project.setProperty("ant.home", "/home/axi/Downloads/apache-ant-1.8.3/bin");
project.setProperty("ant.version", "Apache Ant(TM) version 1.8.3 compiled on February 26 2012");
现在的问题是:

/home/axi/android-sdk-linux/tools/ant/build.xml:445: java.lang.NoSuchMethodError: com.android.ant.TaskHelper.getSdkLocation(Lorg/apache/tools/ant/Project;)Ljava/io/File;
    at com.android.ant.NewSetupTask.execute(NewSetupTask.java:189)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    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:120)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    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:392)
    at org.apache.tools.ant.Target.performTasks(Target.java:413)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    at at.tugraz.iaik.amd.util.CompileAnt.runAntScript(CompileAnt.java:44)
    at at.tugraz.iaik.amd.util.CompileAnt.main(CompileAnt.java:15)
在将所有(可能并非所有都需要)Android Sdk和Ant libs以及tools.jar添加到其工作的类路径之后:)

project.setProperty("key.store", "/home/axi/.android/debug.keystore");
project.setProperty("ant.home", "/home/axi/Downloads/apache-ant-1.8.3/bin");
project.setProperty("ant.version", "Apache Ant(TM) version 1.8.3 compiled on February 26 2012");
/home/axi/android-sdk-linux/tools/ant/build.xml:445: java.lang.NoSuchMethodError: com.android.ant.TaskHelper.getSdkLocation(Lorg/apache/tools/ant/Project;)Ljava/io/File;
    at com.android.ant.NewSetupTask.execute(NewSetupTask.java:189)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    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:120)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    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:392)
    at org.apache.tools.ant.Target.performTasks(Target.java:413)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    at at.tugraz.iaik.amd.util.CompileAnt.runAntScript(CompileAnt.java:44)
    at at.tugraz.iaik.amd.util.CompileAnt.main(CompileAnt.java:15)