I modified the build.gradle file for the Teapot example for the AGDK so that it has a debug build type as well as product flavors. My modifications are below.
buildTypes {
debug {
debuggable true
jniDebuggable true
minifyEnabled false
renderscriptDebuggable true
}
}
flavorDimensions "Dimension"
productFlavors {
development {
dimension "Dimension"
applicationIdSuffix ".dev"
}
production {
dimension "Dimension"
}
}
When I do this, the APK builds but Visual Studio can't find it to deploy to device for debugging. I get this error dialog.
What can I do to make this work?
Related
I have this structure:
1: https://i.stack.imgur.com/zrt1u.png
With gradle:
signingConfigs {
release {
//release stuff
}
debug {
//debug stuff
}
}
flavorDimensions "version"
productFlavors {
pro {
dimension "version"
}
lite {
dimension "version"
applicationIdSuffix ".lite"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
applicationIdSuffix ".debug"
debuggable true
signingConfig signingConfigs.debug
}
}
I have buildTypes release and debug (I need those for using server testing environment) and 2 Flavors, for Pro user and Lite users.
Everything is working fine and as expected, but I encountered some problem then trying to add different menu folder for release buildType and noticed that some res folder not recognized by the IDE as res folder. For example proDebug folder is with stripes icon recognized as res, but liteDebug are not, why is this?
Found the answer, it depends on the current selected Build Variant in the IDE
Hi i am trying to build a androidTest APK based on a flavour and a custom build type i have defined below:
productFlavors {
FlavourOne {
applicationIdSuffix ".live"
buildConfigField 'String', 'SERVER_BASE_URL', '"http://live.com"'
}
FlavourTwo {
applicationIdSuffix ".demo"
buildConfigField 'String', 'SERVER_BASE_URL', '"http://demo.com"'
}
}
buildTypes {
debug {
minifyEnabled false
// shrink code (remove unused classes and methods) - note that it falls back to experimental shrinker for Instant Run
shrinkResources false // don't strip unused res files
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'proguard-rules-debug.pro'
testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-test.pro'
}
release {
minifyEnabled true // shrink code (remove unused classes and methods)
shrinkResources false // don't strip unused res files
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debugDemo {
applicationIdSuffix '.demo'
versionNameSuffix '-DEMO'
minifyEnabled false
// shrink code (remove unused classes and methods) - note that it falls back to experimental shrinker for Instant Run
shrinkResources false // don't strip unused res files
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'proguard-rules-debug.pro'
testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-test.pro'
}
demo {
applicationIdSuffix '.demo'
versionNameSuffix '-DEMO'
minifyEnabled true // shrink code (remove unused classes and methods)
shrinkResources false // don't strip unused res files
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
When i run gradlew assembleFlavourOneDebugDemoAndroidTest i get an error straight away saying
Task 'assembleFlavourOneDebugDemoAndroidTest' not found in root project 'MyProject'.
It works fine if i omit my custom buildType and just do assembleFlavourOneAndroidTest and it works. It also works if do assembleFlavourOneDebugANdroidTest only...
According to the documentation only one Build Type is tested. By default it is the debug Build Type, but this can be reconfigured with:
android {
testBuildType "demo"
}
and your gradle task after sync should look like this:
./gradlew assembleFlavourOneDemoAndroidTest
and be careful there will be NO debug as you pointed out in your description at the end.
assembleFlavourOneDebugDemoAndroidTest
I faced the similar problem,
I need debug build type when develop,
debugMinify build type when run androidTest on pipeline or assembleAPK
so follow bellow code ,
You can run androidTest on debug type when develop
and when you run assemble APK command , testBuildType will be changed
android{
buildTypes{
release{}
debug{}
debugMinify{}
}
testBuildType getCurrentVariant()
}
def getCurrentVariant() {
Gradle gradle = getGradle()
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString()
println(tskReqStr)
if (tskReqStr.contains("assemble") && tskReqStr.contains("DebugMinify")) {
print("buidType: debugMinify")
return "debugMinify"
} else {
print("buidType: debug")
return "debug"
}
}
and
gradlew assembleDevelopDebugMinify
gradlew assembleDevelopDebugMinifyAndroidTest
[DefaultTaskExecutionRequest{args=[assembleDevelopDebugMinify],projectPath='null'}]
buidType: debugMinify
I'd assume some declarations lack the initWith instruction -
because any test build rigidly depends on initWith debug.
When using initWith release, no test tasks are generated.
debugDemo {
initWith debug
...
}
The initWith property allows you to copy configurations from other build types, then configure only the settings you want to change.
Below are the buildTypes and flavors parts of my build.gradle:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix '.debug'
versionNameSuffix '-DEBUG'
}
}
flavorDimensions "default"
productFlavors {
free {
android.sourceSets.free.setRoot('src/main')
dimension "default"
}
plus {
applicationIdSuffix '.plus'
versionName '1.0'
android.sourceSets.plus.setRoot('src/plus')
dimension "default"
}
}
Android Studio only shows two build variants (freeDebug and freeRelease) in the Build variants window. It does not show plusDebug or plusRelease. I have another project with a similar build.gradle and I can clearly see four build variants. Any ideas where I should look?
plus is a default method in groovy. It's not a bug in Android Studio or anything else. You are executing this function in DefaultGroovyMethods
public static <T> Set<T> plus(Set<T> left, T right) {
return (Set)plus((Collection)left, (Object)right);
}
This is because the delegate passed into productFlavors implements Set.
See productFlavors definition
This appears to be a bug/limitation in Gradle. I have filed an issue for it.
Use something else, other than plus. I tried quoting it ("plus"), thinking that perhaps it's a conflict with a keyword, but that had no effect. But Plus and plussss and phat all work.
I've been trying to build different product flavours to allow multiple side-by-side installs for our QA teams so I changed the applicationId to be different in each one.
buildTypes {
debug {
applicationId = "com.mypackagename.qa"
....
}
release {
applicationId = "com.mypackagename"
....
}
development {
applicationId = "com.mypackagename.development
....
}
}
However when I attempt to install them all, the release version is installed alone but both the development and the debug end up replacing each other.
Any thoughts on how to get them to install side by side?
Try to add versionNameSuffix. This is how it should look like:
buildTypes {
debug {
versionNameSuffix ".dev"
applicationIdSuffix '.dev'
}
iqa {
versionNameSuffix ".IQA"
debuggable true
signingConfig signingConfigs.debug
applicationIdSuffix '.IQA'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
How would one configure gradle to point to different lint files for different build types?
We want to translate strings at the end of a development cycle. So we need to ignore translation errors thrown by lint only on the debug version. When we make a release build lint should then throw the translations errors. The following build.gradle throws a DSL method not found.
android {
buildTypes {
release {
signingConfig signingConfigs.release
}
debug {
testCoverageEnabled = true
applicationIdSuffix '.debug'
versionNameSuffix '-DEBUG'
signingConfig signingConfigs.debug
lintOptions debug
}
beta {
applicationIdSuffix '.beta'
versionNameSuffix '- beta'
signingConfig signingConfigs.debug
}
}
lintOptions {
debug {
disable 'TypographyFractions'
}
}
}