Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Android app in debugging mode

My Android Studio version is 2.3.3

In my Android app gradle build, I have explictly defined different server_url string values for debug type and release type:

buildTypes {
        debug {
            resValue "string", "server_url", "https://myserver.debug.com/"
        }
        release {
            resValue "string", "server_url", "https://myserver.com/"
            ...
        }
    }

In my code, I get the string value by:

String url = context.getString(R.string.server_url);

I connected my Android phone to my laptop. The Android studio toolbar looks like this: enter image description here

I also selected build variants to be "debug":

enter image description here

I click the enter image description here, the app is running on my phone, however, it uses server_url value defined in release type. Why?

(Under build/generated/res/resValues/debug/generated.xml & build/generated/res/resValues/release/generated.xml I see those values, no problem there eihter.)

==== Update ===

Adding defaultPublishConfig 'debug' fixed the issue (Thanks @Ulug Toprak), but I am still wondering why Android Studio doesn't work without it though I have set Build Variant to "Debug". Maybe a bug in Android Studio?

like image 394
Leem.fin Avatar asked Jul 21 '17 13:07

Leem.fin


People also ask

What is Android debug mode?

USB Debugging mode is a developer mode in Samsung Android phones that allows newly programmed apps to be copied via USB to the device for testing. Depending on the OS version and installed utilities, the mode must be turned on to let developers read internal logs.

How do I enable debug on APK?

To start debugging an APK, click Profile or debug APK from the Android Studio Welcome screen. Or, if you already have a project open, click File > Profile or Debug APK from the menu bar. In the next dialog window, select the APK you want to import into Android Studio and click OK.


1 Answers

Just to answer your updated question,

Multi module setup (application + android library) will not log annotated methods/classes from Android Library Module but will do it on Android Application Module. The reason behind this, is that the Android Gradle Plugin will build all Android Libraries as release versions.

as suggested in the comments adding defaultPublishConfig "debug" to the build.gradle file will force the debug version

like image 141
Ulug Toprak Avatar answered Oct 13 '22 13:10

Ulug Toprak