I am using okhttp3 with glide so I have added the integration part as well.
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.github.bumptech.glide:okhttp-integration:1.4.0#aar'
I have even enabled multidex support using
compile 'com.android.support:multidex:1.0.1'
and adding this to application class
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(base);
}
Here is full stack trace -
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/okhttp/OkHttpClient;
at com.bumptech.glide.integration.okhttp.OkHttpUrlLoader$Factory.getInternalClient(OkHttpUrlLoader.java:30)
at com.bumptech.glide.integration.okhttp.OkHttpUrlLoader$Factory.<init>(OkHttpUrlLoader.java:41)
at com.bumptech.glide.integration.okhttp.OkHttpGlideModule.registerComponents(OkHttpGlideModule.java:31)
at com.bumptech.glide.Glide.get(Glide.java:157)
at com.bumptech.glide.RequestManager.<init>(RequestManager.java:62)
at com.bumptech.glide.RequestManager.<init>(RequestManager.java:53)
at com.bumptech.glide.manager.RequestManagerRetriever.supportFragmentGet(RequestManagerRetriever.java:198)
at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java:104)
at com.bumptech.glide.Glide.with(Glide.java:644)
at com.skcsllp.mutterfly.activities.EditProfileActivity.onCreate(EditProfileActivity.java:76)
at android.app.Activity.performCreate(Activity.java:6100)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
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:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.squareup.okhttp.OkHttpClient" on path: DexPathList[[dex file
"/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-support-annotations-23.2.1_711eea7d990a3279fc66c06b239bf29196aabc02-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_9-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_8-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_7-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_6-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_5-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_4-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_3-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_2-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_1-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_0-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-okio-1.6.0_4cb2265fa47e13dbef896857be4ee851d4d21b93-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-okhttp-3.2.0_c46370073bf914e884c23455554d5f56e9b15f17-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-internal_impl-23.2.1_945649fcb49395f2024bfee914abcd2b33619e3f-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-gson-2.2.4_d0ce76b63ce905fbab3c5d385c8e1b8692010f19-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-glide-3.6.1_362f6061e938ba7d3e28c67a4832a9a19bdf24aa-classes.dex",
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-com.google.android.gms-play-services-gcm-7.8.0_defd878a1ea68768e6e678ca0946f67a973b8929-classes.dex",
this is config for build
productFlavors {
// Define separate dev and prod product flavors.
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 15
}
}
I could not figure out what's wrong with dex process.
EDIT
Everything works great if i simply remove the integration part from the build.gradle
compile 'com.github.bumptech.glide:okhttp-integration:1.4.0#aar'
No need for multidex unless you have too many methods.
Decide if you're using okhttp (v2) or okhttp3 and update your code accordingly:
compile 'com.github.bumptech.glide:okhttp-integration:1.4.0#aar'
compile 'com.squareup.okhttp:okhttp:2.7.5'
or
compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0#aar'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
Read https://github.com/bumptech/glide/wiki/Integration-Libraries for more details.
(Source: https://github.com/bumptech/glide/issues/1158#issuecomment-215007390)
Related
I am using FileProvider in my app. As usual I declared <Provider> tag in AndroidManifest.xml file as below.
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.jk.android.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/file_paths" />
</provider>
When I run it on android device which has lollipop version it works fine. when I try it on kitkat version it shows following errors:
FATAL EXCEPTION: main
Process: com.jk.android.perfectphotoeditor2018, PID: 24992
java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[zip file "/data/app/com.jk.android.perfectphotoeditor2018-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.jk.android.perfectphotoeditor2018-2, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5071)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4648)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4588)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1290)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5299)
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:932)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:748)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[zip file "/data/app/com.jk.android.perfectphotoeditor2018-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.jk.android.perfectphotoeditor2018-2, /system/lib]]
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:5056)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4648)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4588)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1290)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5299)
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:932)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:748)
at dalvik.system.NativeStart.main(Native Method)
I had tried many solutions like this but it doesn't work for me. so, help me for solve this problem.
build.gradle dependencies:
dependencies {
compile 'com.android.support.constraint:constraint-layout:1.0.2'
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'
})
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
testCompile 'junit:junit:4.12'
/* Add the CSDK framework dependencies (Make sure these version numbers are correct) */
// compile 'com.aviary.android.feather.sdk:aviary-sdk:3.6.3'
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.adobe.creativesdk.foundation:auth:0.9.1251'
compile 'com.adobe.creativesdk:image:4.8.4'
compile 'com.localytics.android:library:4.0.1'
compile 'com.android.support:design:25.4.0'
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support:support-v4:25.4.0'
compile 'com.intuit.sdp:sdp-android:1.0.4'
compile 'com.github.bumptech.glide:glide:4.3.1'
compile 'com.google.android.gms:play-services-ads:9.4.0'
implementation 'com.android.support:support-v4:25.4.0'
}
If you have migrated to AndroidX you have to change the name in AndroidManifest.xml to androidx.core.content.FileProvider
That was the crash in my case.
I have the same question, and this documentation solve my problem.
https://developer.android.com/studio/build/multidexandroid multidex
before android 5.0, you must use follow ways to multidex:
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.3'
}
and then modify application, select any one of three ways:
if you not implement application:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>
if you have custom application, you can modify like this:
public class MyApplication extends MultiDexApplication { ... }
if you have replace base application, you can modify like this:
public class MyApplication extends SomeOtherApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Hope this can solve you problem.
The following code works for me (I've migrated to AndroidX):
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true"
tools:ignore="WrongManifestParent">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_paths" />
</provider>
in my project when set "multiDexEnabled" false, error fixed.
go to manifest and add
android {
defaultConfig {
multiDexEnabled false
}}
hope this is helpful
Just delete the intermediates folder.
After thorough reading of Android Multidex documentation, I found that there is one configuration we generally miss which causes java.lang.NoClassDefFoundError. If you have done regular multidex configuration for 65K reference limit and and still unable to get rid of java.lang.NoClassDefFoundError then you must follow these steps.
Create a file called multidex-config.txt at app level(same directory as the build.gradle file)
Add following line (the absolute class name for which you are getting exception)
android.support.v4.content.FileProvider
Modify your build.gradle as follow
android {
buildTypes {
release {
multiDexKeepFile file('multidex-config.txt')
...
}
}
}
Note : You can add it for specific build type or both by declaring it in defaultConfig.
What happens when you build a multidex enabled app :
The Android build tools construct a primary DEX file (classes.dex) and supporting DEX files (classes2.dex, classes3.dex, and so on) as needed. The build system then packages all DEX files into your APK.
At runtime, the multidex APIs use a special class loader to search all of the available DEX files for your methods (instead of searching only in the main classes.dex file).
Cause of Exception :
When building each DEX file for a multidex app, the build tools perform complex decision-making to determine which classes are needed in the primary DEX file so that your app can start successfully. If any class that's required during startup is not provided in the primary DEX file, then your app crashes with the error java.lang.NoClassDefFoundError.
This shouldn't happen for code that's accessed directly from your app code because the build tools recognize those code paths, but it can happen when the code paths are less visible such as when a library you use has complex dependencies. For example, if the code uses introspection or invocation of Java methods from native code, then those classes might not be recognized as required in the primary DEX file.
So if you receive java.lang.NoClassDefFoundError, then you must manually specify these additional classes as required in the primary DEX file by declaring them with the multiDexKeepFile (shown above) or the multiDexKeepProguard (refer documentation) property in your build type. If a class is matched in either the multiDexKeepFile or the multiDexKeepProguard file, then that class is added to the primary DEX file.
For complete documentation on multidex refer https://developer.android.com/studio/build/multidex
Click to AndroidManifest.xml look at the bottom of the files page you gonna see "Text" and "Merged Manifes" then click to "Merged Manifest" -> Search for "android.support.v4.content.FileProvider" then change it with "androidx.core.content.FileProvider"
Thats it, exact solution.
change
<provider android:name="android.support.v4.content.FileProvider"
to
<provider android:name="androidx.core.content.FileProvider"
tested and works for me
FileProvider was introduced with Android API Level 22 which is Lollipop, that is why you did not face the ClassNotFoundException when testing on a Lollipop device. Android Kitkat does not have the FileProvider class and hence you are facing the exception. If you are looking to access files this post should help you out
guys i have two questions:
1) how to test complete app (i mean run test, not unit) on each api from minSDK version which i set up. Is it any auto process for that?
2) after publish my app i have ANR error on my app publish console (system run 4.4 Kitkat):
java.lang.RuntimeException:
at android.app.ActivityThread.installProvider(ActivityThread.java:5011)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4582)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method:0)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method:0)
Caused by: java.lang.ClassNotFoundException:
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:4996)
i set up avd emulator with similar config on my android studio i after compile i have below exception:
1829-2839/com.google.android.gms.persistent E/LoadManifestTask: Can't find Chimera operation impl class com.google.android.location.copresence.GcmRegistrationChimeraReceiver dropping operation
java.lang.ClassNotFoundException: Didn't find class "com.google.android.location.copresence.GcmRegistrationChimeraReceiver" on path: DexPathList[[zip file "/system/framework/com.android.media.remotedisplay.jar", zip file "/system/framework/com.android.location.provider.jar", zip file "/system/priv-app/PrebuiltGmsCore.apk", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes2.zip", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes3.zip", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes4.zip", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes5.zip"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
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 bws.<init>(:com.google.android.gms:799)
at bwt.run(:com.google.android.gms:2049)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
[ 05-25 03:04:16.195 1623: 1638 D/ ]
HostConnection::get() New Host Connection established 0xb9183a30, tid 1638
Any Idea what cuse this problem?
My app work fine on Lollipop and Nugat.
I paste also my gradle:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId 'com.fff.hhh'
minSdkVersion 15
targetSdkVersion 25
versionCode 8
versionName '4.0'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
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 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.android.gms:play-services:10.2.6'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.github.bumptech.glide:glide:3.8.0'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
}
As described official docs:
You are strongly encouraged to use the GoogleApiClient class to
access Google Play services features. This approach allows you to
attach an OnConnectionFailedListener object to your client. To
detect if the device has the appropriate version of the Google Play
services APK, implement the onConnectionFailed() callback method. If
the connection fails due to a missing or out-of-date version of the
Google Play APK, the callback receives an error code such as
SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, or
SERVICE_DISABLED. ... Another approach is to use the
isGooglePlayServicesAvailable() method. You get a reference to the
singleton object that provides this method using
GoogleApiAvailability.getInstance(). You might call this method in
the onResume() method of the main activity. If the result code is
SUCCESS, then the Google Play services APK is up-to-date and you can
continue to make a connection.
Please make sure you're following these rules.
To test the app against the particular version :
1. Write espresso test
2. run those tests on the device with desired api level
To solve the gcm problem Add
apply plugin: 'com.google.gms.google-services'
at the end of your build.gradle you have pasted above.
I have an Android project, inside I have a library module, my project works fine, compile the project I get the .aar included in a test project and everything ok.
Now,I have added in my library module a Activity that extends Application, Y Added this class in the manifiest.xml of the library
<application
android:allowBackup="true"
android:label="#string/app_name"
android:name=".MyActivityExtendsApplications"
When I test the project it works perfect, but when I take the .aar and test it on other project fails. The problem is that it does not find the activity extend Application ... I have decompiled the aar and I see that everything is correct, all class are inside the folder
The error is
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mylibrary.MyActivityExtendsApplications" on path: DexPathList[[zip file "/data/app/com.myapplication-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myapplication-1/lib/arm, /vendor/lib, /system/lib]]
Suppressed: java.lang.ClassNotFoundException: com.mylibrary.MyActivityExtendsApplications
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
I adding grandle dependency to library .aar In all cases in the same way
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:24.2.1'
compile 'com.android.support:design:24.2.1'
testCompile 'junit:junit:4.12'
compile 'mylibrary-debug.mylibrary-debug#aar'
}
repositories{
flatDir{
dirs 'libs'
}
}
I check merged manifest in my test Project and the activity is there
application
android:name="com.mylibrary.MyActivityExtendsApplications"
android:allowBackup="true"
And I can import this Activity in my test Project and see the code
And I added mylibrary in libs folder.
When I remove the activity MyActivityExtendsApplications, my library works fine.
The issue may be the the Android Beacon Library aar files are missing when you generate your library aar, and the exception description is simply misleading. I don't think classes from aar files are automatically merged when generating a new aar file. You might check to see if these files (like Beacon.class) are missing from your aar.
If this is indeed the problem, there are two possible solutions:
In your application, reference both your library aar file and the Android Beacon Library aar file.
Merge the classes from the first aar file into your new aar file. I have done this before with rather a rather inelegant shell script that I am happy to share, but there may be a better way to accomplish the same thing.
I am building a library in Android Studio which has multiple Gradle dependencies such as the estimote and firebase sdk. When I export the library as an aar and then import it to a sample project, I get a run time error:
E/UncaughtException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/estimote/sdk/BeaconManager;
at com.mgenio.sdk.BeaconSDK.init(BeaconSDK.java:87)
at com.mgenio.sdk.BeaconSDK.checkSDK(BeaconSDK.java:214)
at com.mgenio.sdk.BeaconSDK.access$800(BeaconSDK.java:33)
at com.mgenio.sdk.BeaconSDK$3.onResponse(BeaconSDK.java:186)
at com.mgenio.sdk.BeaconSDK$3.onResponse(BeaconSDK.java:182)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.estimote.sdk.BeaconManager" on path: DexPathList[[zip file "/data/app/com.mgenio.smartscansample-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mgenio.smartscansample-1/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
Is there a special way to export my aar library so it includes these external dependencies? Thanks!
I had a similar issue some months ago, if you're publishing your library in a repository, then you have to add an xml or another kind of file that contains the dependencies your library have.
And if you need yo use any class of those dependencies, when you compile your library in the gradle file in your app module, you have to add transitive=true to have access to this classes or resources like this
compile('mx.segundamano.doubleseekbarview'){
transitive=true
}
EDIT
If you're publishing to Bintray - Maven repository, add this lines to your gradle file at the same level where your bintray configuration is
task generateSourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier 'sources'
}
artifacts {
archives generateSourcesJar
}
Is there a special way to export my aar library so it includes these external dependencies?
No
Exept you deploy your aar into a maven or ivy repository.
These aar dependency have some inbuild functionality in itself such as ic-launcher icon , image,logo, animation and much more.
Dhamija Dependency is one of them. such as :-
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.0#aar'
compile 'com.daimajia.androidanimations:library:1.0.8#aar
but you can use a best commercial dependency inside aar Remove above dependency and use this :
implementation 'com.airbnb.android:lottie:2.5.4'
hope this will resolve your issue !
You just add the same dependencies to your sample project and let Gradle take care of it.
I was following the Firebase guide to adding FCM, and so I added the following dependencies to my app gradle:
compile 'com.google.android.gms:play-services:9.0.0'
apply plugin: 'com.google.gms.google-services'
And this one to my project gradle:
classpath 'com.google.gms:google-services:3.0.0'
After this, I added the google-services.json from the Firebase console settings by downloading it and adding it to my app directory.
Now I'm getting this error:
Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
If I follow the instructions and have my application to support multidex, my application crashes as soon as it launches.
Here is the error after adding multidex to my app:
05-20 01:25:32.253 19812-19812/com.cryogenos.pearsonvisionlimousine W/dalvikvm: VFY: unable to resolve static field 8723 (common_google_play_services_unknown_issue) in Lcom/google/android/gms/R$string;05-20 01:25:32.253 19812-19812/com.cryogenos.pearsonvisionlimousine W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x416b5e30)05-20 01:25:32.253 19812-19812/com.cryogenos.pearsonvisionlimousine E/AndroidRuntime: FATAL EXCEPTION: mainProcess: com.cryogenos.pearsonvisionlimousine, PID: 19812java.lang.NoClassDefFoundError: com.google.android.gms.R$stringat com.google.android.gms.common.internal.zzah.<init>
(Unknown Source)
at com.google.firebase.FirebaseOptions.fromResource(Unknown Source)
at com.google.firebase.FirebaseApp.zzbu(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1609)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1574)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5643)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5206)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5143)
at android.app.ActivityThread.access$1500(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1418)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5883)
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:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:688)
at dalvik.system.NativeStart.main(Native Method)
My phone's google play services is 9.0.0+.
I have updated to the latest play services and the repository in SDK manager.
EDIT:
My app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.cryogenos.pearsonvisionlimousine"
minSdkVersion 19
targetSdkVersion 23
versionCode 3
versionName "2.1"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
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.1.1'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
}
apply plugin: 'com.google.gms.google-services'
One possible way to avoid 64k Dex error is by including only those APIs which your app needs from Google Play Services.
Selectively compiling APIs into your executable
From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:
compile 'com.google.android.gms:play-services:9.0.0'
with these lines:
compile 'com.google.android.gms:play-services-fitness:9.0.0'
compile 'com.google.android.gms:play-services-wearable:9.0.0'
UPDATED
Well I read the doc, which says
Apps that rely on the Play Services SDK should always check the device for a compatible Google Play services APK before accessing Google Play services features
So you only need to check Google Play Service is available or not. And to do this you only need Google Actions, Base Client Library API.
compile 'com.google.android.gms:play-services-base:9.0.0'
as explained in documentation use Selectively compiling APIs into your executable which is best approach for you(take it in first priority insted of Multi Dex), because Multi-dex have some limitations check before proceed.
Avoiding the 64K Limit - Proguard will help you
Before configuring your app to enable use of 64K or more method
references, you should take steps to reduce the total number of
references called by your app code, including methods defined by your
app code or included libraries. The following strategies can help you
avoid hitting the dex reference limit:
Review your app's direct and transitive dependencies - Ensure any large library dependency you include in your app is used in a manner
that outweighs the amount of code being added to the application. A
common anti-pattern is to include a very large library because a few
utility methods were useful. Reducing your app code dependencies can
often help you avoid the dex reference limit.
Remove unused code with ProGuard - Configure the ProGuard settings for your app to run ProGuard and ensure you have shrinking enabled for
release builds. Enabling shrinking ensures you are not shipping unused
code with your APKs.
Using these techniques can help you avoid the
build configuration changes required to enable more method references
in your app. These steps can also decrease the size of your APKs,
which is particularly important for markets where bandwidth costs are
high.
So, try to avoid Multi-Dex
one more thing when you use compile 'com.android.support:design:23.1.1' then you not need to use compile 'com.android.support:appcompat-v7:23.1.1' and compile 'com.android.support:support-v4:23.1.1'. so remove v7 & v4 from build.gradle file
First check if the multidex has really worked, you can do that by renaming the apk file to zip and extracting it. There should 2 multiple classes.dex files.
Secondly, it can also happen if earlier to reduce the method you must have used proguard, so just comment the use of proguard and it should work.
Otherwise paste your exception here.
Something wrong.
Checking the doc you only need this dependency
dependencies {
compile 'com.google.firebase:firebase-messaging:9.0.0'
}
So you can remove this dependency
//compile 'com.google.android.gms:play-services:9.0.0'
If it is not enough and you have more than 65536 methods you can use the multidex support.
Just add these lines in the build.gradle:
android {
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Also in your Manifest add the MultiDexApplication class from the multidex support library to the application element
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
and override attachBaseContext method:
#Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(newBase);
MultiDex.install(this);
}
If you are using a own Application class, change the parent class from Application to MultiDexApplication.