I tried with the test with the 'App-id' and the 'Add Unit id' and the actual ids on signed APK. The add does not show up both times. I get this warn in logcat:
10-10 15:17:53.308 6601-7082/com.babygameseeepe.shreyak.babygames W/Ads: Invoke Firebase method getInstance error.
java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.measurement.AppMeasurement" on path: DexPathList[[zip file "/data/app/com.babygameseeepe.shreyak.babygames-1/base.apk"],nativeLibraryDirectories=[/data/app/com.babygameseeepe.shreyak.babygames-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.google.android.gms.ads.internal.scionintegration.b.a(:com.google.android.gms.DynamiteModulesA@11518438:167)
... 13 more
Here is my implementation:
protected void onCreate(Bundle savedInstanceState) {
--
--
MobileAds.initialize(this, "~My-App-Id~");
mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
In xml :
<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_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="~My-add-unit-id~">
</com.google.android.gms.ads.AdView>
Permissions:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Gradle (project level):
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Gradle (App level) :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.babygameseeepe.shreyak.babygames"
minSdkVersion 15
targetSdkVersion 25
versionCode 5
versionName "1.4.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-ads:11.4.0'
testCompile 'junit:junit:4.12'
}
I have followed this link to implement the add (without firebase). Please help.