我是 Android 开发的初学者。我刚刚发布了一个应用程序,但发现了一些故障,所以我想通过创建一个与已发布应用程序包名称相同的新 Android 项目来纠正这些故障。但是一旦我完成了更新应用程序,这个应用程序就没有在手机上运行(调试)。说“不幸的是,这个应用程序已停止。” 这次我也尝试加入 adMob。
请帮助我,因为我必须尽快发布此内容。
这是应用程序崩溃后的 Logcat:
08-11 18:14:31.063: E/dalvikvm(15877): Could not find class 'com.google.ads.AdView', referenced from method com.gamerspitch.easybluetooth.BlueActivity.initAdView
08-11 18:14:31.254: E/AndroidRuntime(15877): FATAL EXCEPTION: main
08-11 18:14:31.254: E/AndroidRuntime(15877): java.lang.NoClassDefFoundError: com.google.ads.AdView
08-11 18:14:31.254: E/AndroidRuntime(15877): at com.gamerspitch.easybluetooth.BlueActivity.initAdView(BlueActivity.java:107)
08-11 18:14:31.254: E/AndroidRuntime(15877): at com.gamerspitch.easybluetooth.BlueActivity.onCreate(BlueActivity.java:40)
08-11 18:14:31.254: E/AndroidRuntime(15877): at android.app.Activity.performCreate(Activity.java:5133)
08-11 18:14:31.254: E/AndroidRuntime(15877): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-11 18:14:31.254: E/AndroidRuntime(15877): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
08-11 18:14:31.254: E/AndroidRuntime(15877): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-11 18:14:31.254: E/AndroidRuntime(15877): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-11 18:14:31.254: E/AndroidRuntime(15877): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-11 18:14:31.254: E/AndroidRuntime(15877): at android.os.Handler.dispatchMessage(Handler.java:99)
08-11 18:14:31.254: E/AndroidRuntime(15877): at android.os.Looper.loop(Looper.java:137)
08-11 18:14:31.254: E/AndroidRuntime(15877): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-11 18:14:31.254: E/AndroidRuntime(15877): at java.lang.reflect.Method.invokeNative(Native Method)
08-11 18:14:31.254: E/AndroidRuntime(15877): at java.lang.reflect.Method.invoke(Method.java:525)
08-11 18:14:31.254: E/AndroidRuntime(15877): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-11 18:14:31.254: E/AndroidRuntime(15877): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-11 18:14:31.254: E/AndroidRuntime(15877): at dalvik.system.NativeStart.main(Native Method)
这是我的 admob 展示位置的 XML。我只是按照此链接添加 admob。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/easyb"
tools:context=".BlueActivity" >
<LinearLayout
android:id="@+id/adviewPlaceholder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:orientation="vertical" >
</LinearLayout>
//Other elements
我已经把它放在我的清单文件中>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
</activity>
这在我的 Activity onCreate 方法中 >
private AdView ad;
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_blue);
initAdView();
//Other elements
protected void initAdView() {
ad = new AdView(this, AdSize.SMART_BANNER, "a15204b9eb97566");
LinearLayout ll = (LinearLayout)findViewById(R.id.adviewPlaceholder);
ll.addView(ad);
ad.loadAd(new AdRequest());
}
protected void destroyAdView() {
if(ad != null) ad.destroy();
}
@Override
protected void onDestroy() {
// destroy the ad when the activity is destroyed
destroyAdView();
super.onDestroy();
}
提前致谢