No such instance field

心已入冬 提交于 2019-11-30 11:36:45

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.

Android is everything for me

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

Check if your build variant in Android Studio has

  • debuggable as true
  • proguard is disabled or commented out.

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

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

 debug {
        minifyEnabled false
}

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!