No such instance field

前端 未结 6 1261
醉酒成梦
醉酒成梦 2020-12-09 16:54

I\'m trying to get my application to save some data when the orientation of the screen is changed using the onSaveInstanceState to save a boolean value mC

相关标签:
6条回答
  • It turns out there wasn't a problem with the code and that Android Studio required a restart. I think it was down to the fact I had cloned the project and was possibly using an incorrect file from the previous version.

    0 讨论(0)
  • 2020-12-09 17:26

    Check if your build variant in Android Studio has

    • debuggable as true
    • proguard is disabled or commented out.
    0 讨论(0)
  • 2020-12-09 17:29

    I got the same error and I wasted my 3-4 hours to resolve same error finally I got to know why that happened and it was interesting

    1. In my case, I changed the code in one file (I declared one variable and initialized it)

    2. I run the apk from my device and attached debugger from android studio

    3. I set debug point to that newly added variable where I assigned data to it

    4. but during debugging it shows me same error

    5. Then I got to know I changed the code in file but I run the apk from device, and I attached debugger I need to compile and run the changes instead of it how it will reflect in apk that was the actual issue

    6. So I compiled and ran the code and installed newly compiled apk on device then I attached debugger and it worked for me

    hope this will save someone's time

    0 讨论(0)
  • 2020-12-09 17:30

    I had the same error. The solution to the error is to disable the Proguard in build.gradle file.

     debug {
            minifyEnabled false
    }
    
    0 讨论(0)
  • 2020-12-09 17:42

    If you're using pro-guard and obfuscation is true. you have to comment out obfuscation in build gradle

    eg: add this in the pro-guard -dontobfuscate

    0 讨论(0)
  • 2020-12-09 17:44

    In case this comes in handy for anyone else, I was able to resolve this issue immediately once I realized I was in 'Release' mode, not 'Debug' mode, in the Build Variants section.

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