我刚刚将AdMob添加到了我的应用中。当我调试或安装发布版本的应用程序(HTC m7)时,一切似乎都运行良好。问题出现在CHUWI VX2设备上(esky82_tb_cn_kk,Android 4.4)。这很奇怪,因为在这个设备上我的应用程序在调试模式下工作,但在发布版本中不起作用。我尝试转向葫芦,但它对我没有帮助。
有人对此有所了解吗?
我的清单
我的onCreate方法中的指令:
mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
super.onAdClosed();
mAdView.setVisibility(View.GONE);
}
@Override
public void onAdOpened() {
super.onAdOpened();
mAdView.startAnimation(fade_in);
mAdView.setVisibility(View.VISIBLE);
}
@Override
public void onAdFailedToLoad(int errorCode) {
super.onAdFailedToLoad(errorCode);
mAdView.setVisibility(View.GONE);
}
@Override
public void onAdLoaded() {
super.onAdLoaded();
mAdView.startAnimation(fade_in);
mAdView.setVisibility(View.VISIBLE);
}
@Override
public void onAdLeftApplication() {
super.onAdLeftApplication();
mAdView.setVisibility(View.GONE);
}
});
mAdView.loadAd(adRequest);
layout.xml内的代码
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.google.android.gms.ads.AdView android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/banner_ad_unit_id"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:visibility="gone">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
崩溃日志:
05-01 19:39:16.305 124-124/? I/SurfaceFlinger﹕ Skip composition for [Built-in Screen (type:0)] since dirtyRegion is empty
05-01 19:39:16.321 124-124/? I/SurfaceFlinger﹕ Skip composition for [Built-in Screen (type:0)] since dirtyRegion is empty
05-01 19:39:16.330 2162-2162/? D/AndroidRuntime﹕ Shutting down VM
05-01 19:39:16.330 2162-2162/? W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41d79c98)
05-01 19:39:16.330 2162-2162/? W/dalvikvm﹕ threadid=1: uncaught exception occurred
05-01 19:39:16.331 2162-2162/? W/System.err﹕ java.lang.RuntimeException: Unable to start activity ComponentInfo{freshfrog.pytomat/freshfrog.pytomat.Main}: java.lang.NullPointerException
05-01 19:39:16.332 2162-2162/? W/System.err﹕ at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
05-01 19:39:16.332 2162-2162/? W/System.err﹕ at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
05-01 19:39:16.332 2162-2162/? W/System.err﹕ at android.app.ActivityThread.access$800(ActivityThread.java:151)
05-01 19:39:16.332 2162-2162/? W/System.err﹕ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
05-01 19:39:16.332 2162-2162/? W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:110)
05-01 19:39:16.332 2162-2162/? W/System.err﹕ at android.os.Looper.loop(Looper.java:193)
05-01 19:39:16.333 2162-2162/? W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5292)
05-01 19:39:16.333 2162-2162/? W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
05-01 19:39:16.333 2162-2162/? W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:515)
05-01 19:39:16.333 2162-2162/? W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
05-01 19:39:16.333 2162-2162/? W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
05-01 19:39:16.333 2162-2162/? W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
05-01 19:39:16.334 2162-2162/? W/System.err﹕ Caused by: java.lang.NullPointerException
05-01 19:39:16.334 2162-2162/? W/System.err﹕ at freshfrog.pytomat.Main.onCreate(Main.java:450)
05-01 19:39:16.334 2162-2162/? W/System.err﹕ at android.app.Activity.performCreate(Activity.java:5264)
05-01 19:39:16.334 2162-2162/? W/System.err﹕ at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
05-01 19:39:16.334 2162-2162/? W/System.err﹕ at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
05-01 19:39:16.335 2162-2162/? W/System.err﹕ ... 11 more
05-01 19:39:16.335 2162-2162/? W/dalvikvm﹕ threadid=1: calling UncaughtExceptionHandler
05-01 19:39:16.336 124-124/? I/SurfaceFlinger﹕ Skip composition for [Built-in Screen (type:0)] since dirtyRegion is empty
05-01 19:39:16.339 2162-2162/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: freshfrog.pytomat, PID: 2162
java.lang.RuntimeException: Unable to start activity ComponentInfo{freshfrog.pytomat/freshfrog.pytomat.Main}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at freshfrog.pytomat.Main.onCreate(Main.java:450)
at android.app.Activity.performCreate(Activity.java:5264)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
05-01 19:39:16.341 654-669/? V/Provider/Settings﹕ from settings cache , name = dropbox:data_app_crash , value = null
05-01 19:39:16.342 654-669/? D/dalvikvm﹕ create interp thread : stack size=128KB
05-01 19:39:16.342 654-669/? D/dalvikvm﹕ create new thread
05-01 19:39:16.343 654-669/? D/dalvikvm﹕ new thread created
05-01 19:39:16.343 654-669/? D/dalvikvm﹕ update thread list
05-01 19:39:16.343 916-2188/? D/dalvikvm﹕ create interp thread : stack size=128KB
05-01 19:39:16.343 916-2188/? D/dalvikvm﹕ create new thread
05-01 19:39:16.343 916-2188/? D/dalvikvm﹕ new thread created
05-01 19:39:16.343 916-2188/? D/dalvikvm﹕ update thread list
05-01 19:39:16.343 654-2191/? D/dalvikvm﹕ threadid=82: interp stack at 0x64403000
05-01 19:39:16.343 654-2191/? D/dalvikvm﹕ threadid=82: created from interp
05-01 19:39:16.343 654-669/? D/dalvikvm﹕ start new thread
05-01 19:39:16.343 654-669/? V/Provider/Settings﹕ from settings cache , name = send_action_app_error , value = 1
05-01 19:39:16.343 654-669/? W/ActivityManager﹕ Force finishing activity freshfrog.pytomat/.Main
Logcat表示此行(Main.java:450)
mAdView.setAdListener(new AdListener() {
答案 0 :(得分:2)
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
你期待什么?击中双方?
试试这个
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
然后让其余的去吧
答案 1 :(得分:0)
我解决了我的问题。此问题未与AdView连接。这是项目的问题。我犯了小错误。我没有这条线
<?xml version="1.0" encoding="utf-8"?>
在xml布局文件的开头。我不知道它是如何运作的。
然后我的apk开始工作而没有progourd但是当我启用此功能时崩溃。所以我找到this solution