Closed code-with-max closed 11 months ago
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"])
@Rrenovation Thanks my friend!!! It works.
@Rrenovation Thanks your for your answer. I am little confused. Suppose my android library uses implementation("androidx.biometric:biometric:1.1.0")
do i still need to com.google.android.gms:play-services-base:18.2.0
in PackedStringArray
Also similar issue occurs when i try to use Kotlin's coroutines, even for that do i still need to add com.google.android.gms:play-services-base:18.2.0
in PackedStringArray
@kyadalu1 I have tried many things with the 4.2 version of the Android plugin, and the compileOnly and implementation parameters seem more like compileOnly. implementation appears not to take effect.
@Rrenovation Why did you use com.google.android.gms:play-services-base:18.2.0
. I don't get it
@pritish-thub it's main class . Needed for my case: googleApiAvailability
@trash-max Doesn't seem to work for my use case. I am trying to import androidx.biometric:biometric:1.1.0
so i refactored the above code to
func _get_android_dependencies (platform, debug):
if debug:
return PackedStringArray(["androidx.biometric:biometric:1.1.0"])
else:
return PackedStringArray(["androidx.biometric:biometric:1.1.0"])
It works now, i am facing different issue. Thanks @trash-max @Rrenovation
@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
@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
Yup same here
@kyadalu1 Maybe the Godot android plugin might be using old kotlin version when coroutines where not part of kotlin and had to be added as a separate dependency
@kyadalu1 Godot 4.2.1 uses kotlin version 1.7.0 by default.
You can update it if need in /android/build/config.gradle
This part:
ext.versions = [
androidGradlePlugin: '7.2.1',
compileSdk : 33,
// Also update 'platform/android/export/export_plugin.cpp#OPENGL_MIN_SDK_VERSION'
minSdk : 21,
// Also update 'platform/android/export/export_plugin.cpp#DEFAULT_TARGET_SDK_VERSION'
targetSdk : 33,
buildTools : '33.0.2',
kotlinVersion : '1.7.0',
fragmentVersion : '1.3.6',
nexusPublishVersion: '1.1.0',
javaVersion : 17,
// Also update 'platform/android/detect.py#get_ndk_version()' when this is updated.
ndkVersion : '23.2.8568313'
Thanks @trash-max for your reply, I just updated it to kotlinVersion : '1.9.20',
but still same issue
Hey all, this is behavior as intended. The Godot Android library only includes Godot related classes and logic, and so any additional dependencies need to be specified both within build.gradle.kts
and within the _get_android_dependencies
method as @Rrenovation mentioned.
@kyadalu1 Kotlin coroutines are a separate dependency to avoid inflicting the cost on Kotlin users that don't make use of coroutines capabilities. You can find information about how to include the coroutine dependency at https://developer.android.com/kotlin/coroutines#dependency
@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?
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
and call it:
Minimal reproduction project (MRP)
Godot-Android-Plugin-Template.zip