Open bhlokhandwala opened 5 years ago
Can you share me error log regard this issue
The app initializes OK and is working fine on the iOS platform.
I also get the error described above using Ionic.
E.g. the app crashes when calling
(window as any).Freshchat.showConversations();
On Android it fails both on the Emulator and on a real device, both running Android version 8.0.0 (API 26)
Android dependencies in platforms/android/cordova-plugin-freshchat/app-build.gradle
dependencies {
compile 'com.github.freshdesk:freshchat-android:1.5.3'
compile 'com.google.android.gms:play-services-gcm:11.+'
}
The underlying error messages are:
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/graphics/drawable/DrawableWrapper;
at android.support.v7.widget.DrawableUtils.canSafelyMutateDrawable(DrawableUtils.java:147)
at android.support.v7.widget.AppCompatDrawableManager.tintDrawable(AppCompatDrawableManager.java:257)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:207)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:192)
at android.support.v7.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:184)
at android.support.v7.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:91)
at android.support.v7.widget.Toolbar.getWrapper(Toolbar.java:1780)
at android.support.v7.widget.ActionBarOverlayLayout.getDecorToolbar(ActionBarOverlayLayout.java:538)
at android.support.v7.widget.ActionBarOverlayLayout.pullChildren(ActionBarOverlayLayout.java:530)
at android.support.v7.widget.ActionBarOverlayLayout.setWindowCallback(ActionBarOverlayLayout.java:606)
at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:399)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:312)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:277)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.freshchat.consumer.sdk.activity.ChannelListActivity.onCreate(Unknown Source:12)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.graphics.drawable.DrawableWrapper" on path: DexPathList[[zip file "/data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/base.apk", zip file "/data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_dependencies_apk.apk", zip file "/data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_0_apk.apk", zip file "/data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_1_apk.apk", zip file "/data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_2_apk.apk", zip file "/data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_3_apk.apk", zip file "/data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_4_apk.apk", zip file "/data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_5_apk.apk", zip file "/data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_6_apk.apk", zip file "/data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_7_apk.apk", zip file "/data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_8_apk.apk", zip file "/data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/lib/x86, /data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/base.apk!/lib/x86, /data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_dependencies_apk.apk!/lib/x86, /data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_0_apk.apk!/lib/x86, /data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_1_apk.apk!/lib/x86, /data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_2_apk.apk!/lib/x86, /data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_3_apk.apk!/lib/x86, /data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_4_apk.apk!/lib/x86, /data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_5_apk.apk!/lib/x86, /data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_6_apk.apk!/lib/x86, /data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_7_apk.apk!/lib/x86, /data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_8_apk.apk!/lib/x86, /data/app/no.flexistore.app-ALplFuPPi-aCj4awifgEGQ==/split_lib_slice_9_apk.apk!/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 27 more
Also see the following issue https://github.com/freshdesk/freshchat-android/issues/22
It is possible to fix this issue by manually adding the missing dependencies to the app/build.gradle
file and make sure that the versions are aligned.
In my case I changed this, from
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: ":CordovaLib"))
compile "com.android.support:support-v4:24.1.1+"
compile "com.google.android.gms:play-services-maps:15.0.1"
compile "com.google.android.gms:play-services-location:15.0.1"
compile "com.android.support:support-core-utils:27.+"
compile "com.android.support:support-annotations:27.+"
// SUB-PROJECT DEPENDENCIES END
}
to
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: ":CordovaLib"))
compile "com.android.support:support-v4:27.1.1"
compile "com.google.android.gms:play-services-maps:15.0.1"
compile "com.google.android.gms:play-services-location:15.0.1"
compile "com.android.support:support-core-utils:27.1.1"
compile "com.android.support:support-annotations:27.1.1"
compile "com.android.support:appcompat-v7:27.1.1"
// SUB-PROJECT DEPENDENCIES END
}
and now the project builds and runs.
However this is not a workable solution...
I also see that the README.md
states:
Caveats Android : Needs appcompat-v7 : 21+ Needs support-v4 : 21+
If this is the case why are the dependencies not added to the plugin build?
I then forked the project and added the missing dependencies into src/android/Freshchat/build.gradle
dependencies {
compile 'com.github.freshdesk:freshchat-android:1.5.3'
compile 'com.google.android.gms:play-services-gcm:11.+'
compile "com.android.support:support-v4:27.1.1"
compile "com.android.support:appcompat-v7:27.1.1"
}
Using this forked version of the plugin instead also works/runs.
Hi @developerjohan01 ,
Android SDK 1.5.3 targets android sdk version 23. So SDK use support library version 23.4.0. If your target SDK version is higher than 23, you need to add necessary dependency versions for appcompat-v7 and recyclerview-v7.
You can refer below link to see dependencies and their versions in freshchat SDK version 1.5.3 https://github.com/freshdesk/freshchat-android/blob/a3cd78942801d84eababde3a389f5798f627012f/freshchat_sdk/build.gradle
Hi @MuthuFD the problem is not to work out what support libraries to use - the target sdk is 27 so above, version 27 is used (i.e. 27.1.1) The problem is that we are targeting version 27 and then need to add the support libraries, otherwise you get the error mentioned above
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/graphics/drawable/DrawableWrapper;
at android.support.v7.widget.DrawableUtils.canSafelyMutateDrawable(DrawableUtils.java:147)
...
The problem is that there is no place to add the support libraries or the versions to use, if you need them, via the plugin e.g. in the project config.xml
file... or am I missing something?
Adding/modifying the support libraries or changing the versions manually only works on a local build, as I described above.
Note that we are using Ionic and Ionic Appflow. When building on the server the whole Android environment is cleaned and re-created.
Hi @MuthuFD Your solution and reference to FreshChat Android SDK worked for me. Thank you. Added the following to the build.gradle and it worked:
ext { gsonVersion = '2.8.0' picassoVersion = '2.5.2' supportLibraryVersion = '27.1.1' }
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile "com.google.code.gson:gson:$gsonVersion" compile "com.squareup.picasso:picasso:$picassoVersion" compile "com.android.support:appcompat-v7:$supportLibraryVersion" compile "com.android.support:recyclerview-v7:$supportLibraryVersion" }
We got everything working by using the following plugin (together with the Fresh Chat cordova plugin) https://github.com/dpa99c/cordova-android-support-gradle-release This allows us to set the support library version.
The alternative is would be to update the Fresh Chat cordova plugin so that you can configure the support libraries via the plugin and not by updating the gradle file directly.
Updating the build.gradle
file manually is not an option if you are building on a server or are using continuous integration.
After integrating the Plugin and successful
(window as any).Freshchat.init({ appId : "xxxxx", appKey : "xxxx", gallerySelectionEnabled : true, cameraCaptureEnabled : true, teamMemberInfoVisible : true }, function(success){ console.log("Freshchat=====> This is called form the init callback"); });
After a function call on button click
(window as any).Freshchat.showConversations();
The application has stopped Open app again (https://user-images.githubusercontent.com/13188520/46713835-2c863400-cc76-11e8-9ea7-f5a84b2decad.jpeg)