I'm setting up an Admon's ad to my activity in my Android app. But When I did all instructions , still get IllegalStateException
.
I searched for stackoverflow and Googled it. Here is the links :
Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException: Why?
React native Admob Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException: . By the way I have tried implementation com.google.firebase:firebase-ads:15.0.1
. But It worked on emulator but not real device. And I cannot see my ad on real device working. So that I am using implementation 'com.google.android.gms:play-services-ads:17.1.1'
. I did google docs what did it say :
Totally my xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true" />
<meta-data
android:name="com.google.android.gms.ads.AD_MANAGER_APP"
android:value="true"/>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-8855622609935813xxxxxxxxx"/>
<application
android:allowBackup="true"
android:icon="@drawable/logom"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".start" />
<activity android:name=".end_of_start" />
<activity android:name=".end_of_fail" />
<activity android:name=".last_level" />
<activity android:name=".tutorial"></activity>
</application>
</manifest>
My layout' s adview :
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-8855622609935813xxxxxxx">
</com.google.android.gms.ads.AdView>
MainActivity :
mAdView = findViewById(R.id.adView);
MobileAds.initialize(this, "ca-app-pub-8855622609935813xxxxxx");
AdView adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId("ca-app-pub-8855622609935813xxxxxxx");
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
Lastly my gradle:app's library : implementation 'com.google.android.gms:play-services-ads:17.1.1'
I want to work my app with Admob's ad. After that; I set my app to google play for other customers using.