Ivan Alvarez
Ivan Alvarez

Reputation: 3

AdMob MobileAds.initialize is crashing the app for some users

Ive implemented Admob and it works for most of my users, I was able to replicate the error on a real device motorola z2 play with the following reason: (Ads are showing in most of the devices. I was able to replicated in 1 out of 6 devices.)

E/linker: normalize_path - invalid input: "null", the input path should be absolute
W/linker: Warning: unable to normalize "null"
A/zygote: java_vm_ext.cc:523] JNI DETECTED ERROR IN APPLICATION: GetStringUTFChars received NULL jstring
    java_vm_ext.cc:523]     in call to GetStringUTFChars
    java_vm_ext.cc:523]     from int android.webkit.WebViewFactory.nativeLoadWithRelroFile(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.ClassLoader)
    java_vm_ext.cc:523] "main" prio=5 tid=1 Runnable
    java_vm_ext.cc:523]   | group="main" sCount=0 dsCount=0 flags=0 obj=0x733a35e0 self=0xaca04000
    java_vm_ext.cc:523]   | sysTid=10829 nice=-10 cgrp=default sched=0/0 handle=0xb04fa4a8
    java_vm_ext.cc:523]   | state=R schedstat=( 525658304 61963121 522 ) utm=43 stm=8 core=5 HZ=100
    java_vm_ext.cc:523]   | stack=0xbe595000-0xbe597000 stackSize=8MB
    java_vm_ext.cc:523]   | held mutexes= "mutator lock"(shared held)

this is how I initialize Admob on startup

public class AppName extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
            MobileAds.initialize(AppName.this, new OnInitializationCompleteListener() {
                @Override
                public void onInitializationComplete(InitializationStatus initializationStatus) {
                }
            });

    }


}

And my manifest file

 <application

        android:name=".AppName"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme.NoActionBar">

also included the following permissions

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

I followed admob documentation.

Can someone please help me solve this problem.

Thanks in advance

Upvotes: 0

Views: 1101

Answers (2)

Amirhossein
Amirhossein

Reputation: 329

You should initialize MobileAds in your Application class. Not in your Activity class. Create a new class called Application. And add this to application tag in your manifest.

 android:name=".Application"

Upvotes: 0

Make sure you add this line in your Manifest :

 <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>

And just initialize it as the following, and make sure you call it only once per application launch

MobileAds.initialize(this, "ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy");

Upvotes: 1

Related Questions