0

私は Android プロジェクトを持っています。コマンド ラインでテストをビルドしてインストールし、実行したいと考えています。

以下は私のビルドシェルスクリプトです:

android update project --path ./main/libraryProject
android update project --path ./main/Project --library ../libraryProject
android update project --path ./main/Test --library ../libraryProject
android update test-project -m $(pwd)/main/Project -p ./main/Test
cd main/Project
ant debug install
cd ../Test
ant debug install test

プロジェクトをビルドしてインストールすることはできますが、テスト プロジェクトをビルドすると次のエラーが発生します。

    [javac] An annotation processor threw an uncaught exception.
    [javac] Consult the following stack trace for details.
    [javac] java.lang.NoClassDefFoundError: android/app/Activity
    [javac]     at java.lang.ClassLoader.defineClass1(Native Method)
    [javac]     at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
    [javac]     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    [javac]     at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
    [javac]     at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
    [javac]     at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
    [javac]     at java.security.AccessController.doPrivileged(Native Method)
    [javac]     at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    [javac]     at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    [javac]     at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    [javac]     at java.lang.Class.forName0(Native Method)
    [javac]     at java.lang.Class.forName(Class.java:264)
    [javac]     at com.google.android.testing.mocking.UsesMocksProcessor.findClassesToMock(UsesMocksProcessor.java:144)
    [javac]     at com.google.android.testing.mocking.UsesMocksProcessor.process(UsesMocksProcessor.java:108)
    [javac]     at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:735)
    [javac]     at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:664)
    [javac]     at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:809)
    [javac]     at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1060)
    [javac]     at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:795)
    [javac]     at com.sun.tools.javac.main.Main.compile(Main.java:380)
    [javac]     at com.sun.tools.javac.main.Main.compile(Main.java:306)
    [javac]     at com.sun.tools.javac.main.Main.compile(Main.java:297)
    [javac]     at com.sun.tools.javac.Main.compile(Main.java:82)
    [javac]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [javac]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    [javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [javac]     at java.lang.reflect.Method.invoke(Method.java:616)
    [javac]     at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:56)
    [javac]     at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1153)
    [javac]     at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:930)
    [javac]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    [javac]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [javac]     at java.lang.reflect.Method.invoke(Method.java:616)
    [javac]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [javac]     at org.apache.tools.ant.Task.perform(Task.java:348)
    [javac]     at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    [javac]     at com.android.ant.IfElseTask.execute(IfElseTask.java:120)
    [javac]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    [javac]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [javac]     at java.lang.reflect.Method.invoke(Method.java:616)
    [javac]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [javac]     at org.apache.tools.ant.Task.perform(Task.java:348)
    [javac]     at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    [javac]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    [javac]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [javac]     at java.lang.reflect.Method.invoke(Method.java:616)
    [javac]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [javac]     at org.apache.tools.ant.Task.perform(Task.java:348)
    [javac]     at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:398)
    [javac]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    [javac]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [javac]     at java.lang.reflect.Method.invoke(Method.java:616)
    [javac]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [javac]     at org.apache.tools.ant.Task.perform(Task.java:348)
    [javac]     at org.apache.tools.ant.Target.execute(Target.java:392)
    [javac]     at org.apache.tools.ant.Target.performTasks(Target.java:413)
    [javac]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    [javac]     at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    [javac]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    [javac]     at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    [javac]     at org.apache.tools.ant.Main.runBuild(Main.java:811)
    [javac]     at org.apache.tools.ant.Main.startAnt(Main.java:217)
    [javac]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    [javac]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
    [javac] Caused by: java.lang.ClassNotFoundException: android.app.Activity
    [javac]     at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    [javac]     at java.security.AccessController.doPrivileged(Native Method)
    [javac]     at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    [javac]     at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    [javac]     at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    [javac]     ... 68 more

私が何をすべきか知っている人はいますか?AndroidMock を使用したために起こりますか?

4

1 に答える 1

0

コードをコンパイルするには、android jar をクラスパスに追加する必要があります。これを設定することでそれを行うことができます:

<property name="jar.libs.dir" value="${libs.dir}" />

その後、コンパイル後に削除できます。

<target name="-post-compile">
    <delete file="libs/android.jar"> </delete>
</target>
于 2012-08-15T23:30:57.737 に答える