Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8921515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:33:51+00:00 2026-06-15T06:33:51+00:00

I have a sample Android app, created with Eclipse, having one Activity. I ran

  • 0

I have a sample Android app, created with Eclipse, having one Activity.
I ran this command to build the ant build files for this project:

android create project --target 8 --name SampleApp --path ./SampleApp --activity MainActivity --package com.example.sampleapp

Running “ant debug” successfully builds the project and creates the apk files:

-post-build:

debug:

BUILD SUCCESSFUL
Total time: 1 second

Now, I want to create an Android Test Project. I run this command:

android create test-project -m ../SampleApp -n SampleAppTest -p SampleAppTest

This successfully created the SampleAppTest directory containing the build files. I have a single class, src/com/example/sampleapp/MainActivityTest.java:

package com.example.sampleapp;

import android.test.ActivityInstrumentationTestCase2;

public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> {

    public MainActivityTest() {
        super("com.example.sampleapp", MainActivity.class);
    }

}

I want to build this project. In the tutorial found here http://developer.android.com/tools/testing/testing_otheride.html#RunTestsAnt it says I should be able to do “ant run-tests”. Unfortunately this target does not exist:

$ ant run-tests
Buildfile: /Users/cmuraru/Work/androidtest/SampleAppTest/build.xml

BUILD FAILED
Target "run-tests" does not exist in the project "SampleAppTest". 

Total time: 0 seconds

If I try “ant debug” I receive an error when compiling, stating that the MainActivity class (from SampleApp) can not be found.

-compile:
    [javac] Compiling 2 source files to /Users/cmuraru/Work/androidtest/build/test/classes
    [javac] /Users/cmuraru/Work/androidtest/SampleAppTest/src/com/example/sampleapp/MainActivityTest.java:15: cannot find symbol
    [javac] symbol: class MainActivity
    [javac] public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> {
    [javac]                                                                        ^
    [javac] /Users/cmuraru/Work/androidtest/SampleAppTest/src/com/example/sampleapp/MainActivityTest.java:18: cannot find symbol
    [javac] symbol  : class MainActivity
    [javac] location: class com.example.sampleapp.MainActivityTest
    [javac]         super("com.example.sampleapp", MainActivity.class);
    [javac]                                        ^
    [javac] 2 errors

BUILD FAILED
/Users/cmuraru/Work/android-sdk-macosx/tools/ant/build.xml:705: The following error occurred while executing this line:
/Users/cmuraru/Work/android-sdk-macosx/tools/ant/build.xml:718: Compile failed; see the compiler error output for details.

Total time: 1 second

When trying “ant test”, it also fails:

test:
     [echo] Running tests ...
     [exec] INSTRUMENTATION_STATUS: id=ActivityManagerService
     [exec] INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{com.example.sampleapp.tests/android.test.InstrumentationTestRunner}
     [exec] INSTRUMENTATION_STATUS_CODE: -1
     [exec] android.util.AndroidException: INSTRUMENTATION_FAILED: com.example.sampleapp.tests/android.test.InstrumentationTestRunner
     [exec]     at com.android.commands.am.Am.runInstrument(Am.java:616)
     [exec]     at com.android.commands.am.Am.run(Am.java:118)
     [exec]     at com.android.commands.am.Am.main(Am.java:81)
     [exec]     at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
     [exec]     at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:237)
     [exec]     at dalvik.system.NativeStart.main(Native Method)

What am I missing/doing wrong here? Any help is gladly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:33:52+00:00Added an answer on June 15, 2026 at 6:33 am

    Okay, I spotted the problem.
    I failed to mention that in ant.properties, I’ve changed the out.dir location to “../build”. Because of this, the compiler did not know where to get the class files of the SampleApp when building the SampleAppTest. So one solution is to delete the out.dir entry in ant.properties, but I did not want that. I had to find a way to tell the compiler where to get these classes. The solutions I found was to override the “-compile” target in build.xml like so:

    <property name="SampleApp.build.location" value="../build"/>
        <target name="-compile" depends="-build-setup, -pre-build, -code-gen, -pre-compile">
            <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
                <!-- merge the project's own classpath and the tested project's classpath -->
                <path id="project.javac.classpath">
                    <path refid="project.all.jars.path" />
                    <path refid="tested.project.classpath" />
                </path>
                <javac encoding="${java.encoding}"
                        source="${java.source}" target="${java.target}"
                        debug="true" extdirs="" includeantruntime="false"
                        destdir="${out.classes.absolute.dir}"
                        bootclasspathref="project.target.class.path"
                        verbose="${verbose}"
                        classpathref="project.javac.classpath"
                        fork="${need.javac.fork}">
                    <src path="${source.absolute.dir}" />
                    <src path="${gen.absolute.dir}" />
                    <compilerarg line="${java.compilerargs}" />
                    <classpath>
                        <!-- steff: we changed one line here !-->
                        <fileset dir="${SampleApp.build.location}/classes" includes="*"/>
                    </classpath>
                </javac>
    
                <!-- if the project is instrumented, intrument the classes -->
                <if condition="${build.is.instrumented}">
                    <then>
                        <echo level="info">Instrumenting classes from ${out.absolute.dir}/classes...</echo>
    
                        <!-- build the filter to remove R, Manifest, BuildConfig -->
                        <getemmafilter
                                appPackage="${project.app.package}"
                                libraryPackagesRefId="project.library.packages"
                                filterOut="emma.default.filter"/>
    
                        <!-- define where the .em file is going. This may have been
                             setup already if this is a library -->
                        <property name="emma.coverage.absolute.file" location="${out.absolute.dir}/coverage.em" />
    
                        <!-- It only instruments class files, not any external libs -->
                        <emma enabled="true">
                            <instr verbosity="${verbosity}"
                                   mode="overwrite"
                                   instrpath="${out.absolute.dir}/classes"
                                   outdir="${out.absolute.dir}/classes"
                                   metadatafile="${emma.coverage.absolute.file}">
                                <filter excludes="${emma.default.filter}" />
                                <filter value="${emma.filter}" />
                            </instr>
                        </emma>
                    </then>
                </if>
    
                <!-- if the project is a library then we generate a jar file -->
                <if condition="${project.is.library}">
                    <then>
                        <echo level="info">Creating library output jar file...</echo>
                        <property name="out.library.jar.file" location="${out.absolute.dir}/classes.jar" />
                        <if>
                            <condition>
                                <length string="${android.package.excludes}" trim="true" when="greater" length="0" />
                            </condition>
                            <then>
                                <echo level="info">Custom jar packaging exclusion: ${android.package.excludes}</echo>
                            </then>
                        </if>
    
                        <propertybyreplace name="project.app.package.path" input="${project.app.package}" replace="." with="/" />
    
                        <jar destfile="${out.library.jar.file}">
                            <fileset dir="${out.classes.absolute.dir}"
                                    includes="**/*.class"
                                    excludes="${project.app.package.path}/R.class ${project.app.package.path}/R$*.class ${project.app.package.path}/BuildConfig.class"/>
                            <fileset dir="${source.absolute.dir}" excludes="**/*.java ${android.package.excludes}" />
                        </jar>
                    </then>
                </if>
    
            </do-only-if-manifest-hasCode>
        </target>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a simple android app and signed it using the Eclipse export
I have created a small and simple android app. I tried installing it on
I am testing this sample on version 13 of android (3.2) and I have
I thought I'd have a crack at building an Android app having not done
I want built a Android App and use Eclipse for this. It is my
I created ApiDemos project using Eclipse - New Project - Sample command. Trying to
Ok, so I just recently got into this Android app development using Eclipse for
I have a simple app (tabs with Fragment contents) obtained by extending this sample:
in the first activity of my app i have created some fields as like
I have created an android project using eclipse.the default system generated code looked as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.