I've below code
println("Result: '${Method::class.java.getDeclaredField("signature")}'")
When I execute this code on JVM
, I get valid result
import java.lang.reflect.Method
fun main(args: Array<String>) {
println("Result: '${Method::class.java.getDeclaredField("signature")}'")
}
// OUTPUT: Result: 'private transient java.lang.String java.lang.reflect.Method.signature'
but when I execute the same line in Android, I get No field signature in class Ljava/lang/reflect/Method
.
Here's the complete stacktrace
2021-04-24 15:16:49.564 13890-13890/com.theapache64.notes E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.theapache64.notes, PID: 13890
java.lang.RuntimeException: Unable to create application com.theapache64.notes.NotesApp: java.lang.NoSuchFieldException: No field signature in class Ljava/lang/reflect/Method; (declaration of 'java.lang.reflect.Method' appears in /apex/com.android.runtime/javalib/core-oj.jar)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6652)
at android.app.ActivityThread.access$1600(ActivityThread.java:231)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1952)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.lang.NoSuchFieldException: No field signature in class Ljava/lang/reflect/Method; (declaration of 'java.lang.reflect.Method' appears in /apex/com.android.runtime/javalib/core-oj.jar)
at java.lang.Class.getDeclaredField(Native Method)
at com.theapache64.notes.NotesApp.onCreate(NotesApp.kt:20)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1197)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6647)
at android.app.ActivityThread.access$1600(ActivityThread.java:231)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1952)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
2021-04-24 15:16:49.597 13890-13890/? I/Process: Sending signal. PID: 13890 SIG: 9
- Why is this happening?
Aucun commentaire:
Enregistrer un commentaire