Reflection not working on android release apk. Even with proguard/minify disabled

前端 未结 1 1836
悲&欢浪女
悲&欢浪女 2021-01-21 18:04

Currently I\'m facing an odd issue that the release apk of my app throws NoSuchFieldExceptions. It works fine on a debug apk.

The fields I am trying to get are android.w

相关标签:
1条回答
  • 2021-01-21 18:32

    An IllegalAccessException means it can see the variable/method, but that it can't access it because its private (or because its protected and this isn't the same package). This isn't a case of reflection not working, its a common bug that without reflection wouldn't compile.

    You can change the visibility of the variable/method at runtime using reflection and then access it, but its not recommended. Its better to add a public method that does what you need, to prevent the possibility of changing data in ways the class wasn't written to accept.

    0 讨论(0)
提交回复
热议问题