[英]Android Studio: run/debug release version of app
I have added gradle build to Android app, and can launch from Android Studio.我已经将 gradle build 添加到 Android 应用程序,并且可以从 Android Studio 启动。
gradlew build
produces debug and released (signed, minified with proguard) versions. gradlew build
生成调试和发布(签名,使用 proguard 缩小)版本。
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.但是当我在设备上
adb install
发布版本时,它会在启动时崩溃。
How can I run/debug release version of app from Android Studio to find exact place of problem?如何从 Android Studio 运行/调试应用程序的发布版本以找到问题的确切位置?
Or can I debug manually released signed apk in Eclipse?或者我可以在 Eclipse 中调试手动发布的签名 apk 吗?
There's a window called 'Build Variants' where you can choose, which version you want to be installed on your emulator/device.有一个名为“Build Variants”的窗口,您可以在其中选择要在模拟器/设备上安装的版本。
You also have to add debuggable true
to your release build to be able to debug it.您还必须在发布版本中添加
debuggable true
才能对其进行调试。
Also You can use你也可以使用
View -> Tool Windows -> Build Variants
Additionally you can use Gradle
toolbar or ./gradlew tasks --all
此外,您可以使用
Gradle
工具栏或./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. *Android Studio v4.2 默认不包含
Tasks
。 You should disable Do not build Gradle task list during Gradle sync
in Preferences -> Experimental
您应该在
Preferences -> Experimental
禁用Do not build Gradle task list during Gradle sync
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. 如果您使用的是gradle插件的0.14.0或更高版本,则应在build.gradle文件
minifyEnabled
“runProguard”替换为“minifyEnabled”。
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. minifyEnabled false表示构建类型名称不能是main或androidTest(这是由插件强制执行的),并且它们必须彼此唯一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.