androidadbandroid-debugcwac-camera

Android Studio debugger stepping though old version of code, not up to date


I'm new to Android dev so I may be missing something obvious that I can try.

I'm trying to debug some code but the debugger is stepping through the old version of the code, and not current version in my project.

wrong debug line Clearly it has skipped past my exception 'throw' and into commented code

I have tried:

This is actually the cwac demo v9, so it's a demo app that uses the 'camera' library, and it is in the cwac camera library project that I am debugging.

What's unclear to me is where and what is built by gradle, so I haven't 'hard cleaned' anything from Windows explorer. I can't even check file dates...

What tips can you give me please for how to check that the latest code is going out to the device?

Thanks.


Solution

  • Being an Android newbie and up against the complexity of the IDE/gradle (wish it were more like Visual Studio!), it was difficult for me to find the problem, but I did and it was particular to the CWAC-Camera project (fresh from GitHub).

    FWIW why is it such a complex IDE/build system, it seems like a lot of this could be internalized (I mean, get gradle out of view)..?

    SOLUTION

    File->Project Structure->(Choose the module on the left that you run, for me it is camera-v9)->(Choose Dependencies tab)

    There should be a Maven library entry for the CWAC camera, marked as Scope=="Release compile", and also a Module library, scope=="Debug compile".

    I removed the Maven library entry, and changed the Module entry to scope=="Compile". Then it worked.

    So what was happening is that the Maven copy of the library was being used instead of the module. Why? Not sure because I would have thought that running the 'debugger' on something would necessitate 'debug' build mode. I found this but cannot follow the accepted answer (because I don't know the IDE well enough) Why does Gradle build my module in Release mode when the app is in Debug

    I don't know if it's just a slip in the CWAC demo project, or something wrong in my setup. Seems to me that using the Maven lib for Release could produce unexpected results (ie. customizations are gone).

    Having said all of that, CWAC seems to be a life saver and am very grateful for it!