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" />

最佳答案

确保在属性-> Java构建路径->订单和导出中选中.jar文件。

09-27 08:48