25

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?

Paul Verest
  • 60,022
  • 51
  • 208
  • 332

3 Answers3

57

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.

carstenbaumhoegger
  • 1,575
  • 1
  • 18
  • 22
10

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

yoAlex5
  • 29,217
  • 8
  • 193
  • 205
1

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

enter image description here

Ali Dehkhodaei
  • 426
  • 3
  • 15
  • 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 version – Ramiro G.M. Dec 22 '22 at 17:11