Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoClassDefFoundError: com.google.ads.AdView

I am attempting to incorporate admob ads in my app. So far I have added the following code in the onCreate method of my app's main activity...

    adView = new AdView(this,AdSize.BANNER,"my code number");
    adView.loadAd(new AdRequest());

The program compiles without error but at run time I get the message java.lang.NoClassDefFoundError: com.google.ads.AdView. I have seen a supposed explanation of the problem and the cure here but I could not see how it was applicable to my project because I do not have either a "lib" or "libs" directory within my project.

According to eclipse's SDK manager, I have the most up to date version of everything that I use.

like image 799
Mick Avatar asked Apr 27 '12 15:04

Mick


3 Answers

I had a similar problem, but did not have to add the libs folder; I tried, with no success, then removed them afterwards, when I realized that I had just forgotten to export the included Jar archived.

Fix:
Select project settings > Java Build Path, then Order and export.

Here, check the GoogleAdMobAdsSdk-package.

This should solve the NoClassDefFoundError-issue.

like image 94
Kjartan Avatar answered Nov 11 '22 10:11

Kjartan


Just create manually the "libs" folder, and add your libraries there. By default, they doesn't exist

like image 38
Yotes Avatar answered Nov 11 '22 09:11

Yotes


  1. Project-> Clean
  2. Project settings -> Java Build Path. Open "Order and export" tab.
  3. Check GoogleAdMobsAdsSDK.

It is worked for me.

like image 13
N3CAT1 Avatar answered Nov 11 '22 11:11

N3CAT1