Android dependencies error after renaming project - android

I renamed my Project:
after that i got the red callsign at my Project(which you see in the first Image) and this:
also my projectproperties says this but i'm not sure if this was also the case before renaming:
even that the path is(!) spelled correctly.
I referenced the libaries to my Project:
But i'm not able to fix the Problem. Still he doesn't recognize the Facebook and GPS libs in my Project..
I also checked this:
Libraries do not get added to APK anymore after upgrade to ADT 22
this:
accidentally removed android dependencies folder
and this...
Completely renaming a project in Eclipse
but nothing did the trick.
Any help is appreciated.

(following up after some comments)
If your project is broken after a refactor and you are going crazy to figure out what's wrong you can consider to create a fresh new project.
Create an empty project starting from the existing one is really simple, just follow this steps:
Create a new project with the desidered name
Copy oldProject/src/ to newProject/src/
Copy oldProject/res/ to newProject/res/
Copy oldProject/libs/ to newProject/libs/
Copy oldProject/AndroidManifest.xml to newProject/AndroidManifest.xml
Check that your project's classpath is set correctly, same for other dependecies.
Refresh all the projects in the workspace (one by one)
Clean (yes, it's always a good idea)
Build all

For each of your projects, verify dependencies in project references & java build path:
File -> Properties
"Java Build Path"
verify, that all projects, referenced by current project, are added.
"Project references"
verify, that all projects, referenced by current project, are checked.

Related

How to edit build path entries in Eclipse?

So I have been having trouble with the Android Support Library with respect to a Jar mismatch or the like where for some reason I was having trouble extending the ActionBarActivity as it was giving the error that appcompat_v7.apk could not be found.
Hence I deleted the original library I had in my Eclipse projects and reinstalled the Support Library, attaching it to my project of interest with these instructions. Note that following these instructions, the new project folder is now "android-support-v7-appcompat" rather than the original "appcompat_v7".
Following this, I have tried several times to clean my project, quit and reenter Eclipse, but I still come up with two problems stating: "The project cannot be built until build path errors are resolved" and "'ProjectName' is missing required Java project: 'appcompat_v7'".
However, when going to Project --> Properties --> Java Build Path, under "Order and Export" a folder named "appcompat_v7" is shown as missing, though the other jars of interest are present, as can be seen in this screenshot:
What can I do to delete or edit this build path entry? To be clear, at this point my project will not even compile, although prior to my deleting the original appcompat_v7 folder it was able to compile but not load any Activity that extended the ActionBarActivity. I would love to be able to compile my code again -_-
The folder icon next to "appcompat_v7" indicates that it is a project. You should remove it from the "Projects" tab.

NoClassDefFoundError - GameHelper Google Games

Using Eclipse IDE
Following the: https://developers.google.com/games/services/android/quickstart
Using the copy of google-play-services_lib (as recommended) and imported as Eclipse project.
Editing the game manifest with:
Adding our APP ID to res/values/strings.xml
Linked google-play-services_lib with our game project and set references in Order and Export tabs in the project settings
In accordance with https://developers.google.com/games/services/android/init using the project BaseGameUtils, from which our activity cannot inherit, because there’s another class already.
So, we moved to the second method without inheriting (see Using GameHelper without BaseGameActivity). We linked google-play-services_lib for BaseGameUtils and set the Library (compilation went down OK).
Linking added to our project to be able to use GameHelper as well as google-play-services_lib.
At this moment SDK from Facebook started causing trouble, so we had to add android-support-v4.jar (used by BaseGameUtils as well) and error during compilation occurs:
Found 2 versions of android-support-v4.jar in the dependency list,
but not all the versions are identical (check is based on SHA-1 only at this time).
All versions of the libraries must be the same at this time.
Versions found are:
Path: /Users/travis/Work/Craneballs/Mafia_android/facebook-android-sdk/facebook/libs/android-support-v4.jar
Path: /Users/travis/Work/Craneballs/Mafia_android/BaseGameUtils/libs/android-support-v4.jar
the project can be launched, but crashes on GoogleHelper = new GameHelper(this, GameHelper.CLIENT_ALL)
with the error message: java.lang.NoClassDefFoundError: com.google.example.games.basegameutils.GameHelper
I’ve spent many painful hours on this and am at my wits end. Any ideas?
I was having the same problem.
Here's the solution that fixed it for me:
I had the same issue, I did the following to fix the problem.
Go to "Properties" of the project.
Select "Java Build Path"
Select "Order and Export" Tab
You should see the selected project's "src" and "gen" paths and dependencies here.
The order how they listed were first "src" and then "gen" path
I switch them, so that "gen" folder is build before the "src"
gen - automated code in project (from dependencies and references)
src - source code in project
There was no need to restart the Eclipse. It just started working.
Honestly I have never tried "Android Tools > Fix Project Properties", sometimes it might be doing the same thing. I do not know, I just did above after seen the error message, thinking something is wrong with the build paths.
Resources that might help...
NoClassDefFoundError for code in an Java library on Android
Android app crashes after SDK-tools update version (NoClassDefFound, tool version 22)

Include cwac-loaderex library in Android Eclipse project

I'm trying to use the cwac-loaderex library in my Android application. I cloned the repository and have imported the included project into my Eclipse project.
At this point I don't have any compilation errors in Eclipse, but when I try to run the application in the emulator I get:
03-23 20:34:16.895: E/dalvikvm(652): Could not find class 'com.commonsware.cwac.loaderex.SQLiteCursorLoader', referenced from method com.alwaysorderdessert.AlwaysOrderDessertActivity.onCreateLoader
How do I make sure that these external dependencies are loaded along with my application in the emulator and are also (by extension?) included in my distributed .apk?
Thanks!
Update
I have added the .jar file to my project and included in the build path, so now my project explorer window looks like the following:
However, I'm still getting the same error in the emulator. Any ideas?
Thanks again.
Update 2
After a bit of Googling and thanks to this SO answer I found that I just needed to check off the .jar file in the Java Build Path > Order and Exports tab.
Update 3
As was pointed out by the comment in the answer below, I should have copied the .jar file to the libs/ directory rather than lib/. This makes the other changes unnecessary (i.e., adding the .jar to the build path, selecting it for export). What a difference a letter makes!
Put the JAR in your libs/ directory, and that should be sufficient.
I noticed that my README was out of date, telling you to add it to your Eclipse build path. That was correct a year-and-change ago but is no longer needed and may contribute to your problems. Hence, if you manually adjusted your build path, undo that. I apologize for the stale instructions.

What is Android Dependencies? Remove it from Build Path, ClassNotFoundException occurs

I'm working on a team project. I included a .jar file in Build Path and committed to SVN. When I updated code in my working directory, a new folder appears in Eclipse called "Android Dependencies". If I let it be there, my program runs; If I remove it, my program reports a ClassNotFoundException.
Now how to fix this ClassNotFoundException?
For the people whose heart dropped when they read the comment that deleting the Android Dependencies virtual folder will destroy your project, there is an easy fix.
Right click on the destroyed project
Select "Android Tools > Fix Project Properties" in the dropdown
I hosed my project dependencies when trying to set up my git repo, and this is fixed it.
Android Dependencies is a virtual folder where Eclipse shows what JAR files the project depends on. It's not a physical folder; you won't find it on your hard disk. And the folder is not checked in into Subversion.
Do not delete that folder. You will destroy your project.
To fix it, just revert to an older Subversion revision and check it in again.
I've had a similar problem after setting up a git repo with my project.
The problem was that the appcompat import lost its folder reference.
If the 'Fix Project Properties' mentioned doesn't work for you try this:
Go to Project > Properties
Go to the 'Android' tab
Under 'Libraries', if there's a red 'X' next to the appcompat folder, remove
it then hit 'add' and add it in again. The reference should show a
green tick now.
Save and clean the project if needs be
If you also have marked project build target below API level 16 in the Android project properties, the error is going to come because prior to this level, there was no Android dependencies.

In eclipse, unable to reference an android library project in another android project

As I was writing up this question I managed to solve it so repeat it here for the benefit of others. Here is the initial problem:
I have created a very simple library project which I want to reference in another project. I have done this previously with no problems so not really sure why it is not working this time. I have:
Flagged the library project via project properties. The default.properties file has this set : android.library=true
In my other project added reference to my library project via project properties. The default.properties file has the reference added as expected ie android.library.reference.1=K:/android_test_ws/applicationRegistrar
The green tick against the referenced library project starts off green and then changes to a red cross.
This implies that there must be something wrong / missing from the library project but I don't know what. My library project on this occasion is MUCH simpler than the previous one I created.
OK Here is the solution which I found when I was looking for the default.properies file of the referencing project (not the library) in my file system. Although the referencing project was in the same eclipse workspace as the library project, the actual files were somewhere else in the file system ie they were'nt in the same parent folder of the library project. As soon as I placed the referencing project in the same physical folder as the library project it all went fine.
I guess that this must be something to do with android using ant underneath the covers.
Edit: The project name needs match the folder name on the file system. What you are seeing in the Project Properties->Android->Library Reference is a relative file system path.
Make Sure both the projects are present in same work space.
To Do it, while importing the projects make sure "copy project into work space" check box is checked.
the same problem will occur if your library project is in different partition from your current workspace. I have the same problem just now. My git source is in C: and I just move my workspace to D: and everything start to collapse.
Simplest way to get the library paths paths correct is to use the GUI from Eclipse to add the library as shown in the following screenshot and let Eclipse take care of putting the correct relative paths in project.properties. Its a common setup to have your library projects hosted at directories vastly different than your main projects that uses the library. This method will work if the "libary project" and the project using it are in the same eclipse "workspace" (they "need not" be in same parent folder):
Please ensure that the library project is marked as "Is Library" - right click on the library project - properties - Android - mark the "Is Library" checkbox - in project.properties of the library project you should have a new entry:"android.library=true. Now add it into the project you want as described in the post below.(the post with image integrated - from Nilesh Pawar).
This bug is referenced several times here 27199, 35786, 36460 & 38052
Maybe by voting for them, it will be fixed one day...
Yet another observation on the same issue.
For me the two projects where on the same parent folder, and were both local inside the workspace. Even then the issue was still happening.
The I edited the "project.properties" file and put the absolute path(with forward slashes '/' for seperator) of the library project. Saved and closed it. Then went to the project properties dialog, removed the library(which was still showing the cross icon but with abs path) and added it back as usual.
Surprisingly the issue is resolved, and the project compiles and runs.
This is really strange and must be a bug with the ADT.
I am using ADT version 20.0.2
when developer referencing the facebook or any other library project then first of all clean the project from eclipse->project->clean project.
that want allow the error of red cross in referencing screen.
For me, I just restart the eclipse and the added library works fine.
I mean first time it showing red marks after adding the library project.
Though eclipse main project and library project are in same workspace folder and no resources files are in outside of the project folder.
So, you can try with to restart your eclipse. Happy coding....
Workaround for me was to
Create a new workspace
Import Library Project in that workspace
Import The desired project in that workspace
Having both project and library project the same target Android OS version
Reference library project in my project
solved my problem
i had the same problem there when i try to change my workspace so this my solution:
import and copy all project data including library project into workspace
delete the old project reference by Right-click on the project-->Properties-->Android-->Library, and select corrupted library(so that waht i call it) and choose Remove
clean project first (to refresh ur project properties)
go to library project Properties-->Android-->Library and check the is library if it does'nt click Apply then OK
if the library project is library is already checked, first Unchecked it then Clean the library project after that do the Step 4 again
go to project that u want the library are in then Right-click on the project-->Properties-->Android-->Library, Add then choose the library project (it should be there) and click Apply then OK
if still doesn't appear clean the project once more time and that should do
Just restart your eclipse. It's solve my problem
When you have a look at the reference-path before and after, it comes from i.e. "C:/workspace/mylib" and goes to "../../mylib" when copied to the correct location, quite interesting.
FYI,
What worked for me was to delete the 'library' projects (the actual projects) from my workspace (without deleting the files), and then re-importing them using the wizard (import existing android project from source code).
Thanks for posting the question.
I had exactly the same problem while integrating Facebook with my Android application. I fixed the issue by moving my development project to the same Windows drive in which library project was located. Somehow Eclipse is unable to read the library project's location properly from default.properties file if it is in a different drive.
Similar to Sufi Khan's post I also solved this issue with a reboot. My case differed in that when I first accessed Properties->Android and added the library I got a lovely green checkmark. When I closed the dialog Eclipse was still showing class-not-found type errors. When I checked the properties again I saw the red X. But Mr. Kahn's solution (delete the bad lib, restart Eclipse, add the lib again) worked fine.
I'm using the 0702 version of the ADT bundle (starts with "cluster", rhymes with "duck").
I followed the accepted answer but also had to make sure my "project.properties" file was readable.
If the file is readonly (checked into source control) eclipse will not edit it. Adding the library reference will succeed, but the change won't be persisted after hitting OK.
If closing the preferences window and reopening in again removes the library you just added, this may be your solution.
In case your library project still doesn't show up try adding library flag in your library project properties
Add android.library=true
project.properties
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-17
android.library=true

Categories

Resources