Android Studio: run/debug release version of app
Asked Answered
G

3

29

I have added gradle build to Android app, and can launch from Android Studio. gradlew build produces debug and released (signed, minified with proguard) versions.

buildTypes {
    debug {
        zipAlignEnabled true
        versionNameSuffix "-" + buildDateTime()
    }
    release {
        minifyEnabled true
        // Eclipse project.properties # proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        zipAlignEnabled true
        signingConfig signingConfigs.release
        versionNameSuffix "-" + buildDateTime()
    }

But when I adb install on device the release version it crashes on start.

How can I run/debug release version of app from Android Studio to find exact place of problem?

Or can I debug manually released signed apk in Eclipse?

Gratulant answered 13/3, 2015 at 8:21 Comment(0)
C
63

There's a window called 'Build Variants' where you can choose, which version you want to be installed on your emulator/device.

enter image description here

You also have to add debuggable true to your release build to be able to debug it.

Corydon answered 13/3, 2015 at 8:38 Comment(6)
BTW must add debuggable true for release buildType see tools.android.com/tech-docs/new-build-system/…Gratulant
Yes, I missed that aspect, Android Studio only adds that for the debug builds.Corydon
More exactly those are defaults defined in android gradle plugin, not IDEGratulant
Well, I can run, but I cannot debug: Warning: debug info can be unavailable. Please close other application using ADB: Monitor, DDMS, Eclipse and Waiting for process: com.company.app . On devise side there is dialog "Waiting for debugger to connect" :-(Gratulant
That window is empty for me. No values are listedCotemporary
in .kts file : isDebuggable = trueNigro
P
13

Android Run .apk

View -> Tool Windows -> Build Variants

Additionally you can use Gradle toolbar or ./gradlew tasks --all

//install on device(which is running)
Tasks -> install -> install<build_varaiant>

//open 
adb shell am start -n <package_name>/.<activity_name>

*Android Studio v4.2 does not contain Tasks by default. You should disable Do not build Gradle task list during Gradle sync in Preferences -> Experimental

Peccavi answered 2/6, 2021 at 20:34 Comment(1)
Basically shorter version of the accepted answer.Gratulant
C
1

You can use Profile or Debug APK option in android studio and debug your release apk.

enter image description here

Cavort answered 15/12, 2022 at 9:50 Comment(1)
this options showed me an error on my debugabble release build that wasn't shown before. In my case I had to download and install a new skd versionGarfield

© 2022 - 2024 — McMap. All rights reserved.