Android Studio debugger works, although the old version of the code is not updated

I am new to Android developer, so I can skip something obvious that I can try.

I am trying to debug some code, but the debugger is stepping over the old version of the code, not the current version in my project.

wrong debug line Obviously, he skipped past my exception "throw" and in the commented code

I tried:

  • Removing the previous apk installed on the device
  • Rebuild / clean
  • Using Genymotion and a real device (Gingerbread)
  • adb kill-server
  • Restart and. Studio
  • Related Questions about SO

This is actually cwac demo v9, so this is a demo application that uses the camera library, and this is in the cwac camera library project that I am debugging.

What is incomprehensible to me, where and what is built by gradle, so I did not "strongly remove" anything from Windows explorer. I can’t even check file dates ...

What advice can you give me, please, how to check that the latest code is coming to the device?

Thanks.

+5
source share
2 answers

Being an Android newbie and against the complexity of IDE / gradle (I would like it to be more like Visual Studio!), I found it difficult to find the problem, but I did it, and it was especially important for CWAC -Camera (fresh from GitHub).

FWIW Why is it such a complex IDE / build system, it seems that many of them can be internalized (I mean, get gradle out of sight) ..?

DECISION

File-> Project Structure → (Select the module on the left that you are launching, for me this is camera-v9) → (Dependencies tab)

For a CWAC camera, there must be a Maven entry labeled Scope == "Release compile", as well as a Module library, scope == "Debug compile".

I deleted the Maven library entry and changed the module entry in scope == "Compile". Then it worked.

So what happens is that instead of the module, a copy of the Maven library was used. What for? Not sure, because I thought launching a "debugger" on something would require "debugging" the build mode. I found this, but I can’t fulfill the accepted answer (because I don’t know the IDE well enough) Why gradle builds my module in Release mode when the application is in Debug

I don’t know if this is just a miss in the CWAC demo project or something is wrong in my setup. It seems to me that using Maven lib for Release may lead to unexpected results (i.e. Settings have already disappeared).

Having said all this, CWAC seems to save a life and is very grateful for that!

+1
source

Try it. Open the app build.gradle file and make changes (just add a space). Then click the "Sync Now" button in the upper right corner.

I'm not too sure what happens with caching, but that seems to have fixed this for me.

+1
source

Source: https://habr.com/ru/post/1216214/


All Articles