adMob工作正常,直到我将eclipse更新到最新版本,现在启动时报告错误,java.lang.NoClassDefFoundError:com.google.ads.AdRequest。但adMob库附加到项目!!谢谢。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR); // Emulator
adRequest.addTestDevice("3xxxxxxxxxx");
AdView adView = new AdView(this, AdSize.BANNER, "axxxxxxxxxx");
LinearLayout layout = (LinearLayout)findViewById(R.id.mainLayout);
layout.addView(adView);
adView.loadAd(new AdRequest());
}
以及对清单
的正确引用和权限 <activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
答案 0 :(得分:6)
确保在属性中选中.jar文件 - &gt; Java构建路径 - &gt;订单和出口。