简体   繁体   中英

Android Studio: run/debug release version of app

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?

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

在此处输入图片说明

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

Also You can use

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

If you are using version 0.14.0 or higher of the gradle plugin, you should replace "runProguard" with " minifyEnabled " in your build.gradle files.

 minifyEnabled false

minifyEnabled false Means Build Type names cannot be main or androidTest (this is enforced by the plugin), and that they have to be unique to each other.

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

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM