Hello defold team
I try to add helpshift (Getting Started | Helpshift Developer Guide). But when I call function showConversation или showFAQs - crash
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/app/AppCompatActivity;
I try add android.support.v7.app; but its cant find
Are you creating a HelpShift extension of your own or are you using an existing one? If so, which one? Does you Helpshift extension have a build.gradle file which includes appcompat as mentioned in the docs you linked?
In general the Android support library (AppCompat) is not recommended for use by Google. Instead Google recommends that developers should use AndroidX. Defold uses AndroidX by default, but if you really don’t want to use it you can disable it:
Note that most extensions use AndroidX so by disabling it in your app those other extensions will probably not work.
I noticed that HelpShift is still using the old Android support library. I wonder why they aren’t updating?
Are you using an app manifest file? And if so, can you please verify that “Use Android Support Lib” is NOT checked: Native extensions - Build variants
Please verify that the “Target SDK Version” in game.project is 28 or higher.
If you do have Target SDK Version set to 28 or higher and if you have not checked “Use Android Support Lib”, then Gradle should automatically migrate the HelpShift library to use Android X. Exactly as described here:
And the setting should be enabled by default. BUT now that I look at the code I see it as the default in the template.appmanifest in the editor:
This file is used when you create a .appmanifest file from the editor, but I don’t see that we default to using Jetifier if you don’t have an appmanifest file.
Ok, try this:
Create a foobar.appmanifest (File->New->App Manifest)
Leave everything as default
Use foobar.appmanifest in game.project Native Extension → App Manifest
Rejecting re-init on previously-failed class java.lang.Class<com.helpshift.activities.HSMainActivity>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/app/AppCompatActivity;
at boolean com.helpshift.util.ApplicationUtil.isApplicationInDebugMode(android.content.Context) (ApplicationUtil.java:28)
at void com.helpshift.Helpshift$4.run() (Helpshift.java:166)
at void com.helpshift.util.SafeWrappedRunnable.run() (SafeWrappedRunnable.java:20)
at java.lang.Object java.util.concurrent.Executors$RunnableAdapter.call() (Executors.java:459)
at void java.util.concurrent.FutureTask.run() (FutureTask.java:266)
at void java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) (ThreadPoolExecutor.java:1167)
at void java.util.concurrent.ThreadPoolExecutor$Worker.run() (ThreadPoolExecutor.java:641)
if add lib - android-support-v7-appcompat.jar
and in java file add import android.support.v7.app.AppCompatActivity;
error when call Helpshift.install
Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatActivity>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/app/FragmentActivity;
at boolean com.helpshift.util.ApplicationUtil.isApplicationInDebugMode(android.content.Context) (ApplicationUtil.java:28)
at void com.helpshift.Helpshift$4.run() (Helpshift.java:166)
at void com.helpshift.util.SafeWrappedRunnable.run() (SafeWrappedRunnable.java:20)
at java.lang.Object java.util.concurrent.Executors$RunnableAdapter.call() (Executors.java:459)
at void java.util.concurrent.FutureTask.run() (FutureTask.java:266)
at void java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) (ThreadPoolExecutor.java:1167)
at void java.util.concurrent.ThreadPoolExecutor$Worker.run() (ThreadPoolExecutor.java:641)
at void java.lang.Thread.run() (Thread.java:764)
if add lib android-support-v4.jar - build error
Error in /tmp/job4827484569690883035/upload/helpshift/lib/android/android-support-v4.jar:android/support/v4/media/MediaBrowserCompat$CallbackHandler.class:
Type android.support.v4.media.MediaBrowserCompat$CallbackHandler is defined multiple times: /tmp/job4827484569690883035/upload/helpshift/lib/android/android-support-v4.jar:android/support/v4/media/MediaBrowserCompat$CallbackHandler.class, /tmp/.gradle/unpacked/androidx.media-media-1.0.0.aar/classes.jar:android/support/v4/media/MediaBrowserCompat$CallbackHandler.class
Compilation failed
Exception in thread “main” java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: /tmp/job4827484569690883035/upload/helpshift/lib/android/android-support-v4.jar:android/support/v4/media/MediaBrowserCompat$CallbackHandler.class
at com.android.tools.r8.utils.w.a(SourceFile:92)
at com.android.tools.r8.D8.main(D8.java:4)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: /tmp/job4827484569690883035/upload/helpshift/lib/android/android-support-v4.jar:android/support/v4/media/MediaBrowserCompat$CallbackHandler.class
at Version.fakeStackEntry(Version_3.0.41-sc03.java:0)
at com.android.tools.r8.utils.w.a(SourceFile:68)
at com.android.tools.r8.utils.w.a(SourceFile:28)
at com.android.tools.r8.utils.w.a(SourceFile:27)
at com.android.tools.r8.utils.w.b(SourceFile:3)
at com.android.tools.r8.D8.a(D8.java:17)
at com.android.tools.r8.D8.a(D8.java:15)
at com.android.tools.r8.utils.w.a(SourceFile:84)
… 1 more
Caused by: com.android.tools.r8.internal.b: Type android.support.v4.media.MediaBrowserCompat$CallbackHandler is defined multiple times: /tmp/job4827484569690883035/upload/helpshift/lib/android/android-support-v4.jar:android/support/v4/media/MediaBrowserCompat$CallbackHandler.class, /tmp/.gradle/unpacked/androidx.media-media-1.0.0.aar/classes.jar:android/support/v4/media/MediaBrowserCompat$CallbackHandler.class
at com.android.tools.r8.internal.TA.a(SourceFile:14)
at com.android.tools.r8.internal.TA.a(SourceFile:22)
at com.android.tools.r8.internal.Ew.b(SourceFile:6)
at com.android.tools.r8.internal.Ew.a(SourceFile:23)
at com.android.tools.r8.internal.Ew.a(SourceFile:10)
at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2048)
at com.android.tools.r8.internal.Ew.a(SourceFile:6)
at com.android.tools.r8.graph.I0$c.f(SourceFile:3)
at com.android.tools.r8.dex.a.a(SourceFile:94)
at com.android.tools.r8.dex.a.a(SourceFile:23)
at com.android.tools.r8.D8.a(D8.java:21)
at com.android.tools.r8.D8.d(D8.java:6)
at com.android.tools.r8.D8.c(D8.java:1)
at com.android.tools.r8.utils.w.a(SourceFile:24)
You could also try to manually jettify the lib to make it Android X compatible. Download the .aar file, unpack it, grab the .jar file. Run the jettifier tool (as per instructions on the HelpShift page).
I also think you need to initialize the HelpShift SDK from Application.onCreate() which is problematic. This needs to be confirmed though.
It seems like this is some issue with jetifier for that plugin, here is an instruction how to do it manually, but you’ll have to put jar file into a lib folder instead of using Gradle file for the android version: