Android cannot instantiate Multidex Application - android

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"

Related

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'

Unfortunately Application has stopped while launching google maps Activity

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

Unable to get provider com.facebook.internal.FacebookInitProvider: java.lang.ClassNotFoundException

I am trying to share a photo from my application to facebook. I have added the Facebook SDK and done the initial setup. But when I run the application its crashing and I am getting the following exception.
Here is my logcat:
java.lang.RuntimeException: Unable to get provider com.facebook.internal.FacebookInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.facebook.internal.FacebookInitProvider" on path: DexPathList[[zip file "/data/app/com.ignite.a01hw909350.kolamdemo-2/base.apk", zip file "/data/app/com.ignite.a01hw909350.kolamdemo-2/split_lib_slice_1_apk.apk"],nativeLibraryDirectories=[/data/app/com.ignite.a01hw909350.kolamdemo-2/lib/arm64, /data/app/com.ignite.a01hw909350.kolamdemo-2/base.apk!/lib/arm64-v8a, /data/app/com.ignite.a01hw909350.kolamdemo-2/split_lib_slice_1_apk.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5267)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4859)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4799)
at android.app.ActivityThread.access$1600(ActivityThread.java:168)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1434)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5609)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.internal.FacebookInitProvider" on path: DexPathList[[zip file "/data/app/com.ignite.a01hw909350.kolamdemo-2/base.apk", zip file "/data/app/com.ignite.a01hw909350.kolamdemo-2/split_lib_slice_1_apk.apk"],nativeLibraryDirectories=[/data/app/com.ignite.a01hw909350.kolamdemo-2/lib/arm64, /data/app/com.ignite.a01hw909350.kolamdemo-2/base.apk!/lib/arm64-v8a, /data/app/com.ignite.a01hw909350.kolamdemo-2/split_lib_slice_1_apk.apk!/lib/arm64-v8a, /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.ActivityThread.installProvider(ActivityThread.java:5252)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4859) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4799) 
at android.app.ActivityThread.access$1600(ActivityThread.java:168) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1434) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5609) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) 
Suppressed: java.lang.ClassNotFoundException: com.facebook.internal.FacebookInitProvider
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
Here is my Manifest.xml
<application
android:name=".AppController"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:largeHeap="true"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
<activity android:name=".MainActivity" />
<activity
android:name=".ARCameraActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="fullSensor" />
<activity
android:name=".RegistrationActivity"
android:screenOrientation="portrait" />
<activity
android:name=".LoginActivity"
android:screenOrientation="portrait" />
<activity
android:name=".SplashActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MenuActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ScanAndDrawActivity"
android:screenOrientation="portrait" />
<activity
android:name=".GalleryActivity"
android:screenOrientation="portrait" />
<activity
android:name=".PdfKolamActivity"
android:screenOrientation="portrait" />
<service
android:name=".BluetoothService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.ignite.a01hw909350.kolamdemo.BluetoothService" />
</intent-filter>
</service>
<receiver
android:name=".MyScheduleReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
</intent-filter>
</receiver>
<activity
android:name=".BotDialogActivity"
android:launchMode="singleInstance"
android:noHistory="true"
android:theme="#style/Theme.AppCompat.Light.Translucent" />
<activity android:name=".ModelActivity" />
<activity android:name=".PanchangActivity" />
<receiver
android:name=".MyStartServiceReceiver" android:exported="true"/>
<service
android:name=".services.AlarmService"
android:enabled="true">
<intent-filter>
<action android:name="NOTIFICATION_SERVICE" />
</intent-filter>
</service>
<receiver
android:name=".BootReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
<provider android:authorities="com.facebook.app.FacebookContentProvider43234236033829"
android:name="com.facebook.FacebookContentProvider"
android:exported="true"/>
</application>
Here is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.ignite.a01hw909350.kolamdemo"
minSdkVersion 17
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'
}
}
aaptOptions {
noCompress 'KARMarker'
noCompress 'armodel'
}
repositories {
jcenter()
maven()
}
}
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 project(':KudanAR1')
compile project(':eventbus-3.0.0')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.scottyab:secure-preferences-lib:0.1.4'
compile 'com.jrummyapps:animated-svg-view:1.0.1'
compile 'me.zhanghai.android.materialprogressbar:library:1.3.0'
compile 'io.palaima:smoothbluetooth:0.1.0'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.afollestad.material-dialogs:core:0.9.3.0'
compile 'com.flurgle:camerakit:0.9.13'
compile 'com.github.zhukic:sectioned-recyclerview:1.0.0'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.prolificinteractive:material-calendarview:1.4.3'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:design:25.3.1'
compile 'com.github.barteksc:android-pdf-viewer:2.4.0'
compile 'org.rajawali3d:rajawali:1.1.668#aar'
compile 'com.tapadoo.android:alerter:1.0.8'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
testCompile 'junit:junit:4.12'
}
Where is the problem coming from?
I had the same error because a badly set multidex. The problem occurred on device with Android 4.4.2.
This i had in build.gradle:
defaultConfig {
multiDexEnabled true
}
And I had to add to build.gradle:
dependencies {
compile 'com.android.support:multidex:1.0.2'
}
And this method to my application class:
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Answer is originaly from here, which problem I had to solve when I avoided facebook problem by removing facebook SDK. So maybe can help another tip from there.
Try to change your facebook-sdk version to the latest (now it is 4.24.0):
compile 'com.facebook.android:facebook-android-sdk:4.24.0'
Update your google play services 11.0.2
compile 'com.google.android.gms:play-services-maps:11.0.2'
compile 'com.google.android.gms:play-services-location:11.0.2'
This fixed this problem for me.
Make sure gradle is not running in offline work mode, otherwise it will not download sdk from repositories.
Make gradle work online with steps below:
1 - Open the Preferences window by clicking File > Settings
2 - In the left pane, click Build, Execution, Deployment > Gradle
3 - Uncheck the Offline work checkbox
4 - Click OK
Just try Clean Project & Rebuild Project.

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.

Eclipse migration NoClassDefFound GooglePlayServicesClient$ConnectionCallbacks

i have a problem with my code.
So far I worked with Eclipse, but now i work with Android Studio.
(In Eclipse)
I have a library project called MoST, that requires google_play_service_r16 library project. To import this project in Android Studio:
1) In Eclipse I add google_play_service_r16 to MoST.
2) Export file as build.gradle.
3) Finally i imported build.gradle and then create MoST.aar in Android Studio.
In Android Studio i created a new project that uses the MoST module. When i try to run my new application i have this error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.unipa.uniar, PID: 23978
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/GooglePlayServicesClient$ConnectionCallbacks;
at org.most.MoSTApplication.onCreate(MoSTApplication.java:66)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1032)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5881)
at android.app.ActivityThread.-wrap3(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1718)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.GooglePlayServicesClient$ConnectionCallbacks" on path: DexPathList[[zip file "/data/app/com.unipa.uniar-2/base.apk", zip file "/data/app/com.unipa.uniar-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.unipa.uniar-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.unipa.uniar-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.unipa.uniar-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.unipa.uniar-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.unipa.uniar-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.unipa.uniar-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.unipa.uniar-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.unipa.uniar-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.unipa.uniar-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.unipa.uniar-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.unipa.uniar-2/lib/arm64, /system/lib64, /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 org.most.MoSTApplication.onCreate(MoSTApplication.java:66) 
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1032) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5881) 
at android.app.ActivityThread.-wrap3(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1718) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6688) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358) 
My app module build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.unipa.uniar"
minSdkVersion 15
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(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':most')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-base:10.2.1'
testCompile 'junit:junit:4.12'
compile files('libs/weka-3.6.6-android.jar')
compile files('libs/org.apache.commons.io.jar')
compile files('libs/bcprov-jdk15on-155.jar')
compile files('libs/apache-httpcomponents-httpclient.jar')
compile files('libs/httpcore-4.4.6.jar')
}
(Most module) AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.most"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Permission for activity recognition -->
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<application
android:name="org.most.MoSTApplication"
android:allowBackup="false"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:launchMode="singleInstance" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="MoSTService"
android:enabled="true" >
</service>
</application>
</manifest>
The error says Most Didn't find class "com.google.android.gms.common.GooglePlayServicesClient$ConnectionCallbacks"
How can i fix the problem?
SOLUTION
GooglePlayServicesClient class has been deprecated for some time. Recent versions of google play services such as 10.2.1 can create a variety of problems. In my case I can not use newer versions as I can not edit library directly. To solve the problem have included the version of google play service 4.3.23, that include the GooglePlayServiceClient and I solved the problem. AndroidManifest.xml (final):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.unipa.uniar">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- Permission for Network -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- Permission for activity recognition -->
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<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/Theme.AppCompat.Light"
tools:replace="android:allowBackup,android:icon,android:theme">
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".Welcome"
android:label="#string/app_name">
<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=".TrainingSet" />
<activity android:name=".Testing"></activity>
</application>
</manifest>
and this is the gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.unipa.uniar"
minSdkVersion 15
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(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':most')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services:4.3.23'
testCompile 'junit:junit:4.12'
compile files('libs/weka-3.6.6-android.jar')
compile files('libs/org.apache.commons.io.jar')
compile files('libs/bcprov-jdk15on-155.jar')
compile files('libs/apache-httpcomponents-httpclient.jar')
compile files('libs/httpcore-4.4.6.jar')
}

Categories

Resources