Unfortunately Application has stopped while launching google maps Activity - android

I am trying to create an application using google app activity .I have just followed the steps to create a google map application using Google maps activity and not added any extra code. The application gets crashed while launching it.I have given my manifests file, builde.gradle(app) and logcat below.
Here is my Manifest File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ranjit.getlocation">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyDd-cGnR0SwDXXDRQPqnTDpBTQ" />
<activity
android:name=".MapsActivity"
android:label="#string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
below is the build.gradle(app) file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.ranjit.getlocation"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
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.1.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.android.gms:play-services:10.0.1'
testCompile 'junit:junit:4.12'
}
logcat of the application is below
08-12 10:50:02.947 15439-15439/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ranjit.getlocation, PID: 15439
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.example.ranjit.getlocation-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.ranjit.getlocation-1, /vendor/lib, /system/lib, /system/lib/arm]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5029)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4621)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4561)
at android.app.ActivityThread.access$1500(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.example.ranjit.getlocation-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.ranjit.getlocation-1, /vendor/lib, /system/lib, /system/lib/arm]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.installProvider(ActivityThread.java:5014)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4621) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4561) 
at android.app.ActivityThread.access$1500(ActivityThread.java:139) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:149) 
at android.app.ActivityThread.main(ActivityThread.java:5257) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) 
at dalvik.system.NativeStart.main(Native Method) 

You have to include multiDex in your application. In your manifest, you have not included the MulitiDexApplication.
ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList
Add this to your dependencies.
compile 'com.android.support:multidex:1.0.1'
In your Gradle add multiDexEnabled true.
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true // add this line
}
...
}
In your manifest add multiDex application class.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>
Avoid including complete play service (compile 'com.google.android.gms:play-services:10.0.1') library. instead, use particular library you need.
Inclued this dependency for map.
com.google.android.gms:play-services-maps:11.0.4

Related

java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider

When i trying to run my project this error showing
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.kishankalola.earnbyspin, PID: 11122
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.kishankalola.earnbyspin-1/base.apk"],nativeLibraryDirectories=[/data/app/com.kishankalola.earnbyspin-1/lib/arm64, /system/lib64, /vendor/lib64, /system/vendor/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:6054)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5611)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5550)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1628)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6328)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1076)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:937)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.kishankalola.earnbyspin-1/base.apk"],nativeLibraryDirectories=[/data/app/com.kishankalola.earnbyspin-1/lib/arm64, /system/lib64, /vendor/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.ActivityThread.installProvider(ActivityThread.java:6039)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5611) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5550) 
at android.app.ActivityThread.-wrap2(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1628) 
at android.os.Handler.dispatchMessage(Handler.java:110) 
at android.os.Looper.loop(Looper.java:203) 
at android.app.ActivityThread.main(ActivityThread.java:6328) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1076) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:937) 
app level gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.kishankalola.earnbyspin"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'
project level gradle file
// 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.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Android Menifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kishankalola.earnbyspin">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
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">
<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=".LoginActivity" />
<activity android:name=".RegisterActivity" />
<activity android:name=".SetupActivity" />
<activity android:name=".ForgotePassword" />
<activity android:name=".RedeemActivity" />
<activity android:name=".PaypalActivity" />
<activity android:name=".PaytmActivity"/>
</application>

Upgrade to studio 3.0 is crashing my app with dalvik.system.BaseDexClassLoader.findClass

This is just happening after a migration from studio 2.x to studio 3.0 with android 4.4. Android 6 runs fine.
I googled this issue but didn't find crisp response. Just a particular app has this behavior. I have other apps which are fine.
The update process has broken something but what? Why is it impacting android 4.x only?
I tried clean sync, rebuild,restart studio, restart tablet, ...
here is my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.narb.test"
minSdkVersion 18
targetSdkVersion 24
versionName '3.2'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionNameSuffix '-9-nov-2017'
multiDexEnabled true
versionCode 53
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/commons-net-3.5.jar')
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.google.android.gms:play-services-maps:10.0.1'
testCompile 'junit:junit:4.12'
compile 'org.jsoup:jsoup:1.10.3'
}
and the logcat:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.narb.test/com.narb.test.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.narb.test.MainActivity" on path: DexPathList[[zip file "/data/app/com.narb.test-29.apk"],nativeLibraryDirectories=[/data/app-lib/com.narb.test-29, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)
at android.app.ActivityThread.access$900(ActivityThread.java:174)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5593)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.narb.test.MainActivity" on path: DexPathList[[zip file "/data/app/com.narb.test-29.apk"],nativeLibraryDirectories=[/data/app-lib/com.narb.test-29, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2296)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470) 
at android.app.ActivityThread.access$900(ActivityThread.java:174) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5593) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method) 
and the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.narb.test">
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application
android:allowBackup="true"
android:largeHeap="true"
android:configChanges="keyboardHidden|screenSize"
android:icon="#drawable/networksafe"
android:label="test"
android:logo="#drawable/networksafe"
android:screenOrientation="portrait"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".vpn.services"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BIND_VPN_SERVICE">
<intent-filter>
<action android:name="android.Net.Services"/>
</intent-filter>
</service>
<activity
android:name=".Activities.Settings"
android:windowSoftInputMode="stateHidden" />
<activity android:name=".Activities.About" />
<activity android:name=".Activities.History" />
<service
android:name=".Socket"
android:exported="false" />
<service
android:name=".ServiceMonitoring"
android:exported="false" />
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
<activity android:name=".Activities.RateMe"></activity>
</application>
</manifest>
Run the Gradle clean command then do the File -> Invalidate caches & restart. For me it solves the problem
The crash was due to this line in build.gradle:
multiDexEnabled true
Once I removed this line the crash was gone.
I don't know why 2.3 has put this line originally but what is sure is that studio 3.0 made sdk 18 and below crash.
In your case, if you don't need multidex, then disabling it is the right solution. If you need it in the future, follow the instructions linked below to use the MultiDexApplication.
For context, there are two types of multidex, legacy and native. For devices API 21 and above, the platform just reads multiple dex files directly from the APK.
For devices before API 21, there is the multidex support library that patches the classloader to add in the extra dex files as part of an Application class. Anything that can be loaded before this happens needs to be in the main dex, and you need to use MultiDexApplication (or a subclass, or call MultiDex.install(this) from your Application onAtttachBaseContext)
Android studio 3.0 switched to creating the minimal main dex for debug builds, that is, only keeping the smallest set of files in the main dex. This is for build performance and to make these crashes reproducible, rather than it being luck if a class was included in the main dex or not.
In your case, your app fit in one dex in 2.3, but in 3.0 with the new minimal main dex behavior, that class was not in the main dex. However because you are not using the MultiDexApplication, the classloader is never patched, so the classes in the secondary dex file cannot be loaded.
For more information see https://developer.android.com/studio/build/multidex.html#mdex-gradle

java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.measurement.AppMeasurement" on path: DexPathList

My app was running well but it is crashing now. I started getting warnings even though I am not integrating with firebase. Now I think that I can not solve this problem. I tried every possible solution available on stackoverflow. Also, I am using viewpager in my code if that helps.
LogCat
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.kidsbox.android.abcforkidsalphabetshapesandnumbers-1/base.apk"],nativeLibraryDirectories=[/data/app/com.kidsbox.android.abcforkidsalphabetshapesandnumbers-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:167)
at com.google.android.gms.ads.internal.scionintegration.b.a(:com.google.android.gms.DynamiteModulesA:152)
at com.google.android.gms.ads.internal.scionintegration.b.g(:com.google.android.gms.DynamiteModulesA:43)
at com.google.android.gms.ads.internal.request.c.a(:com.google.android.gms.DynamiteModulesA:26)
at com.google.android.gms.ads.internal.util.b.run(:com.google.android.gms.DynamiteModulesA:4)
at com.google.android.gms.ads.internal.util.af.call(:com.google.android.gms.DynamiteModulesA:3)
at com.google.android.gms.ads.internal.util.ag.run(:com.google.android.gms.DynamiteModulesA:3)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.measurement.AppMeasurement
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kidsbox.android.abcforkidsalphabetshapesandnumbers">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
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=".Alphabet" />
<activity android:name=".Number" />
<activity android:name=".Shapes"/>
</application>
Build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.kidsbox.android.abcforkidsalphabetshapesandnumbers"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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.google.android.gms:play-services-ads:11.0.4'
testCompile 'junit:junit:4.12'
}
I think this issue is similar with How to enable multidexing with the new Android Multidex support library
Add implementation "com.android.support:multidex:1.0.1" in your build.gradle's dependencies ( implementation can be replaced with compile );
Add a custom application extends from Application. Add code as below:
override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)
MultiDex.install(this)
}
Add your custom application in AnroidManifest.xml as android:name=".CustomApplication"
You should use compile 'com.google.firebase:firebase-ads:11.2.0'
instead of compile 'com.google.android.gms:play-services-ads:11.2.0'

Android cannot instantiate Multidex Application

I am getting the following error when I install my app on any device.Kindly provide me a solution.I have never encountered this type of error before.Below I have posted build,gradle,manifest etc..
Error:
java.lang.RuntimeException: Unable to instantiate application android.support.multidex.MultiDexApplication: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication" on path: DexPathList[[zip file "/data/app/com.example.jobinsabu.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.jobinsabu.myapp-1/lib/arm64, /vendor/lib64, /system/lib64]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:590)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4964)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1555)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication" on path: DexPathList[[zip file "/data/app/com.example.jobinsabu.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.jobinsabu.myapp-1/lib/arm64, /vendor/lib64, /system/lib64]]
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 android.app.Instrumentation.newApplication(Instrumentation.java:986)
at android.app.LoadedApk.makeApplication(LoadedApk.java:585)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4964) 
at android.app.ActivityThread.-wrap1(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1555) 
at android.os.Handler.dispatchMessage(Handler.java:111) 
at android.os.Looper.loop(Looper.java:207) 
at android.app.ActivityThread.main(ActivityThread.java:5776) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) 
Suppressed: java.lang.ClassNotFoundException: android.support.multidex.MultiDexApplication
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.jobinsabu.myapp">
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:hardwareAccelerated="true">
<meta-data android:name="com.google.android.geo.API_KEY" android:value="---------"/>
<activity android:name=".others.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.darsh.multipleimageselect.activities.AlbumSelectActivity"
android:theme="#style/MultipleImageSelectTheme">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- ATTENTION: This was auto-generated to add Google Play services to your project for
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>
build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.jobinsabu.ohxee"
minSdkVersion 16
targetSdkVersion 26
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.borax12.materialdaterangepicker:library:1.9'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.patrickpissurno:ripple-effect:1.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.android.gms:play-services-maps:11.0.1'
testCompile 'junit:junit:4.12'
compile 'com.github.darsh2:MultipleImageSelect:3474549'
compile 'com.android.support:multidex:1.0.1'
compile 'com.sa90.materialarcmenu:library:1.4'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.google.firebase:firebase-auth:11.0.1'
compile 'org.jetbrains:annotations-java5:15.0'
compile 'com.google.android.gms:play-services:11.0.1'
}
apply plugin: 'com.google.gms.google-services'
myapp.java:
public class OhxeeApp extends MultiDexApplication {
#Override
public void onCreate() {
super.onCreate();
Log.e("App","Started");
}
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
The ClassNotFoundException is thrown when the Java Virtual Machine
(JVM) tries to load a particular class and the specified class cannot
be found in the classpath
Don't
android:name="android.support.multidex.MultiDexApplication"
public class OhxeeApp extends MultiDexApplication {
Do
android:name="com.example.jobinsabu.ohxee.others.OhxeeApp"
public class OhxeeApp extends Application {
in your manifest.
android:name=".OhxeeApp"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:hardwareAccelerated="true">
In AndroidManifest change the application name to OhxeeApp:
android:name=".OhxeeApp"

Conflicting between Firebase messaging and Content Provider when i use them together

I have an application that share locations between users on Google maps and sorting and retrieving database using content provider and also opening chat messages using firebase messaging but when i combine Firebase messaging and Android content provider together the conflict happens and i found the error below , although when i use content provider or firebase messaging separately they work well and i have outputs from both, but once i combine both i have that message :
04-22 09:13:36.734 23186-23186/pioneers.safwat.onecommunity E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: /data/app/pioneers.safwat.onecommunity-5.apk
at android.app.ActivityThread.installProvider(ActivityThread.java:5199)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4802)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4686)
at android.app.ActivityThread.access$1400(ActivityThread.java:168)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1389)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:177)
at android.app.ActivityThread.main(ActivityThread.java:5496)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1225)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1041)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: /data/app/pioneers.safwat.onecommunity-5.apk
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:64)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.ActivityThread.installProvider(ActivityThread.java:5184)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4802) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4686) 
at android.app.ActivityThread.access$1400(ActivityThread.java:168) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1389) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:177) 
at android.app.ActivityThread.main(ActivityThread.java:5496) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:525) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1225) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1041) 
at dalvik.system.NativeStart.main(Native Method) 
my Gradle file is (Module) :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "pioneers.safwat.onecommunity"
minSdkVersion 18
targetSdkVersion 25
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
// compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.google.android.gms:play-services-location:10.2.1'
// compile 'com.google.android.gms:play-services-plus:10.0.1'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.firebaseui:firebase-ui:0.6.1'
compile 'com.google.android.gms:play-services:10.2.1'
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.google.firebase:firebase-core:10.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
and my gradle file( Build):
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and My manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pioneers.safwat.onecommunity">
<permission
android:name="pioneers.safwat.onecommunity.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="pioneers.safwat.onecommunity.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".Start">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Authentic"/>
<activity android:name=".MainActivity"/>
<activity android:name=".UserData"/>
<activity android:name=".UpdateData"/>
<provider
android:name=".Myprovider"
android:authorities="pioneers.safwat.onecommunity.Myprovider"
android:exported="true"
android:multiprocess="true"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="" />
</application>
</manifest>
Try adding this in your manifest
<application
....
android:name=".MyApplication">
// ...
</application>
Then make a class.
public class MyApplication extends Application {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Try this link for more details.

Categories

Resources