Android.App.Activity - package does not exist

I have andorid project files that should compile correctly.

I installed the latest eclipse and Andriod ADT plugins.

Then I imported the project and right-click build.xml to execute it as ANT build. but I have the source codes on some kind of basic code, which, I'm sure, comes from my incorrect setup.

I also tried to run it using ANT from the command line. both times I had errors of the same type

What's wrong?

Buildfile: /Users/admin/Downloads/moshe-5/build.xml init: process.annotations: [javac] Compiling 9 source files to /Users/admin/Downloads/moshe-5/build/classes [javac] /Users/admin/Downloads/moshe-5/src/ti/moshe/CustomAdapter.java:7: package android.app does not exist [javac] import android.app.Activity; [javac] ^ [javac] /Users/admin/Downloads/moshe-5/src/ti/moshe/CustomAdapter.java:8: package android.content does not exist [javac] import android.content.Context; [javac] ^ [javac] /Users/admin/Downloads/moshe-5/src/ti/moshe/CustomAdapter.java:9: package android.graphics does not exist [javac] import android.graphics.Color; 
+6
source share
5 answers

Do not try to build using ANT. Eclipse and the ADT plugin provide a great tool that saves you the trouble. Just right click on the project, select "run" as -> Android application

-8
source

In my case, this was due to the fact that I did not have a default.properties file with a target field in it.

I had to manually create the file and put

 target=android-9 

Or another target version of Android.

If you run

 ant -v 

with your build team, you'll probably see this line

 Property "target" has not been set 

and

 [property] Unable to find property file: /PATH_TO/default.properties 

There are enough hints in these posts.

Hope this also solves your problem.

+3
source

It does not find android packages. In the build step, you must enable android.jar corresponding to the version of Android you want to port.

+1
source

When you write the compilation target, you override the default value specified by android_rules.xml located in: C: \ Program Files (x86) \ Android \ android-sdk \ platform \ android-8 \ templates or wherever android_rules.xml is located on your computer.

Like the Potter mentioned above, it does not find the android library and other libraries, so please look at android_rules.xml to find out how it installs the correct libraries:

 <target name="compile" depends="-resource-src, -aidl" description="Compiles project .java files into .class files"> <!-- If android rules are used for a test project, its classpath should include tested project location --> <condition property="extensible.classpath" value="${tested.project.absolute.dir}/bin/classes" else="."> <isset property="tested.project.absolute.dir" /> </condition> <condition property="extensible.libs.classpath" value="${tested.project.absolute.dir}/libs" else="./libs"> <isset property="tested.project.absolute.dir" /> </condition> <javac encoding="ascii" target="1.5" debug="true" extdirs="" destdir="${out.classes.absolute.dir}" bootclasspathref="android.target.classpath" verbose="${verbose}" classpath="${extensible.classpath}"> <src path="${source.absolute.dir}" /> <src path="${gen.absolute.dir}" /> <classpath> <fileset dir="${external.libs.absolute.dir}" includes="*.jar" /> <fileset dir="${extensible.libs.classpath}" includes="*.jar" /> </classpath> </javac> </target> 

Inside the classpath tags, the android.jar file is used. You can add other libraries by adding more sets of files.

Some other good code examples for writing the ANT compilation target:

It is not possible to create and run an android testing project created using ant create test-project "when the tested project has banks in the libs < directory - this worked for me

http://www.vogella.de/articles/ApacheAnt/article.html

http://www.alittlemadness.com/2010/05/31/setting-up-an-android-project-build/ <- setting up ANT project

+1
source

Most likely, he will not find Android, because you did not define the sdk.dir property, which tells the build process where to find Android. This property is usually found in the local.properties file and populated when you do:

 android update project 

as described here:

http://developer.android.com/tools/projects/projects-cmdline.html#UpdatingAProject

0
source

Source: https://habr.com/ru/post/896355/


All Articles