IllegalAccessError: Method is inaccessible to class

前端 未结 3 1823
耶瑟儿~
耶瑟儿~ 2021-02-10 02:09

I\'ve got very strange error, because it only happens after installing app from generated .apk. When I try to run the app through IDE, it works fine.



        
3条回答
  •  猫巷女王i
    2021-02-10 03:00

    From the official Kotlin documentation:

    Java allows accessing protected members from other classes in the same package and Kotlin doesn't, so Java classes will have broader access to the code

    So, please make sure that your BaseActivity and MyActivity are under the same package.

    If both activities are not under the same package then it will run perfectly by direct run from Studio, but it will crash (IllegalAccessError) while you generate .apk and try to run on the device by installing that apk.

提交回复
热议问题