我正在尝试安装相同的应用程序,但具有不同的版本/变体。所以我找到了这个博客。
https://blog.grandcentrix.net/how-to-install-different-app-variants-on-one-android-device/
我想用不同的应用程序针对不同的sprint对博客的图片执行相同的操作
这是我的gradle文件:
apply plugin: 'com.android.application'
def debugsuffix = System.getProperty('debugsuffix', project.getProperties().get('debugsuffix', null))
def final appId = 'com.arthlimchiu.testapp'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId = appId
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
dev {
applicationId = appId + "." + debugsuffix + ".dev"
resValue "string", "app_name", ".dev-" + debugsuffix
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}
运行此命令后:
在Gitbash中,我在Windows上
debugsuffix为NULL。
这是我尝试通过显示debugsuffix作为应用程序名称进行调试时的屏幕截图。
我在正确执行命令吗?还是我错过了什么?这是我第一次用传递的参数来进行这样的gradlebtw。有人尝试过吗?这真的是一个很好的帮助:)
最佳答案
我终于做到了!我实际上阅读了Gradle提供的免费电子书。并且了解了如何解决如何在一台设备上安装多个相同应用的想法。
这是我的Gradle文件。
apply plugin: 'com.android.application'
def debugsuffix = System.getProperty('debugsuffix', project.getProperties().get('debugsuffix', null))
def final appId = 'com.arthlimchiu.testapp'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId = appId
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
applicationIdSuffix ".$debugsuffix"
resValue "string", "app_name", "testApp-$debugsuffix"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}
然后您运行以下命令:
您可以在命令行中用空格隔开链接任务。
这是输出:
您现在可以执行[AppName] -Sprint1等或[AppName] -bug-fix-05之类的操作。这样的事情。
关于android - 为gradle传递的参数为null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39101068/