23

I'm tring to use com.google.android.apps.analytics.GoogleAnalyticsTracker but got NoClassDefFoundError when

GoogleAnalyticsTracker.getInstance();

I'm sure that libGoogleAnalytics.jar is included in the Build Path and the code was successfully built.

that code worked perfectly before that I suspect that the error occur after I updated the ADT to the latest but no clue.

Could anybody give any suggestions on this?

2

3 Answers 3

53

Actually this is the problem we are facing with ADT 17 you have to put your jar file into libs folder in order to overcome this exception

so right click on your project -->create a folder with name libs

and follow this step in

 right click (on libs folder) -->import-->File System-->browse to select your jar file and hit finish and run you project.

after that

 right click on the project --> Built Path-->java built path-->add jars select your jar file from your libs folder
6
  • I've placed the jar into a libs folder, following your instructions, and it still throws the error. Little help? 03-25 14:12:09.914: E/AndroidRuntime(1040): java.lang.NoClassDefFoundError: com.google.android.apps.analytics.GoogleAnalyticsTracker
    – worked
    Commented Mar 25, 2012 at 18:14
  • 1
    Still not working. The project in question was dropped in my lap. It already has a libs folder with the jar file needed to run. However, I get the red exclamation mark on the project folder from the get go. If I follow your instructions, it removes the exclamation mark, yet continue to receive the error:03-25 15:04:50.292: E/AndroidRuntime(293): java.lang.NoClassDefFoundError: com.google.android.apps.analytics.GoogleAnalyticsTracker
    – worked
    Commented Mar 25, 2012 at 19:07
  • post some screen shot of expanded libs folder and expanded refreced libraries folder
    – Akram
    Commented Mar 26, 2012 at 2:39
  • 2
    @worked Try to close your project, then re-open it. You should see the new "Android Dependencies" reference folder.
    – Tri Bui
    Commented Mar 28, 2012 at 3:57
  • 7
    Worked for me too! Had a folder called 'lib' with the jars in, right clicked on the folder went to 'Refactor->Rename', renamed to 'libs', now works fine :) Commented Apr 5, 2012 at 9:53
8

To solve the problem with the error NoClassdefFoundError when you are using the Google Analytics v2beta library, you need to mark this library as "exported".

How?

  • Add your library: Project -> Properties -> Java Build Path -> Libraries -> Add External JARs...
  • Then go to "Order and Export" in the same window, and mark this library as "exported" with the checkbox.

Your proyect will now find the Analytics class when you run it!

More details and why this happen here.

0
0

Besides renaming the library folder to libs and removing the Google Analytics library from the Build Path I had to also add the following to the .classpath file:

<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>

Otherwise the new Android Dependencies reference folder would not show up. Also, closing and re-opening the project helped.

Also found more explanation here:

http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.