将admob广告添加到main.xml会导致我的应用崩溃

时间:2012-03-30 08:32:51

标签: android admob android-xml

首先让我说这个应用程序在前一天工作正常。我重新启动了电脑,删除了项目并添加了项目的先前版本并且它一直在崩溃。如果我从main.xml中删除这个从mainactivity加载的应用程序不会崩溃。如果我在main.xml中有这个:

 <com.google.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="50dp"
            android:layout_alignParentBottom="true"
            ads:adSize="BANNER"
            ads:adUnitId="a14ee1ad68dcbdb"
            ads:loadAdOnCreate="true" />
该应用程序崩溃了。如果我运行应用程序并且此代码不在main.xml文件中,但在其他xml文件中,该应用程序正常工作,它将显示其他活动的添加。

我尝试删除xml文件中的所有代码,只是在上面添加了上面的admob,它仍然崩溃了。我在考虑卸载eclipse并再次安装它? 有任何想法吗????

以下是logcat中从头到尾的一切:

 03-30 11:39:17.215: D/AndroidRuntime(338): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-30 11:39:17.215: D/AndroidRuntime(338): CheckJNI is ON
03-30 11:39:17.335: D/AndroidRuntime(338): --- registering native functions ---
03-30 11:39:17.825: D/AndroidRuntime(338): Shutting down VM
03-30 11:39:17.825: D/dalvikvm(338): Debugger has detached; object registry had 1 entries
03-30 11:39:17.845: I/AndroidRuntime(338): NOTE: attach of thread 'Binder Thread #3' failed
03-30 11:39:18.215: D/AndroidRuntime(346): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-30 11:39:18.215: D/AndroidRuntime(346): CheckJNI is ON
03-30 11:39:18.345: D/AndroidRuntime(346): --- registering native functions ---
03-30 11:39:18.835: I/ActivityManager(59): Force stopping package com.petermihaylov.android.cardcounter uid=10040
03-30 11:39:18.835: I/Process(59): Sending signal. PID: 331 SIG: 9
03-30 11:39:18.896: I/UsageStats(59): Unexpected resume of com.android.launcher while already resumed in com.petermihaylov.android.cardcounter
03-30 11:39:18.905: W/InputManagerService(59): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@45094eb8
03-30 11:39:18.945: I/ActivityManager(59): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.petermihaylov.android.cardcounter/.MainActivity }
03-30 11:39:18.945: D/AndroidRuntime(346): Shutting down VM
03-30 11:39:18.955: D/jdwp(346): Got wake-up signal, bailing out of select
03-30 11:39:18.955: D/dalvikvm(346): Debugger has detached; object registry had 1 entries
03-30 11:39:19.039: I/AndroidRuntime(346): NOTE: attach of thread 'Binder Thread #3' failed
03-30 11:39:19.155: I/ActivityManager(59): Start proc com.petermihaylov.android.cardcounter for activity com.petermihaylov.android.cardcounter/.MainActivity: pid=353 uid=10040 gids={3003}
03-30 11:39:19.345: D/dalvikvm(33): GC_EXPLICIT freed 285 objects / 10864 bytes in 186ms
03-30 11:39:19.475: W/ActivityThread(353): Application com.petermihaylov.android.cardcounter is waiting for the debugger on port 8100...
03-30 11:39:19.525: I/System.out(353): Sending WAIT chunk
03-30 11:39:19.565: I/dalvikvm(353): Debugger is active
03-30 11:39:19.595: D/dalvikvm(33): GC_EXPLICIT freed 47 objects / 2056 bytes in 249ms
03-30 11:39:19.745: I/System.out(353): Debugger has connected
03-30 11:39:19.745: I/System.out(353): waiting for debugger to settle...
03-30 11:39:19.945: I/System.out(353): waiting for debugger to settle...
03-30 11:39:20.075: D/dalvikvm(33): GC_EXPLICIT freed 2 objects / 64 bytes in 422ms
03-30 11:39:20.207: I/System.out(353): waiting for debugger to settle...
03-30 11:39:20.405: I/System.out(353): waiting for debugger to settle...
03-30 11:39:20.605: I/System.out(353): waiting for debugger to settle...
03-30 11:39:20.823: I/System.out(353): waiting for debugger to settle...
03-30 11:39:21.025: I/System.out(353): waiting for debugger to settle...
03-30 11:39:21.225: I/System.out(353): waiting for debugger to settle...
03-30 11:39:21.468: I/System.out(353): waiting for debugger to settle...
03-30 11:39:21.677: I/System.out(353): debugger has settled (1469)
03-30 11:39:29.005: W/ActivityManager(59): Launch timeout has expired, giving up wake lock!
03-30 11:39:29.421: W/ActivityManager(59): Activity idle timeout for HistoryRecord{450bae78 com.petermihaylov.android.cardcounter/.MainActivity}

3 个答案:

答案 0 :(得分:1)

看起来你正在尝试调试应用程序,而且它正在调试中。如果你试图运行它,你会得到更多相关的日志吗?

此外,您是否有机会更新到Android工具的r17 ? r17的工具强制您将SDK放在项目的libs /文件夹中。

答案 1 :(得分:0)

您确定已正确完成教程并添加了权限并导入了SDK吗?

尝试从头开始逐步完成本指南: https://developers.google.com/mobile-ads-sdk/docs/android/fundamentals

在Eclipse中清理项目有时可以解决一些问题。

答案 2 :(得分:0)

在全新安装Eclipse后,我最近遇到了与Admob非常相似的奇怪问题。经过几个小时的调查,为什么,它最终成为我在项目偏好中的构建顺序。我将Google AdMob jar设置为顶部,清理项目并解决了我的所有问题。

您粘贴的logcat文本未提供任何错误信息。你可以从失败点粘贴logcat文本,通常你可以在这里看到与AdMob的通信。

可能有所帮助,只是一个想法。

New version of Android LED Clock just uploaded to the market

杰森