https://kotlinlang.org logo
#android
Title
# android
p

Paulius Ruminas

05/16/2019, 8:35 AM
Hi, I have a Java SAM interface with internal modifier for the single method
void invoke();
. I use that SAM interface as a lambda expression in Kotlin from a different package. If I run this code from Android studio I don't get any runtime exception but if I bundle it into an APK then I receive
java.lang.IllegalAccessError
. Why is that?
g

gildor

05/16/2019, 8:37 AM
What is exact stack trace of IllegalAccessError?
p

Paulius Ruminas

05/16/2019, 8:40 AM
Copy code
05-16 11:00:44.568 14101 14101 E AndroidRuntime: java.lang.IllegalAccessError: Interface com.example.airidas.test2.test2.Test$ChangeHandler implemented by class com.example.airidas.test2.test.TestKt$test$1 is inaccessible (declaration of 'com.example.airidas.test2.test.TestKt$test$1' appears in /data/app/com.example.airidas.test2-1/base.apk)
05-16 11:00:44.568 14101 14101 E AndroidRuntime: 	at com.example.airidas.test2.test.TestKt.test(test.kt:6)
05-16 11:00:44.568 14101 14101 E AndroidRuntime: 	at com.example.airidas.test2.MainActivity.onCreate(MainActivity.kt:12)
05-16 11:00:44.568 14101 14101 E AndroidRuntime: 	at android.app.Activity.performCreate(Activity.java:6977)
05-16 11:00:44.568 14101 14101 E AndroidRuntime: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
05-16 11:00:44.568 14101 14101 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
05-16 11:00:44.568 14101 14101 E AndroidRuntime: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3064)
05-16 11:00:44.568 14101 14101 E AndroidRuntime: 	at android.app.ActivityThread.-wrap14(ActivityThread.java)
05-16 11:00:44.568 14101 14101 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1659)
05-16 11:00:44.568 14101 14101 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:102)
05-16 11:00:44.568 14101 14101 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:154)
05-16 11:00:44.568 14101 14101 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6823)
05-16 11:00:44.568 14101 14101 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
05-16 11:00:44.568 14101 14101 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563)
05-16 11:00:44.568 14101 14101 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)
8 Views