HMS-Core / hms-cordova-plugin

This repo contains all of Cordova HMS plugins.
https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin?ha_source=hms1
Apache License 2.0
88 stars 40 forks source link

Plugin breaks reflection: java.lang.AssertionError: Built-in class kotlin.Any is not found #128

Closed kristiyanP closed 11 months ago

kristiyanP commented 12 months ago

Description When I add the cordova push plugin on cordova 10&11 the plugin breaks reflection code. Steps to reproduce: Create class

class HelloPrinter() {

    companion object {
        fun test(){
            HelloPrinter::class.java.methods
                .filter { it.name =="helloWorld" }
                .mapNotNull { it.kotlinFunction }
                .forEach { it.call() }
        }
    }

    fun helloWorld() {
        Log.e("Hello", "world")
    }
}

Invoke test method in MainActivity extends CordovaActivity

 @Override
public void onCreate(Bundle savedInstanceState){
       // ....
      com.bandyer.cordovasampleapp.HelloPrinter.Companion.test();
}

Expected behavior That everything works.

Current behavior java.lang.AssertionError: Built-in class kotlin.Any is not found

Environment

Other From my debug it looks like that applying the plugin with afterEvaluate breaks the kotlin reflection https://github.com/HMS-Core/hms-cordova-plugin/blob/master/cordova-plugin-hms-push/src/android/build-extras.gradle#L41-L49 In fact if you modify it as the capacitor way it works.

ozkulbeng commented 11 months ago

Hi @kristiyanP

Thank you for your contribution, it is highly appreciated. 🎉 Due to our internal development and release flow & checks, we can't merge your PR directly. You can be sure that the fix will be released with our next major update.