I am using Linux Fedora 16 OS. Eclipse Indigo.
Android SDK as well as its associated Eclipse plugin have been installed successfully.
However, when I imported a sample project I downloaded, the build errors indicated that the compiler could not find the Android classes in the classpath, i.e. the Android jars did not automatically get added to the Eclipse classpath when installing the plugin.
I tried adding all the jars that are in the /android/tools/lib directory (like a lot of them) but that didn't do it.
So I am wondering if this jar(s) need to be downloaded separately, i.e. are not part of the SDK package (which seems doubtful).
Error example:
android.app.Activity cannot be resolved to a type
in Eclipse when you have import as project of android ,check root directory of you project and check it have following thing in it ,like below
.project
AndroidManifest.xml
if your imported project of android doesn't have .project then you should import project like below step :
in Eclipse go to:
File-->New-->Android Project -->now you have some option to check if you want to add Project that have already source code then select Project from exiting Source and find your Project root directory.
Now one more thing when you have imported project Right Click on Project root Directory and Click on properties go to Android -->then if there is no selected build target then select one of Android Target as your required.
Yes, I faced this issue too. Sometimes, while importing android source code eclipse does not add android framework jars to build path. In that case open the .classpath file (It will be in the root folder of your project) and add the line
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
after the source classpath entries. Refresh, clean and build the project. You will find android framework added to your project's build path
Related
I have the support libraries installed via the SDK manager.
I have copied the C:\Program Files\Android\android-sdk\extras\android\support\v7\appcompat folder to my projects libs folder.
I have added the \tools folder of the sdk to my command line path. I have then run
android update project --path . --library C:\Users\srayner\dev\android\AndroidTest1\libs\appcompat
But now netbeans gives me this error;
Failed to resolve library path: C:\Users\srayner\dev\android\AndroidTest1\libs\appcompat
What is the correct method to setup an android support library with resouses in netbeans?
I have successfully build and added the appcompat project in NetBeans.
Create a new android project in netbeans - I called mine "appcompat".
Build your new project just make sure it can be successfully build.
Delete everything inside the src directory and rebuild. My project just contained the default MainActivity that was created by NetBeans. You don't need it.
Navigate to your android sdk install directory
"androidSdkPath\extras\android\support\v7\appcompat and copy all
the contents within that folder
Paste the copied contents to the android project that you
created in step 1 (again mine was named as appcompat).
Very important - Open project.properties and ensure that the "target" property matches the following: "target=android-21"
Build your project and Voila... you should be all set.
If you are still having issues compiling the project that will be using the appcompat library, change your project library properties target=android-21"
I'm having trouble trying to import a project. After doing so I get 6 error items. Of which 4 are the same (Unable to resolve target 'Android-8').
Another one is: Project 'MyProject' is missing required Java project: 'org.json'.
Even though the file org.json.jar is in the libs folder.
And the last one is: The project cannot be built until build path errors are resolved.
What can I do to make Eclipse properly import my projects?
I even tries to create a new project and manually copie the files, but didn't turn out as expected.
To import the existing project
Project Explorer-->new Android Project from Existing Resource-->select project and check copy to the work space option(if you need)--> finish.
Problem
Unable to resolve target 'Android-8'
Right click on the project-->android-->select the target as 8 and save.
org.json.jar
Download this jar from the internet and paste the jar file in the lib folder.
3.Clean the projec once
Unable to resolve target 'Android-8'
You dont have Android-8 SDK installed on your pc.Concider downloading this SDK or if you have any SDK above this version just select it. under project properties.
Project 'MyProject' is missing required Java project: 'org.json'
This message suggest you that this project is expecting org.json library project in your workspace and you should include it as library project.
If you have got jar file then its fine,under project properties just remove library project dependancies and include jar file in build path.
How have you installed the ADT?
It's possible that if Android options aren't available, you haven't installed the ADT plugin correctly.
I would do the following:
Ensure that the ADT is installed
Delete the project and re-import it under the option "Import existing Android code into workspace"
Check that the build path options are correct. Android projects add jars in the lib folder to projects automatically, but this is worth checking.
Keep us posted!
In my Android app I use:
import javax.xml.bind.JAXBContext;
But I get:
The import javax.xml.bind cannot be resolved
I do have com.viewstreet.java.eclipse.jaxbplugin.JAXBPlugin in my plugins list.
#commonsware is correct , just add respctive JAXB API jars in lib folder of your projet or in case of maven project add dependency in pom file
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
viz in my case on linux, solved the issue
Go to https://javaee.github.io/jaxb-v2/ and download the standalone distribution (link at the very bottom of page).
jaxb-ri-2.3.1.zip or whatever version is the latest shall be downloaded. Unzip it and copy the jaxb-ri\mod\jaxb-api.jar from the unzipped folder into the plugins folder of your eclipse installation directory.
Go to eclipse, open your project, right click project name in Projects panel (left most) and choose Properties => Build Path
Under Libraries tab, select Classpath and then click Add External JARs button. Browse and select the file you just copied to eclipse's plugins folder.
Click Apply and Close
Just import your required javax.xml.bind classes and your project shall be built instantly.
Put the JAR in the project's libs/ directory, then add it to the build path via the Add JARs button. That's my standard recipe, and it seems to work, and it has the advantage of putting the JAR in the right spot for command-line builds as well.
At this point, though, I suspect that you will get a compile error. Generally, you cannot import classes in the java and javax packages into an Android project.
Download jax-b.jar and add it as external jar in your project.
Any import cannot be resolved in Java means a class you referenced is not found anywhere on the classpath. You need the library you're trying to use added to your classpath. In Eclipse, that's in project properties in the Java Build Path => Libraries tab. If you don't have the jar file that contains the API you're trying to use, you probably need to get it from http://jaxb.java.net/.
Adding a library/JAR to an Eclipse Android project
I'm building an Android app which uses a library that is defined in another Eclipse project (same workspace). All is working fine, but now I added a jar file to the library project's build path. In Eclipse I exported the jar file to make it visible to dependent projects of the library (Build Path -> Order and Export -> mark the jar file). Still Eclipse (ADT) complains that the import cannot be resolved.
I have set up a test project for the library as well, and there the imports are visible after exporting the jar file as mentioned above.
Is there anything I forgot to configure?
Regards,
Martin
ADT doesn't seem to pick it up automatically :-/
Manually configuring the main project's build path to rely on the library project's jars worked for me.
Build Path -> Libraries -> Add JARs -> {Library Project}\libs\myjar.jar
In my Android app I use:
import javax.xml.bind.JAXBContext;
But I get:
The import javax.xml.bind cannot be resolved
I do have com.viewstreet.java.eclipse.jaxbplugin.JAXBPlugin in my plugins list.
#commonsware is correct , just add respctive JAXB API jars in lib folder of your projet or in case of maven project add dependency in pom file
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
viz in my case on linux, solved the issue
Go to https://javaee.github.io/jaxb-v2/ and download the standalone distribution (link at the very bottom of page).
jaxb-ri-2.3.1.zip or whatever version is the latest shall be downloaded. Unzip it and copy the jaxb-ri\mod\jaxb-api.jar from the unzipped folder into the plugins folder of your eclipse installation directory.
Go to eclipse, open your project, right click project name in Projects panel (left most) and choose Properties => Build Path
Under Libraries tab, select Classpath and then click Add External JARs button. Browse and select the file you just copied to eclipse's plugins folder.
Click Apply and Close
Just import your required javax.xml.bind classes and your project shall be built instantly.
Put the JAR in the project's libs/ directory, then add it to the build path via the Add JARs button. That's my standard recipe, and it seems to work, and it has the advantage of putting the JAR in the right spot for command-line builds as well.
At this point, though, I suspect that you will get a compile error. Generally, you cannot import classes in the java and javax packages into an Android project.
Download jax-b.jar and add it as external jar in your project.
Any import cannot be resolved in Java means a class you referenced is not found anywhere on the classpath. You need the library you're trying to use added to your classpath. In Eclipse, that's in project properties in the Java Build Path => Libraries tab. If you don't have the jar file that contains the API you're trying to use, you probably need to get it from http://jaxb.java.net/.
Adding a library/JAR to an Eclipse Android project