Strange Android Exception
Here is what causes the problem in my case. Maybe it helps.
Context
:
I used Reflection
in my project. I had some private fields and wanted to fill them automatically via reflection.
To achieve this, I did the following:
Field field = MyClass.class.getDeclaredField("MyField");
field.setAccessible(true);
field.set(classInstance, "SomeValue");
field.setAccessible(false); // <- exactly this line was causing this error
After removing that line everything worked 100% fine and I never got the error again. I am not 100% sure why, but as far as I now understand, it is not necessary to reset the accessible flag to false again, because this is done automatically.