Class not found exception on android - android

I get some soure from net. and import on my workspace. When i run on emulator, its throws,
"05-28 17:30:47.895: E/AndroidRuntime(840): java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.developmentmill.laserlogic/com.developmentmill.laserlogic.StageActivity}:
java.lang.ClassNotFoundException: com.developmentmill.laserlogic.StageActivity in
loader dalvik.system.PathClassLoader[/data/app/com.developmentmill.laserlogic-2.apk]"
But when i run the same code on my friend machine, its running without any error.
My eclipse ADT Version is 17.0 my friend eclipse ADT version is 16.0
I copy the jar files from lib folder to libs foder. and change the java build path from lib to libs folder. and also i cleaned the project.
Again, i run the project, the same error has been throw.
What is the problem and how to correct it? y its occur on my machine only. Pls help me.

I have also faced this problem.
so try this.
Right click on project -> goto properties -> Java buid path -> libraries -> remove all External Jars from here -> press OK
also remove all jars from libs folder
clean project -> restart eclipse.
Then again put all required jars in libs folder.
I have solved my problem by this
hope this will help you....

First create libs folder in your project and then add all jar file or library file used in project in libs folder and now run your project.
It will definitely run.

What worked for me was:
I already had a libs folder in the same hierarchy as my src & res folders.
The FlurryAgent.jar file was saved on my Desktop. I simply right clicked on the FlurryAgent file, copied it. Then I pasted the file into the libs folder in Eclipse.
Eclipse automatically copied the FlurryAgent.jar file into the “Android Dependencies” folder also.

Related

For Android Map api v2 Description references non existing library google-play-services_lib\bin\google-play-services_lib.jar

I have import google-play-services_lib into my workspace and Add google project into MYProject it give mr error:
Description Resource Path Location Type
The container 'Android Dependencies' references non existing library 'D:\Android
Workspace\google-play-services_lib\bin\google-play-services_lib.jar' HBuddy Build
path Build Path Problem
Description Resource Path Location Type The project cannot be built
until build path errors are resolved HBuddy Unknown Java Problem
and I have already installed Google Play Service in Extras
I met this issue as well.
My solution is,
clean project google-play-services_lib firstly
then clean my project which depends on play service library
Hey i know what your problem is. I think it seems like you didn't built your google-play-services project... Try the following solution:
Import the google-play-services_lib "project" into your workspace
Add the freshly imported project to your applications build path
RIGHT-CLICK the google-play-services_lib project and select "Build Project"
Wait a few moments or "clean up" your project
Run your application and - Voila -
Please uncheck "Is Library" as follows ;
Your bin folder doesn't exist! You probably don't have permission to create a folder.
If you create a project from existing code make sure you check "Copy projects into workspace".
I found that the reference is looking at the wrong folder. It normally looks in <android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/bin/ for the jar file and the file is actually inside the <android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/libs folder. I couldn't find a way to change the reference link, so I just copied the jar file and the matching jar properties file from the /libs folder to the /bin folder.
I hope it helps.
My solution is,
clean project google-play-services_lib firstly
then clean my project which depends on play service library
There is another way to resolve this issue. Import google_play_services_lib project to your work space.
android-sdk/extras/google/google_play_services/libproject/google-play-services_lib
Then add the google-play-services.jar file externally.
right click on your_project -> properties ->java build path -> Libraries -> add External JARs -> select google-play-services.jar from work space ->clean ->build
It works for me.
I was facing the same issue and got it solved when I updated my eclipse Android SDK tools.
I was using version 22 and when I updated Android SDK tools to 22.0.1 the error vanished and I could build my project.
I hope this helps someone...
Check Read Only property of the Project folder.
If its checked, uncheck it and then try.

eclipse, set up android application

I'm studying this tutorial now:
http://www.ibm.com/developerworks/opensource/tutorials/os-eclipse-android/
I got an error says "project contains error" when running the code. But I didn't find any error mark in my project. What happened? Thank you very much!
Right Click in your project - Properties - Java Build Path - and then you will see the error, so you just have to delete the error and then clean your project
There is an R.java file in your src directory, and while it used to go there in previous versions (as I just learned), it doesn't belong there any more.
That file is generated by the platform, not you, and should appear in the gen directory.
The copy in your src directory is probably interfering with the real R.java file in your gen directory. Remove the file from src and Eclipse will be happier.

Eclipse Android gen already exists but is not a source folder

I am getting the following errors when I try to load an Android project in Eclipse that was working just fine last week.
Any ideas?
[2012-03-16 09:29:43 - MyProject] /MyProjectName/gen already exists but is not a source folder. Convert to a source folder or rename it
Note that I have tried to clean the project several times, even restarted but it still gives me this errors.
right click on project and go to project properties, then goto java build path, and then in source tab, click on add folder button and add gen folder.
just src and gen folders should be checked there if you haven't any library projects attached.
MyProject] /MyProjectName/gen already exists but is not a source folder. Convert to a source folder or rename it
This problem happens when eclipse does not able to find each linked contents in a project.
For example:
When we import a project to eclipse from a specific folder(suppose D://NewFolder), eclipse memorized and link each content with its appropriate path (which is D://NewFolder/project_library/src in our example).
But if we replaced(Here D://NewFolder To E://Another_Folder) or delete the library from its specific folder(Here D://NewFolder), eclipse unable to find its(project_library) original path
and give red error.
So when this problem happens, first we have to make sure that the imported project or library is its original folder and no changes has made to this.
Otherwise again replace the project to its specific folder to which eclipse has linked at the time of import i.e parent folder.
This happens because your .classpath file got wiped out somehow. This file contains all the information from the Java Build Path tab under Project Properties. You could add in all information manually but there's an easier way of fixing this problem.
If you have a copy of the .classpath file on your machine, you can just copy and paste it into your project directory.
Follow these steps in Eclipse :
Project -> Properties -> Select Java Build Path ->
Open Source tab -> Click Add Folder and check the gen

Eclipse - ACRA jar file not recognised

I'm trying to add ACRA to my project and I've followed these steps ACRA Basic Setup but Eclipse is not recognising the #ReportCrashes that it has you create with the class:
I made sure I created a "lib" folder and I added the jar file to it (by drag & drop from a windows explorer), I then right-clicked it and choose Add to Build Path. I even tried to remove the jar file and re-add it and do a Project --> Clean but still nothing.
Any ideas as to what I'm doing wrong?
Here's some screenshots of the Annotations from Eclipse:
I've had the same problem, and I think I've discovered the root of it: I was importing the jar inside SRC folder, instead of importing the one in BUILD folder. Just deleted the first one, reconfigured BUILDPATH to remove the wrong entry, did a clean, copied the right (BUILD FOLDER) jar into the libs folder in my project and then everything went OK
Maybe it helps?
OK I figured out the problem. I had the same issue as you and the problem for me was that I added the source jar and not the build jar from the ACRA archive. It now recognizes the classes from the jar. Rookie mistake :)
Robert,
I updated to R20 of the Android SDK Tools today (Aug 15, 2012) and also upgraded to Eclipse Juno and had similar problems with ACRA and my other jar files.
The way I understand it R17 change the build process that any jar in the '/libs' folder is automatically added to the build path. Which means if you had a jar in the '/libs' folder you need to remove it from you java build path or you get the dreaded "Dalvik 1" build error.
Next, I noticed there is no way to add source or javadoc to jars in the lib folder. So I moved all my jars to a second folder, in my case '/external/jar'. When I moved ACRA-4.2.3.jar to '/external/jar' my project would crash with the same error as yours. So I moved it back to '/libs' and it worked, although I could not add javadoc or source to the ACRA jar.
The conclusion is to place the ACRA jar file in the '/libs' folder. Other jar files may be placed in '/libs' or elsewhere. Also, update Android SDK and Eclipse.
Hope this helps you are somebody,
Fish

Why can't android find com.google.gson.Gson

I'm trying to use GSON in my project, but my application is crashing, with logcat saying that com.google.gson.Gson cannot be found. I've put import com.google.gson.Gson on my class files, I have gson in my package explorer, and added it by Right click -> build path -> add libraries. It also shows up in Project->properties->java build path->libraries tab->gson. What have I done wrong?
What worked for me: Check the checkbox next to the lib (gson-2.0.jar) in: 'Project Properties' -> 'Java Build Path' -> 'Order and Export' tab. Then do a clean/build.
This adds the exported=true attribute to the classpath entry
<classpathentry exported="true" kind="lib" path="libs/gson-2.0.jar"/>
Have you put the jar file in the libs folder of the project? If not , try moving it there, creating the folder if required. Should be at the same level as the src folder.
I had a similar issue trying to get an app built and that solved it.
I'm using IntelliJ, not eclipse but here is how I did it:
Download the source files from https://google-gson.googlecode.com/files/google-gson-2.2.4-release.zip
Unpack them
Copy them into the "libs" folder of your project. I did this manually by using the terminal but you can do it by going in your project folder located in your computer. Your Project_Name >app >Libs [paste them here]
Go to your editor (IntelliJ in my case) You should see the the following 3 files in the libs folder of the project structure:
gson-2.2.4.jar
gson-2.2.4-javadoc.jar
gson-2.2.4-sources.jar
Open your build.gradle file and insert the following line in the dependencies section:
compile files('libs/gson-2.2.4.jar', 'libs/gson-2.2.4-javadoc.jar', 'libs/gson-2.2.4-javadoc.jar')
Right click on each of the source files and select "Add as Library..."
Use the following options:
Name: name of the jar file
Level: Project Library
Add to Module: select project your adding to
Rebuild project
Build > Rebuild project
Import and use it!
import com.google.gson.Gson;
I have observed today that it doesn't like when you add your library.
The solution that worked for me was to add it as an external jar only. I have observed it by doing the steps described by author of this post i.e. Properties -> Java Build Path -> Libraries -> Add External JARs and point to the downloaded gson library.
I ran into the same issue (when installed SDK 17) ...
The solution is, that you just put the pure jar files into the "libs" folder (without subfolders).
You also don't need to declare them, android wil find them itself. You may need to do a Project > Clean
I had similar problem, but I guess my requirement was more complicated as the GSON libarary was used by an Android Library Project that my main Android project depended on. I have tried both approaches above but none of them worked for me. If I add the GSON jar file directly to the main Android project it works, but that is not what I wanted.
With a bit of investigation I have realised that the GSON jar does not use any dependencies (third party libraries) itself. So my solution was to copy the source file of the GSON project to my Android Library project's src filder and it worked like a charm. so you can use the Source code rather then the binary code. The source code is part of the download in a jar file, just unzip it.
i'm sure you have copied the jar into "libs",
and also added property> Java Build Path >(tab) Libraries, right?
my issue was stupid...
please check other than Gson jar, if you have two stuffs at least in above tab:
android x.x
Android Dependencies (especially this one, i missed this, eclipse show me an error of "could not find class com.google.gson.xx" )
simply do a project copy will solve this problem...
Do not edit .classpath file directly or even put files into lib folders out of Eclipse.
Instead use the Java Build Path->Order and Export tab to select libraries to be exported in the final deployment unit (eg war/apk)
To be on safer side, do a Project->Clean after you change the build path.
I faced the same thing.But the solution was quite easy,just Right-Click on your project->Properies->Libraries->Add external jars->OK and thats it.It solved my problem.hope it will solve yours as well
If Projct Properties -> Java build path -> Add external jars doesn't work and your project is a web project, try adding the gson jar directly to the server lib folder. Example: for apache Tomcat to apache-tomcat/lib.
I have been trying the same thing and read so many answers and tried so many things but to not vial, but i solved this problem by doing just one click and its simple.
1) Add your .jar file in libs folder make sure its libs not lib
2) Clean and Build your project you will see that file under libs folder
3) right click the file and go to build path and select add to build path
Run your project it will work fine. Hope this helps
I am using Android Studio
I had the same problem I had solve it by
select project press f4 from popup
click app and in dependencies
select file dependency and select the three folders which I had pasted in lib directory

Categories

Resources