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?

Kurosawa Hiroyuki
  • 1,217
  • 2
  • 14
  • 22

3 Answers3

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
Purplemonkey
  • 1,927
  • 3
  • 27
  • 39
Akram
  • 7,548
  • 8
  • 45
  • 72
  • 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 Mar 25 '12 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 Mar 25 '12 at 19:07
  • post some screen shot of expanded libs folder and expanded refreced libraries folder – Akram Mar 26 '12 at 02:39
  • 2
    @worked Try to close your project, then re-open it. You should see the new "Android Dependencies" reference folder. – Tri Bui Mar 28 '12 at 03: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 :) – AndroidNoob Apr 05 '12 at 09:53
  • Didn't work? Restart your eclipse workspace! and I'm not kidding. – Reza Mohammadi Jul 14 '12 at 17:24
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.

Pelanes
  • 3,451
  • 1
  • 34
  • 32
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

user756427
  • 31
  • 2