java.lang.ClassNotFoundException: Didn't find class com.google.android.gms.ads.MobileAdsInitProvider
You are getting this error because you have use multiDex but some implementation part is missing. Follow below steps to resolve the error.
1) Add "multiDexEnabled true" in defaultconfig in app-level gradle file
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
}
...
}
2) If your minSdkVersion is less than 21 then add below dependency.
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
3) Use MultiDexApplication class as Application class. There are three way to use MultiDexApplication as Application class
i) Just set MultiDexApplication class in AndroidManifest.xml file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>
ii) If you are already using custom application class then extent MultiDexApplication in custom application class
public class MyApplication extends MultiDexApplication { ... }
iii) If it is not possible to extend MultiDexApplication because you already extend other class and can not change it then use below method in your custom application class
public class MyApplication extends SomeOtherApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Note: I was facing same error and just solved by extending MultiDexApplication class
Android: Didn't find class com.google.android.gms.ads.AdActivity on path
Looks like problem has solved after updating Google Play Services lib to the latest version.
AdMob causing: unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.ClassNotFoundException
I got a similar error and this solved it.
In biuld.gradle (Module)
android {
...
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
Related Topics
Android Studio Cannot Resolve Symbol But Code Executes Correctly
How to Change the Text Color in a String to Multiple Colors in Java
Dynamic Listview in Android App
How to Get Timezone from Android Mobile
Android Telegram App --> Java.Lang.Unsatisfiedlinkerror: No Implementation Found for Void
Detecting State Changes Made to the Bluetoothadapter
Inside Onclicklistener I Cannot Access a Lot of Things - How to Approach
How to Specify the Jdk Version in Android Studio
Failed to Import New Gradle Project: Failed to Find Build Tools Revision *.0.0
How to Sort Alphabetically While Ignoring Case Sensitive
Android: How to Parse Url String with Spaces to Uri Object
Convert Utc to Current Locale Time
Android: How to Disable List Items on List Creation
Issue When Using a Custom Font - "Native Typeface Cannot Be Made"
Android - Copy Assets to Internal Storage