AppCompat Classes Not Found in Eclipse - android

OK, maybe it's just the lack of sleep, but I am having difficulty getting AppCompat classes to be visible in my Eclipse project, despite the fact that:
this project used to work
a Gradle build of this project works fine
Here's my Eclipse project setup:
So, I have:
android-support-v4.jar in libs/
android-support-v7-appcompat attached as an Android library project
The symptom is that the AppCompat classes are not visible: Eclipse reports "The import android.support.v7.app cannot be resolved" when I try to import android.support.v7.app.ActionBarActivity. The android-support-v7-appcompat.jar file appears to have the class, and it appears to be properly added to my build path (by virtue of being in "Android Dependencies", which is checked in the Eclipse build path dialog).
Other notes:
I temporarily removed the appcompat library project from the Eclipse configuration, exported Gradle build files, and added it back, with no effect on Eclipse. Adding compile 'com.android.support:appcompat-v7:19.0.1' to the dependencies block in the Gradle build file was sufficient to get the project to build using gradle assembleDebug, so it's not like I have the import statement wrong.
I created a new project and have the same issue there, so it is not tied to this specific project.
The SDK Manager reports that I have 19.0.1 of the Android Support Library installed.
I have cleaned this project and appcompat, restarted Eclipse, and have tried various profanities, with no effect on Eclipse.
Any suggestions as to where I am going wrong?
UPDATE
Here's my Java build path, per Eclipse:

Well, I'm not completely certain what I did, but it's now working.
The most likely situation is that the directory had some of the wrong files marked read-only. Allowing all files to be writeable, plus restarting Eclipse for the fourth time today, eliminated my problems, in both projects (the one depicted above and another one).
Now, it's entirely possible that I did something else along the way that got picked up by the restart of Eclipse, or just that Eclipse wanted to restart (again) before it decided to behave.
Anyway, thanks to all who provided advice!

Have you checked if the android-support-v4.jar is the same version in both projects? When you are using appcompat, in fact, you don't need the android-support-v4.jar, as it is packed in appcompat project. Another try is to verify if the Project Build Target of appcompat is <= project build target of your project.

Remove support jar from your project, since support jar is there in app-compat lib also.

Related

GCM NoClassDefFoundError [duplicate]

I have a rather big Android App project that is referencing several library projects. Everything was fine until i upgraded the eclipse ADT plugin to the newest version (v22). I also upgraded the SDK of course. I do not see any compile errors in eclipse, but when i run the project on the phone i get a NoClassDefFoundError.
java.lang.NoClassDefFoundError: org.acra.ACRA
....
The arca library is included in one of the referenced library project (in the libs folder) and i can see it in the "Android Private Libraries" in the package explorer, also as i said, no compile errors. The project runs fine on everyone else's computer that did not upgrade ADT.
I have already tried a whole bunch of stuff including but not limited to:
re-install the android SDK
download a fresh ADT bundle
delete all my code an get it again from git
copy the library in question to the app project
comment out the code that uses this library - i just get the same error for the next library
all without any success, so i'm getting really desperate here.
I would be really happy if anyone could give me a hint on how to solve that problem.
Quoting Streets of Boston from his adt-dev post:
When upgrading, the 'Order and Export' of the new 'Android Private
Libraries' is not always checked. And the android-support-v4.jar is now in
this 'Android Private Libraries' section.
To fix this, go to 'Order and Export' and check 'Android Private
Libraries'. Then refresh/clean/rebuild.
After you done this 'fix' for a library project, you may need to just close
and re-open any depending project, because they may not see this 'fix'
immediately.
Give this a shot and with luck it will solve your problem.
Simply checking Android Private Libraries was not enough, I also had to install Android SDK Build-tools in Android SDK Manager.
I had also the same problem and my adt was 22.0.1. And none of the solution above worked. Further when adding a external library project to a working project.I always check the gen folder of working project and if R of external library project is there (along with package name),then only external library project is exported. And on my gen folder no packagename of external library was shown.
So I checked on project.properties file and there wasn't any external library link present android.library.reference.1= present. So I manually added the external library reference there ,even though I had added from project->properties->Java Build Path->Projects->Add. So manually editing the project.properties did all the work for me.
I have encountered a similar problem, spent about 3 hours, but none of the proposed here decisions did not help... Finally I found a source of the problem: my project files & project.properties were read-only. Eclipse is simply silently ignoring any changes in library dependencies when I doing it in the GUI!
I had the same problem. It was because of the eclipse project.
To solve it I created a new project in eclipse, copy my existing project classes and resources into it and then launched eclipse again and added my custom includes.
I had the similar issue and my answer is slightly different from CommonsWare's. Here is my screenshot:
After checking the libs back in my build started to work again.
I had also the same problem,
i) add gson lib as referecend librairies
ii) check it in java Build Path

java.lang.NoClassDefFoundError after ADT update [duplicate]

I have a rather big Android App project that is referencing several library projects. Everything was fine until i upgraded the eclipse ADT plugin to the newest version (v22). I also upgraded the SDK of course. I do not see any compile errors in eclipse, but when i run the project on the phone i get a NoClassDefFoundError.
java.lang.NoClassDefFoundError: org.acra.ACRA
....
The arca library is included in one of the referenced library project (in the libs folder) and i can see it in the "Android Private Libraries" in the package explorer, also as i said, no compile errors. The project runs fine on everyone else's computer that did not upgrade ADT.
I have already tried a whole bunch of stuff including but not limited to:
re-install the android SDK
download a fresh ADT bundle
delete all my code an get it again from git
copy the library in question to the app project
comment out the code that uses this library - i just get the same error for the next library
all without any success, so i'm getting really desperate here.
I would be really happy if anyone could give me a hint on how to solve that problem.
Quoting Streets of Boston from his adt-dev post:
When upgrading, the 'Order and Export' of the new 'Android Private
Libraries' is not always checked. And the android-support-v4.jar is now in
this 'Android Private Libraries' section.
To fix this, go to 'Order and Export' and check 'Android Private
Libraries'. Then refresh/clean/rebuild.
After you done this 'fix' for a library project, you may need to just close
and re-open any depending project, because they may not see this 'fix'
immediately.
Give this a shot and with luck it will solve your problem.
Simply checking Android Private Libraries was not enough, I also had to install Android SDK Build-tools in Android SDK Manager.
I had also the same problem and my adt was 22.0.1. And none of the solution above worked. Further when adding a external library project to a working project.I always check the gen folder of working project and if R of external library project is there (along with package name),then only external library project is exported. And on my gen folder no packagename of external library was shown.
So I checked on project.properties file and there wasn't any external library link present android.library.reference.1= present. So I manually added the external library reference there ,even though I had added from project->properties->Java Build Path->Projects->Add. So manually editing the project.properties did all the work for me.
I have encountered a similar problem, spent about 3 hours, but none of the proposed here decisions did not help... Finally I found a source of the problem: my project files & project.properties were read-only. Eclipse is simply silently ignoring any changes in library dependencies when I doing it in the GUI!
I had the same problem. It was because of the eclipse project.
To solve it I created a new project in eclipse, copy my existing project classes and resources into it and then launched eclipse again and added my custom includes.
I had the similar issue and my answer is slightly different from CommonsWare's. Here is my screenshot:
After checking the libs back in my build started to work again.
I had also the same problem,
i) add gson lib as referecend librairies
ii) check it in java Build Path

Libraries do not get added to APK anymore after upgrade to ADT 22

I have a rather big Android App project that is referencing several library projects. Everything was fine until i upgraded the eclipse ADT plugin to the newest version (v22). I also upgraded the SDK of course. I do not see any compile errors in eclipse, but when i run the project on the phone i get a NoClassDefFoundError.
java.lang.NoClassDefFoundError: org.acra.ACRA
....
The arca library is included in one of the referenced library project (in the libs folder) and i can see it in the "Android Private Libraries" in the package explorer, also as i said, no compile errors. The project runs fine on everyone else's computer that did not upgrade ADT.
I have already tried a whole bunch of stuff including but not limited to:
re-install the android SDK
download a fresh ADT bundle
delete all my code an get it again from git
copy the library in question to the app project
comment out the code that uses this library - i just get the same error for the next library
all without any success, so i'm getting really desperate here.
I would be really happy if anyone could give me a hint on how to solve that problem.
Quoting Streets of Boston from his adt-dev post:
When upgrading, the 'Order and Export' of the new 'Android Private
Libraries' is not always checked. And the android-support-v4.jar is now in
this 'Android Private Libraries' section.
To fix this, go to 'Order and Export' and check 'Android Private
Libraries'. Then refresh/clean/rebuild.
After you done this 'fix' for a library project, you may need to just close
and re-open any depending project, because they may not see this 'fix'
immediately.
Give this a shot and with luck it will solve your problem.
Simply checking Android Private Libraries was not enough, I also had to install Android SDK Build-tools in Android SDK Manager.
I had also the same problem and my adt was 22.0.1. And none of the solution above worked. Further when adding a external library project to a working project.I always check the gen folder of working project and if R of external library project is there (along with package name),then only external library project is exported. And on my gen folder no packagename of external library was shown.
So I checked on project.properties file and there wasn't any external library link present android.library.reference.1= present. So I manually added the external library reference there ,even though I had added from project->properties->Java Build Path->Projects->Add. So manually editing the project.properties did all the work for me.
I have encountered a similar problem, spent about 3 hours, but none of the proposed here decisions did not help... Finally I found a source of the problem: my project files & project.properties were read-only. Eclipse is simply silently ignoring any changes in library dependencies when I doing it in the GUI!
I had the same problem. It was because of the eclipse project.
To solve it I created a new project in eclipse, copy my existing project classes and resources into it and then launched eclipse again and added my custom includes.
I had the similar issue and my answer is slightly different from CommonsWare's. Here is my screenshot:
After checking the libs back in my build started to work again.
I had also the same problem,
i) add gson lib as referecend librairies
ii) check it in java Build Path

import .R cannot be resolved when I import actionbarsherlock

I want to be able to use the action bar in my android project (2.3), so I am trying to import the actionbarsherlock library. However, I am having problems....
I've imported the library, edited the build path of my android project to include the library, and also deleted the android-support-v4 jar from the ABS /libs directory and copied my project's android-support-v4 into the ABS /libs directory to solve the jar mismatch. However, now that I've done all those things, my project can't resolve myproject.R anywhere. I import myproject.R in almost all of my .java files, and they all have the same error ("The import com.myproject.R cannot be resolved"). In addition, when I clean my project, I get a lot of errors in the console window:
They all go along the lines of:
error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light'.
To my knowledge, R is where all of the layout information is stored, so I have no idea why this is even a problem...
I've been working on this error for days, and I'm extremely frustrated and finally decided to take it to stack overflow. Thanks guys for the help!
ActionBarSherlock is a library project.
So import the library project in your eclipse
Its a library project. To check Right Click on your library project. goto Properties.
Choose android. You will see a Is Library checked as shown in the below pic.
Add your library project to your Android project.
Right click on your Android project. Goto Properties . Choose android . Click add button add the library to your project. You can see a green tick in the below pic.
Make sure you have one copy of andorid-suuport-v4.jar in your libs folder.
Do not import R.*;
You will see two R.java one for the library project and one for your android project.
Clean and build.
edited the build path of my android project to include the library
Never manually modify the build path of an Android project.
ActionBarSherlock is an Android library project. You need to add a reference to ActionBarSherlock's library project from your main application project and undo the manual change to the build path.
UPDATE
The second half of your problem was that your build target was set too low. The build target controls what version of the Android classes, resources, etc. is available to your app, and if you use ActionBarSherlock, you need this to be API Level 14 or higher.
if I make my project build target 4.0, can I still run it on an emulator/phone running Android 2.3?
Yes. Set your android:minSdkVersion to be 10 or lower. Eclipse (via Lint) will yell at you if you accidentally try using classes, methods, and such that are higher than your minSdkVersion, even though they are legal due to your build target.
I found that
if minSDKVersion in AndroidManifest.xml of the Project is lower than library,
it also make the Project to be error to build R.java

Cannot build library dependent project after update to ADT 14

In order to implement different versions of our UI we broke our program up into UI specific code and a common library project that has everything else. Up until yesterday when I updated to ADT 14 everything was working fine. Now I can't build. I keep getting the error "The container 'Library Projects' references non existing library 'path to the bin folder of my common project and the name of the project.jar'
I've been all over the web and tried everything I can think of to fix this to no avail. Can someone help me out? I'm basically stuck at this point.
Maybe you have the same issues I had when switching to the new ADT:
In my previous setup I had some resources split between the library and the main project. The library project would not compile error free on its own but only in combination with the main project which added the missing resources.
It doesn't work like this any more.
The library project must compile completely error free now. When it does the build process will create a <lib_project_name>.jar in the bin folder of the library project.
If the jar file is not created ( thus the build process of the library project failed for some reason - eg. because the changes in the R.java file (see http://tools.android.com/recent/buildchangesinrevision14 )) you will get the error message you described.
Also, I had to manually remove the <lib_project>_src from the project.
I've had a problem with a few different projects where I did the fixes suggested in the other answer, but they were only fixed temporarily.
Every time I reopened Eclipse or did a Clean on a project, the "Library Projects" directory would disappear, and I would have to open the project properties, remove the library, and add it again.
I solved this the hard way by creating a new project and copying everything into it.
Then I found an easy way to solve it. Right click the project, Refactor-->Rename. You can rename it back afterwards. This fixed it.
Check out the article "Changes to Library Projects in Android SDK Tools, r14" ( http://android-developers.blogspot.com/2011/10/changes-to-library-projects-in-android.html ) on the Android Developers blog.
E.g. #P.Melch: "I had to manually remove the _src from the project" should be done as follows:
To fix the project, you must remove the extraneous source folders with the following steps:
Right click source folder and choose Build Path > Remove from Build
path.
A dialog will pop up. In it, make sure to check “Also unlink the folder from the project” to completely remove the folder.
You have to update the Android SDK in Android SDK Manager
Android SDK Tools Intalled
Android SDK Plataforms Installed
Android SDK Builds Installed

Categories

Resources