Class not found in aar - android

I'm getting class not found exception in my Android library (aar) when GoogleApiAvailability is called.
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.GoogleApiAvailability" on path: DexPathList[[zip file "/data/app/com.myunityplugin.PushNotifications-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myunityplugin.PushNotifications-1/lib/arm, /vendor/lib, /system/lib]]
The error is self-explanatory, but I'm not sure what I'm doing wrong. I'm pretty new to gradle and AndroidStudio.
I have the following under dependencies within my gradle.build:
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
I think the problem is that the play-services library needs to be included in the aar, and compile doesn't do that. I tried using 'runtime' but I get "gradle dsl runtime not found".
Questions:
Is this an issue where I need to include the play-services library in my aar, and how do I accomplish that? (if not, how do I address this problem)
Do I need to specify play-services or does play-services-gcm suffice?
Error Info / Setup
Line causing the error
GoogleApiAvailability ServiceAvailability = GoogleApiAvailability.getInstance();
Exception:
05-23 05:38:48.221 28055-28055/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myunityplugin.PushNotifications, PID: 28055
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/GoogleApiAvailability;
at com.myplugin.unitynotification.GCM.GCM.checkPlayServices(GCM.java:33)
at com.myplugin.unitynotification.GCM.MainActivity.onCreate(MainActivity.java:80)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3108)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3263)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1687)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6897)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.GoogleApiAvailability" on path: DexPathList[[zip file "/data/app/com.myunityplugin.PushNotifications-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myunityplugin.PushNotifications-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.myplugin.unitynotification.GCM.GCM.checkPlayServices(GCM.java:33) 
at com.myplugin.unitynotification.GCM.MainActivity.onCreate(MainActivity.java:80) 
at android.app.Activity.performCreate(Activity.java:6550) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3108) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3263) 
at android.app.ActivityThread.access$1000(ActivityThread.java:197) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1687) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:6897) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) 
Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.common.GoogleApiAvailability
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)
... 16 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
App Level build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
provided files('lib-not-include/classes.jar')
}
Project level gradle.build
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

The aar file doesn't contain the nested (or transitive) dependencies and doesn't have a pom file which describes the dependencies used by the library.
It means that, if you are importing a aar file using a flatDir repo you have to specify the dependencies also in your project.
You should use a maven repository (you have to publish the library in a private or public maven repo), you will not have the same issue.
In this case, gradle downloads the dependencies using the pom file which will contains the dependencies list.

Related

App Immediatley crashes once app runs with error ClassNotFoundException: Didn't find class application on path: DexPathList

Starting a new project and I am experiencing the following error... I have tried other solutions but seem to be dated
Steps I have tried:
Double checked plugins (listed below)
Instance Run (not listed)
tried using kapt in-place of annotationProccessor (produces a different error)
Process: com.example.transfer_tracker, PID: 28953
java.lang.RuntimeException: Unable to instantiate application com.example.transfer_tracker.CoreApplication package com.example.transfer_tracker: java.lang.ClassNotFoundException: Didn't find class "com.example.transfer_tracker.CoreApplication" on path: DexPathList[[dex file "/data/data/com.example.transfer_tracker/code_cache/.overlay/base.apk/classes4.dex", zip file "/data/app/~~zfKHJdy7wnPYBA_pfwtohQ==/com.example.transfer_tracker-gXT0kIH37Cwb7XaCDmovmg==/base.apk"],nativeLibraryDirectories=[/data/app/~~zfKHJdy7wnPYBA_pfwtohQ==/com.example.transfer_tracker-gXT0kIH37Cwb7XaCDmovmg==/lib/arm64, /system/lib64, /system_ext/lib64]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:1364)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6686)
at android.app.ActivityThread.access$1500(ActivityThread.java:247)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2053)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7839)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.transfer_tracker.CoreApplication" on path: DexPathList[[dex file "/data/data/com.example.transfer_tracker/code_cache/.overlay/base.apk/classes4.dex", zip file "/data/app/~~zfKHJdy7wnPYBA_pfwtohQ==/com.example.transfer_tracker-gXT0kIH37Cwb7XaCDmovmg==/base.apk"],nativeLibraryDirectories=[/data/app/~~zfKHJdy7wnPYBA_pfwtohQ==/com.example.transfer_tracker-gXT0kIH37Cwb7XaCDmovmg==/lib/arm64, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:218)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:52)
at android.app.Instrumentation.newApplication(Instrumentation.java:1177)
at android.app.LoadedApk.makeApplication(LoadedApk.java:1356)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6686) 
at android.app.ActivityThread.access$1500(ActivityThread.java:247) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2053) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loopOnce(Looper.java:201) 
at android.os.Looper.loop(Looper.java:288) 
at android.app.ActivityThread.main(ActivityThread.java:7839) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) 
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/example/transfer_tracker/Hilt_CoreApplication;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
... 15 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.transfer_tracker.Hilt_CoreApplication" on path: DexPathList[[dex file "/data/data/com.example.transfer_tracker/code_cache/.overlay/base.apk/classes4.dex", zip file "/data/app/~~zfKHJdy7wnPYBA_pfwtohQ==/com.example.transfer_tracker-gXT0kIH37Cwb7XaCDmovmg==/base.apk"],nativeLibraryDirectories=[/data/app/~~zfKHJdy7wnPYBA_pfwtohQ==/com.example.transfer_tracker-gXT0kIH37Cwb7XaCDmovmg==/lib/arm64, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:218)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 18 more
[CIRCULAR REFERENCE:java.lang.NoClassDefFoundError: Failed resolution of: Lcom/example/transfer_tracker/Hilt_CoreApplication;]
Android Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.transfer_tracker">
<application
android:name=".CoreApplication"
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.TransferTracker">
<activity
android:name=".login.LauncherActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Project build.gradle
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.40.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Module project.gradle
plugins {
id 'com.android.application'
id 'kotlin-kapt'
id 'kotlin-android'
id 'dagger.hilt.android.plugin'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.transfer_tracker"
minSdk 22
targetSdk 31
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.google.dagger:hilt-android:2.40.5'
annotationProcessor 'com.google.dagger:hilt-compiler:2.40.5'
}
Application Class
package com.example.transfer_tracker
import android.app.Application
import androidx.multidex.MultiDexApplication
import dagger.hilt.android.HiltAndroidApp
#HiltAndroidApp
class CoreApplication : Application()
when using kapt instead of annotationProccessor
public final class CoreApplication extends android.app.Application {
^
Expected #HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin? (dagger.hilt.android.plugin)
See https://dagger.dev/hilt/gradle-setup.html
[Hilt] Processing did not complete. See error above for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
> java.lang.reflect.InvocationTargetException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
UPDATE
Implemented with Dagger2 error is gone... maybe this is due to a bug within the Hilt library
After adding these dependencies everything works fine
implementation 'com.google.dagger:hilt-android:2.40.5'
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.0'
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03'
annotationProcessor 'androidx.hilt:hilt-compiler:1.0.0'
annotationProcessor 'com.google.dagger:hilt-android-compiler:2.38.1'
Try extending the CoreApplication class with MultiDexApplication like this:
#HiltAndroidApp
class CoreApplication : MultiDexApplication() {...}
I think your Application class is getting saved in a different Dex file.
Trying to keep them in a single Dex file should work.
Try this Procedure
Suggestion:
To check Dex file classes you can use Android Studio,
open your apk into Android Studio. You can see your dex files in the apk explorer.
Then select the dex file to see what classes are inside it.
I had the same problem.
Got it resolved by removing this from AndroidManifest.xml
<application
android:name="com.package.name.Application" <- Remove this entire line
Before that I tired invalidating caches, Project Clean, delete build, .gradle and .idea folders, upgraded everything to the latest versions.
Nothing else worked.

How to fix Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder"

I'm trying to implement OTP verification by phone number using firebasebut I'am getting ths error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.wasali.mobile_authentication, PID: 7864
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/browser/customtabs/CustomTabsIntent$Builder;
at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth##20.0.1:13)
at com.google.android.gms.internal.firebase-auth-api.zzth.zzb(com.google.firebase:firebase-auth##20.0.1:7)
at com.google.android.gms.internal.firebase-auth-api.zzth.onPostExecute(com.google.firebase:firebase-auth##20.0.1)
at android.os.AsyncTask.finish(AsyncTask.java:660)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:677)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6276)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/com.wasali.mobile_authentication-1/base.apk"],nativeLibraryDirectories=[/data/app/com.wasali.mobile_authentication-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 com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth##20.0.1:13) 
at com.google.android.gms.internal.firebase-auth-api.zzth.zzb(com.google.firebase:firebase-auth##20.0.1:7) 
at com.google.android.gms.internal.firebase-auth-api.zzth.onPostExecute(com.google.firebase:firebase-auth##20.0.1) 
at android.os.AsyncTask.finish(AsyncTask.java:660) 
at android.os.AsyncTask.-wrap1(AsyncTask.java) 
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:677) 
at android.os.Handler.dispatchMessage(Handler.java:110) 
at android.os.Looper.loop(Looper.java:203) 
at android.app.ActivityThread.main(ActivityThread.java:6276) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924) 
I tried many solutions like add this dependencie but it doesn't work:
implementation androidx.browser:browser:1.2.0
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-analytics'
implementation platform('com.google.firebase:firebase-bom:26.0.0')
I was facing same issue, please try following-
//import broswer(require for firebase reCaptch Verifications)
implementation 'androidx.browser:browser:1.2.0'
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:26.1.0')
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-analytics'
Make sure you put apply plugin: 'com.google.gms.google-services' // Google Services plugin
at top of build.gradle(app), and add a dependency in build.gradle(Project) as following-
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.4' // Google Services plugin
}
}
In case you are facing error as 'Static interface methods are only supported starting with Android N' then update Java Version to 1.8 via adding those lines
in your build.gradle(Project)
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
...
}
Happy coding!

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/Function;

I am getting this error:
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/Function;
Here is the full output:
2018-11-09 18:33:22.546 24224-24224/com.test.notes.notes E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.test.notes.notes, PID: 24224
java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
at com.google.android.gms.internal.firebase-firestore.zzkj.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:6274)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/Function;
at com.google.android.gms.internal.firebase-firestore.zzfu.zzd(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzeg.<init>(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzcj.zza(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzcl.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.google.android.gms.internal.firebase-firestore.zzkg$zza.run(Unknown Source)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.util.Function" on path: DexPathList[[zip file "/data/app/com.test.notes.notes-1/base.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.test.notes.notes-1/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 com.google.android.gms.internal.firebase-firestore.zzfu.zzd(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzeg.<init>(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzcj.zza(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzcl.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.google.android.gms.internal.firebase-firestore.zzkg$zza.run(Unknown Source)
at java.lang.Thread.run(Thread.java:761)
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.test.notes.notes-1/split_lib_slice_7_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:367)
at dalvik.system.DexFile.<init>(DexFile.java:112)
at dalvik.system.DexFile.<init>(DexFile.java:77)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:359)
at dalvik.system.DexPathList.makeElements(DexPathList.java:323)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:263)
at dalvik.system.DexPathList.<init>(DexPathList.java:126)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
at com.android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.java:43)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:58)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:541)
2018-11-09 18:33:22.546 24224-24224/com.test.notes.notes E/AndroidRuntime: at android.app.LoadedApk.getClassLoader(LoadedApk.java:574)
at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:1900)
at android.app.LoadedApk.getResources(LoadedApk.java:787)
at android.app.ContextImpl.<init>(ContextImpl.java:2038)
at android.app.ContextImpl.createAppContext(ContextImpl.java:1983)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5439)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1576)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:6274)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
And I think my build.gradle is needed so here is my build.gradle(Project: test):
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 27
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.test.notes.notes"
minSdkVersion 16
targetSdkVersion 27
versionCode 17
versionName "5.1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
}
aaptOptions {
cruncherEnabled = false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support:cardview-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.android.support:support-vector-drawable:27.0.2'
implementation 'com.google.firebase:firebase-firestore:15.0.0'
implementation 'com.firebaseui:firebase-ui-firestore:3.1.1'
api 'com.joooonho:selectableroundedimageview:1.0.1'
api 'com.github.bumptech.glide:glide:3.7.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'
api 'com.google.firebase:firebase-core:16.0.5'
api 'com.google.firebase:firebase-firestore:15.0.0'
api 'com.google.firebase:firebase-storage:16.0.4'
api 'com.google.firebase:firebase-auth:16.0.5'
api 'com.crashlytics.sdk.android:crashlytics:2.9.5'
}
apply plugin: 'com.google.gms.google-services'
With that error, the app crashes.
I think there could be anything wrong with the firebase SDK, but can't figure it out?
Please help me to fix this. I didn't find a way to fix it, for a long time.:(
EDIT:
After updated everything to the newest version and added:
multiDexEnabled true
...everything works fine. But now I have the Problem, why I downgraded the versions finally. Please have a look at my question: I don't get a response:
Updating code after firebase 16.0.+ update
When I could fix that everything would be fine.
I see a whole mess of problems in your build.gradle.
The first category of issues is that most of your dependencies are pretty outdated.
The Android API 27 support libraries are on 27.1.1, not 27.0.2.
firebase-firestore is on 17.1.2, not 15.0.0.
firebase-ui-firestore is on 4.2.1, not 2.1.1.
glide is on 4.8.0, not 3.7.0.
Dependency versions should be up-to-date in general, but absolutely must be up-to-date if they're from Google. Otherwise you run into exactly the type of error you have.
The second problem is that you implement firebase-firestore twice, once with implementation and again with api. Remove one or the other.
A handy tip: if a dependency is highlighted in yellow, that means it's outdated! Click the text, hit Alt+Enter and choose the option to update it to the latest version.

Android Studio 3.1 Error while Compile

Just updated to Android Studio 3.1 and i am getting this error while i compile and run my app it crushes not even it launch. I don't know how to fix this before the update everything was working smooth. And now this weird error help me guys.
HERE IS THE ERROR MESSAGE THAT I GET.
Process: gmlab.shotonlogo, PID: 10917
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/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/base.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_dependencies_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_resources_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_0_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_1_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_2_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_3_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_4_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_5_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_6_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_7_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_8_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/lib/arm64, /system/lib64, /vendor/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:6242)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/base.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_dependencies_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_resources_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_0_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_1_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_2_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_3_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_4_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_5_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_6_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_7_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_8_apk.apk", zip file "/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.ActivityThread.installProvider(ActivityThread.java:6227)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722) 
at android.app.ActivityThread.-wrap1(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6494) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
03-27 13:55:57.256 10917-10917/? E/AndroidRuntime: Suppressed: java.io.IOException: No original dex files found for dex location /data/app/gmlab.shotonlogo-kgXVXTIWrCf-_Y9hAwZoWQ==/split_lib_resources_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:353)
at dalvik.system.DexFile.<init>(DexFile.java:100)
at dalvik.system.DexFile.<init>(DexFile.java:74)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
at dalvik.system.DexPathList.<init>(DexPathList.java:157)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:35)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:693)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:727)
at android.app.LoadedApk.getResources(LoadedApk.java:954)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2270)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5639)
HERE IS THE BUILD CONFIG FOR MY PROJECT
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "gmlab.shotonlogo"
minSdkVersion 17
targetSdkVersion 27
versionCode 50
versionName "4.6"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'agency.tango.android:material-intro-screen:0.0.5'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-ads:12.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:design:27.1.0'
}
apply plugin: 'com.google.gms.google-services'
PROJECT LEVEL GRADLE
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Hey i just disable the INSTANT RUN and my app is working fine now. IDK What they did with Android Studio 3.1. Thank you all for your replies :)

Unable to get provider com.google.firebase.provider.FirebaseInitProvider on a downloaded apk, works fine when uploading the apk with adb

Very much aware there are similar questions. Tried all the answers, none of them helped.
Everything works just fine when I upload the apk to my phone with Android Studio but when I download and install the apk I get this nonsense:
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.mycompany.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mycompany.myapp-1/lib/arm64, /system/lib64, /vendor/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5945)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5534)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5473)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1571)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6209)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.mycompany.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mycompany.myapp-1/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 android.app.ActivityThread.installProvider(ActivityThread.java:5930)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5534) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5473) 
at android.app.ActivityThread.-wrap2(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1571) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6209) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
The app is pretty much only a webview wrapper for a webapp + widget + GCM functionality that receives push messages and shows notifications. If I get this to work, I might never need to touch Android again, so for the love of god please help me with this final issue.
Here's my build.gradle files:
Project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Module:
apply plugin: 'com.android.application'
//apply plugin: "com.ewerk.gradle.plugins.annotation-processor"
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.mycompany.myapp"
minSdkVersion 21
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true //tried this due to one answer, didnt do anything
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
/*
configurations.all {
resolutionStrategy {
force 'com.android.support:design:23.4.0'
force 'com.android.support:support-v4:23.4.0'
force 'com.android.support:appcompat-v7:23.4.0'
}
}
*/
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
//compile 'com.android.support:appcompat-v7:24.4.0'
//compile 'com.jakewharton:butterknife-compiler:8.4.0'
//annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.jakewharton:butterknife:8.4.0'
//compile 'com.google.android.gms:play-services-gcm:10.0.1'
//compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
//compile 'com.firebase:firebase-client-android:2.3.1'
// https://mvnrepository.com/artifact/com.squareup.okhttp/okhttp
compile group: 'com.squareup.okhttp', name: 'okhttp', version: '2.7.5'
}
apply plugin: 'com.google.gms.google-services'
Yessss, finally. Goodbye android!
Turns out the APK android studio had built during normal build processes was crap for some reason. Build-> Build APK built a 3x bigger apk file that worked when downloaded too.

Categories

Resources