godot: 4.2 version android plugin crash with java.lang.ClassNotFoundException

Tested versions

Reproduce in 4.2.1

System information

Ubuntu 23.10, Godot_v4.2.1-stable_linux.x86_64

Issue description

App died with java.lang.ClassNotFoundException when used this template - https://github.com/m4gr3d/Godot-Android-Plugin-Template It`s crashed with any imported classes, not only GoogleApiAvailability, also task.Task and others.

It seems that the classes from dependencies are not included in the apk’s classes.dex and game always crash with java.lang.ClassNotFoundException.

Steps to reproduce

  1. Start new plug-in with - https://github.com/m4gr3d/Godot-Android-Plugin-Template
  2. Import any library, e.g.
import com.google.android.gms.common.GoogleApiAvailability

and call it:

val googleApiAvailability = GoogleApiAvailability.getInstance()
val status: Int = googleApiAvailability.isGooglePlayServicesAvailable(activity!!)
  1. Assemble and install plug-in
  2. Run game with it
  3. Watch logcat:
2-13 11:28:55.970  5464  5464 F DEBUG   : Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.GoogleApiAvailability" on path: DexPathList[[zip file "/data/app/~~5i67fVLY5Ef9yC4AfWCKlw==/org.godotengine.classicsnake-ZMW6o20AcigpqLXz7bibYQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~5i67fVLY5Ef9yC4AfWCKlw==/org.godotengine.classicsnake-ZMW6o20AcigpqLXz7bibYQ==/lib/x86_64, /data/app/~~5i67fVLY5Ef9yC4AfWCKlw==/org.godotengine.classicsnake-ZMW6o20AcigpqLXz7bibYQ==/base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64]]

Minimal reproduction project (MRP)

Godot-Android-Plugin-Template.zip

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

I addressed the issue in my project

I overridden the export_plugin.gd example:

func _get_android_dependencies (platform, debug):
    if debug:
        return PackedStringArray(["com.google.android.gms:play-services-base:18.2.0"])
    else:
        return PackedStringArray(["com.google.android.gms:play-services-base:18.2.0"])

@pritish-thub it’s main class . Needed for my case: googleApiAvailability

@trash-max @Rrenovation One question which i would like to ask you guys is i face similar issue here. It is due to kotlin coroutines. Coroutines are part of kotlin lang and i am using version 1.9.10 and kotlin is not any third party dependency. If i use normal kotlin code my plugin works but as soon as i use coroutines it craashes. Any advice