Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
351 views
in Technique[技术] by (71.8m points)

android - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...