Hi everyone I have problems with admob-free plugin. I executed these command in a ionic 4 project:
ionic start myapp sidemenu
ionic capacitor add android
ionic cordova plugin add cordova-plugin-admob-free --save --variable ADMOB_APP_ID="myadmobid"
npm install @ionic-native/admob-free
Ionic capacitor sync android
ionic capacitor run android
when I test the program on my device android studio shows the next error and the app stop.
FATAL EXCEPTION: main
Process: com.danieltrevino.myapp, PID: 29617
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzur;
at com.google.android.gms.ads.BaseAdView.<init>(Unknown Source:3)
at com.google.android.gms.ads.AdView.<init>(Unknown Source:1)
at name.ratson.cordova.admob.banner.BannerExecutor$1.run(BannerExecutor.java:70)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:280)
at android.app.ActivityThread.main(ActivityThread.java:6706)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: com.google.android.gms.internal.zzur
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312
I read that the problem could be about google play services versions
android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android/capacitor-cordova-android-plugins/build.gradle
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
google()
jcenter()
mavenCentral()
flatDir{
dirs 'src/main/libs', 'libs'
}
}
dependencies {
implementation fileTree(dir: 'src/main/libs', include: ['*.jar'])
implementation 'org.apache.cordova:framework:7.0.0'
// SUB-PROJECT DEPENDENCIES START
implementation "com.google.android.gms:play-services-base:11.0.4"
implementation "com.google.android.gms:play-services-ads:11.0.4"
// SUB-PROJECT DEPENDENCIES END
}
// PLUGIN GRADLE EXTENSIONS START
apply from: "cordova.variables.gradle"
// PLUGIN GRADLE EXTENSIONS END
for (def func : cdvPluginPostBuildExtras) {
func()
}
I am following the next tutorial , do you know some solution for this?