m4gr3d / Godot-Android-Plugin-Template

This repository serves as a quickstart template for building a Godot Android plugin for Godot 4.2+.
MIT License
43 stars 11 forks source link

App crash with java.lang.ClassNotFoundException #2

Closed code-with-max closed 11 months ago

code-with-max commented 11 months ago

Hello. App died with java.lang.ClassNotFoundException when I used this template.

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]]

It`s crashed with any imported classes, not only GoogleApiAvailability, also task.Task and others.

import com.google.android.gms.common.GoogleApiAvailability
import com.google.android.gms.tasks.*

upd: https://github.com/godotengine/godot/issues/86152

lettdev commented 11 months ago

Same error, it seems that the classes from dependencies are not included in the apk's classes.dex and game always crash with java.lang.ClassNotFoundException. I try a lot of different way but no luck

kyadalu1 commented 11 months ago

I face similar issue here

code-with-max commented 11 months ago

@lettdev @kyadalu1

Solution https://github.com/godotengine/godot/issues/86152#issuecomment-1858817419

m4gr3d commented 11 months ago

@trash-max @lettdev @kyadalu1 The dependencies you're trying to import are not included in the Godot Android library since they're not part of the Godot project; they're part of Google's set of libraries.

To include them in your project, you need to update build.gradle.kts and the _get_android_dependencies method with the correct build dependencies.

kyadalu1 commented 11 months ago

@m4gr3d Godot relies on kotlin v1.7.0 so i think coroutines needs to be added as separate dependency. In many of my native android projects which uses kotlin v1.9.20 and even for some which uses kotlin v1.8.20, i never had to add couroutines as separate dependency.

Will Godot 4.3 update kotlin version to 1.8 or 1.9?

m4gr3d commented 11 months ago

@m4gr3d Godot relies on kotlin v1.7.0 so i think coroutines needs to be added as separate dependency. In many of my native android projects which uses kotlin v1.9.20 and even for some which uses kotlin v1.8.20, i never had to add couroutines as separate dependency.

Will Godot 4.3 update kotlin version to 1.8 or 1.9?

Yes, we should be able to update the Kotlin version for Godot 4.3.

kyadalu1 commented 10 months ago

@m4gr3d Its good to know that kotlin version will be updated for Godot 4.3 but when i try to change it manually like this any idea why it still fails, what else do i need to update?

m4gr3d commented 10 months ago

@m4gr3d Its good to know that kotlin version will be updated for Godot 4.3 but when i try to change it manually like this any idea why it still fails, what else do i need to update?

@kyadalu1 The values shown in the config.gradle file match the values used by the Godot Editor when it's exporting the Godot app binary. As such, any changes you make locally won't take effect since the values used by the Godot Editor remain the same.

kyadalu1 commented 10 months ago

@m4gr3d Can you tell how to update the value in Godot Editor?

Screenshot 2024-01-04 at 8 36 58 AM

I don't see updating the kotlin version option in above screenshot.

Do i have to download godot source code, update kotlin version and somehow recompile the engine for it to take effect?

m4gr3d commented 10 months ago

The values cannot be updated from the Godot Editor.

Do i have to download godot source code, update kotlin version and somehow recompile the engine for it to take effect?

Yes, you would have to rebuild the engine from source for the changes to take effect.

myselfuser1 commented 10 months ago

@m4gr3d Can we get kotlin 1.9.20 in Godot 4.3?

m4gr3d commented 10 months ago

@m4gr3d Can we get kotlin 1.9.20 in Godot 4.3?

Done in https://github.com/godotengine/godot/pull/87346

myselfuser1 commented 10 months ago

@m4gr3d Thank you so much