Sign library before running Junit Android - android

I'm developing unit test using JUnit 4 on Android studio, but I need to sign the library before running tests to each function of the library to be accepted on my device. I'm trying the following:
build.gradle
android {
signingConfigs {
config {
keyAlias 'xxxxx'
keyPassword 'xxxxx'
storePassword 'xxxxxx'
storeFile file('cert/platform.jks')
}
}
compileSdkVersion 26
buildToolsVersion '26.0.2'
testBuildType "debug"
defaultConfig {
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.111"
externalNativeBuild {
cmake {
cppFlags "-fexceptions"
}
}
signingConfig signingConfigs.config
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
flavorDimensions "api"
productFlavors {
minApi17 {
dimension "api"
ndk.with {
moduleName = 'FAL'
abiFilters = ["armeabi"]
}
signingConfig signingConfigs.config
}
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
buildTypes {
debug {
signingConfig signingConfigs.config
}
release {
signingConfig signingConfigs.config
}
}
}
dependencies {
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation files('libs/zxing-2.3.0.jar')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}
I'm using this portion of code, but the application don't work in device (Certification error). What is the proper way to sign the application before running the test?

Click on Build -> Generate Signed APK -> Create new... -> add password, some credentials needed and click Next -> choose build type and flavors, check Signature Versions (check here: https://developer.android.com/about/versions/nougat/android-7.0.html#apk_signature_v2) but tl;dr -> choose V2.
This way you will generate dummy certificate which will sign your builds. Your gradle file will update automatically. If not than add:
signingConfigs {
config {
keyAlias 'KEY'
keyPassword 'PASSWORD'
storeFile file('../cert/fileName.jks')
storePassword 'STORE_PASSWORD'
}
to your gradle file.
It's good practice to store generated cert inside your project repo.

Related

Unable to build : How to add Android Build Config for new Module

Now i am converting my android code to modularized architectural approach. Facing issues when trying add a dependency on "app" module from "chat" module.
I have the following build config for the "app" module.
android {
lintOptions {
checkReleaseBuilds false
abortOnError false
}
signingConfigs {
companydevconfig {
keyAlias 'company'
keyPassword '123456'
storeFile file('../app/jksFils/company_dev.jks')
storePassword '123456'
}
companyqaconfig {
keyAlias 'company'
keyPassword '123456'
storeFile file('../app/jksFils/company_qa.jks')
storePassword '123456'
}
companyprodconfig {
keyAlias 'company'
keyPassword '123456'
storeFile file('../app/jksFils/release.keystore')
storePassword '123456'
}
}
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.company.employee.dev"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.13"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
aaptOptions {
cruncherEnabled = false
}
testOptions {
unitTests.returnDefaultValues = true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled true
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
dataBinding {
enabled = true
}
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/rxjava.properties'
}
flavorDimensions "company"
productFlavors {
dev {
dimension "company"
applicationId "com.company.employee.dev"
versionCode 277
versionName "2.0.0.16"
signingConfig signingConfigs.companydevconfig
buildConfigField 'String', 'BASEURL', '"https://dev.company.com"'
}
qa {
dimension "company"
applicationId "com.company.employee.qa"
versionCode 225
versionName "2.0.2.2"
signingConfig signingConfigs.companyqaconfig
buildConfigField 'String', 'BASEURL', '"https://qa.company.com"'
}
prod {
dimension "company"
applicationId "com.company.employee.prod"
versionCode 38
versionName "1.5.20"
signingConfig signingConfigs.companyprodconfig
buildConfigField 'String', 'BASEURL', '"https://cloud.company.com"'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests.returnDefaultValues = true
unitTests.all {
setIgnoreFailures(true)
jacoco {
includeNoLocationClasses = true
}
}
}
}
Now i have added a new module "chat". And it has following code in build config.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.company.employee.chat"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
dataBinding {
enabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
implementation project(':app')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
When i try to build i get following Error.
ERROR: Unable to resolve dependency for ':chat#debug/compileClasspath': Could not
resolve project :app.
Show Details
Affected Modules: chat
ERROR: Unable to resolve dependency for ':chat#debugAndroidTest/compileClasspath': Could not
resolve project :app.
Show Details
Affected Modules: chat
ERROR: Unable to resolve dependency for ':chat#debugUnitTest/compileClasspath': Could not
resolve project :app.
Show Details
Affected Modules: chat
ERROR: Unable to resolve dependency for ':chat#release/compileClasspath': Could not resolve
project :app.
Show Details
Affected Modules: chat
ERROR: Unable to resolve dependency for ':chat#releaseUnitTest/compileClasspath': Could not
resolve project :app.
Show Details
Affected Modules: chat
Here are some things to consider
There are differences between App Module and Library Module.
Library Module is complied to .aar/file. However, App Module is Compiled to APK.
This means that you can not import App Module as dependency to Library Module. Therefore, Remove This line from Library Module:
implementation project(':app')
Make sure the library is listed at the top of your settings.gradle.
Open settings.gradle of the App Module and make sure there is your library listed
include ':app', ':chat'
import the Library Module to your App Module Build Gradle
import your Library Module as dependency
dependencies {
implementation project(':chat')
}
Most Importantly Have a look at :Create an Android library

Linkedin Sample demo not working

I am working to implement LinkedIn SDK into my application. I import the demo code and created the sample project on LinkedIn developer console. I also added required package name and hash. I got those two from the sample demo code.
But after adding this two when I try to run the application it always fire the below error.
{
"errorMessage":"either bundle id or packagename / hash are invalid,unknown, malformed"
"errorCode":"INVALID_REQUEST"
}
I cross checked several time for the hash and package name because this two are parameter we have to add into console.
Posible duplicate of this post. Problem is about your are not signing correctly the APK generated. Check your signingConfig in the build.gradle file.
allprojects {
repositories {
mavenCentral()
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 17
versionCode 1
versionName "1.0"
}
signingConfigs {
sdkTest {
storeFile file("debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
release {
storeFile file("debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
buildTypes {
sdkTest {
signingConfig signingConfigs.sdkTest
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
compile project(':linkedin-sdk')
}
configurations {
}
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
}

Android Studio does not sign the code for debug build

Android Studio refuses to sign my code for debug build.
I have an older project which did not have any signing instructions in build.gradle, so I added these according to this Android gradle signingConfig error and other posts.
My build.gradle file on module level (the only module) looks like this (excerpt):
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "cc.appname.android"
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName '1.0'
}
signingConfigs {
debug {
storeFile file('../../../.android/debug.keystore')
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
The storeFile can be found, because when I change the path I get a compile error. When the path is correct, it compiles, but when I try to use the Facebook SDK within my app, it reports a wrong keyhash.
I noticed that signingConfigs
signingConfig signingConfigs.debug
is underlined with the error message "Cannot infer argument types..."
So I went to Project Settings in the UI, removed signing and the relationship between the build and signing, saved this, and added it back. Same problem.
I am sure this is something very small that I just overlooked, or Google renamed the command between versions, whatever.
Can anybody help?
Several things here, assuming your debug.keystore is the one from the ~/.android folder.
Change this:
debug {
storeFile file('../../../.android/debug.keystore')
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
to this(store the debug.keystore in the root project):
debug {
storeFile rootProject.file('debug.keystore')
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
You do not need to override the debug BuildType, it naturally signs with the debug key anyways, so you can remove:
debug {
signingConfig signingConfigs.debug
}
The final build.gradle:
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "cc.appname.android"
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName '1.0'
}
signingConfigs {
debug {
storeFile rootProject.file('debug.keystore')
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
Both buildTypes.debug and signingConfigs.debug exist by default.
You do not need to define buildTypes.debug unless you want to change it.
You do not need to define signingConfigs.debug unless you want to change it.
If you want to use the default debug signing for a different build type, you can do that. For example, the following works also without defining anything else:
buildTypes {
unsignedRelease {
initWith release
signingConfig signingConfigs.debug
}
}
Adding an answer for the new gradle experimental plugin since the syntax is different:
model {
android {
buildTypes {
release {
signingConfig = $("android.signingConfigs.myConfig")
...
}
}
}
android.signingConfigs {
create("myConfig") {
keyAlias = 'androiddebugkey'
keyPassword = 'android'
storeFile = new File("${System.properties['user.home']}/.android/debug.keystore")
storePassword = 'android'
storeType = "jks"
}
}
}
NOTE: the android.signingConfigs block must be placed outside of the android block.

Android Studio Error JUNIT4 !!! JUnit version 3.8 or later expected:

I'm doing Android project (in Android Studio), with a little SDK inside that is pure java.
So What I want is to do test from JUnit4.
And I configured the Gradlle File in this way:
apply plugin: 'android'
android {
compileSdkVersion "Google Inc.:Google APIs:19"
buildToolsVersion "19.0.1"
lintOptions{
checkReleaseBuilds false
}
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 28
versionName "4.0.5"
}
signingConfigs {
debug {
}
release {
}
}
buildTypes {
debug{
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
debuggable true
buildConfigField "boolean", "LOG_ENABLED", "true"
signingConfig signingConfigs.debug
}
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
debuggable false
buildConfigField "boolean", "LOG_ENABLED", "false"
signingConfig signingConfigs.release
}
}
productFlavors{
develFlavor{
}
testFlavor{
}
trainingFlavor{
}
preFlavor{
}
proFlavor{
}
}
}
if (project.hasProperty('storePassword')) {
android.signingConfigs.release.storePassword = storePassword
}
if (project.hasProperty('keyAlias')) {
android.signingConfigs.release.keyAlias = keyAlias
}
if (project.hasProperty('keyPassword')) {
android.signingConfigs.release.keyPassword = keyPassword
}
//testing
sourceSets {
unitTest {
java.srcDir file('test')
resources.srcDir file('test/resources')
}
}
configurations {
unitTestCompile.extendsFrom runtime
unitTestRuntime.extendsFrom unitTestCompile
}
task unitTest(type:Test, dependsOn: assemble) {
description = "run unit tests"
testClassesDir = project.sourceSets.unitTest.output.classesDir
classpath = project.sourceSets.unitTest.runtimeClasspath
}
build.dependsOn unitTest
dependencies {
compile files('libs/junit-4.11-sources.jar')
unitTestCompile 'junit:junit:4.11'
unitTestCompile files("$project.buildDir/classes/debug")
compile 'com.google.code.gson:gson:+'
compile 'com.android.support:appcompat-v7:+'
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/sbc_mapslib.jar')
compile files('libs/t21c2dm-lib-v1.0.jar')
}
Then I do a simply test case to see if junitis working. But when I run it, this error is promted.
!!! JUnit version 3.8 or later expected:
I saw in some other question that the solutions was, change dependences of Junit4.jar to be in first position, but it doesn't work to
If you test Android specific behaviour, that means if you need to run the test on the device (hardware or Emulator), you cannot use JUnit 4, because it's not built in in that version. You need to use JUnit 3 (I know that's cumbersome).
If you have some tests where you don't need a running Android, you can use every version you like (as you do with standard JUnit tests).

Signing product flavors with gradle

I am tyring to migrate my projects to gradle. One of my projects has multiple product flavors and each one of them has to be signed with a different signingConfig in its release version. So this is what I tried so far:
buildscript {
...
}
apply plugin: 'android'
android {
compileSdkVersion 17
buildToolsVersion '17'
signingConfigs {
flavor1 {
storeFile file("keystore")
storePassword "secret"
keyAlias "aliasForFlavor1"
keyPassword "secretFlavor1"
}
flavor2 {
storeFile file("keystore")
storePassword "secret"
keyAlias "aliasForFlavor2"
keyPassword "secretFlavor2"
}
}
productFlavors {
flavor1 {
signingConfig signingConfigs.flavor1
}
flavor1 {
signingConfig signingConfigs.flavor2
}
}
}
dependencies {
...
}
When I run gradle build I get a groovy.lang.MissingFieldException and the following error message:
No such field: signingConfigs for class: com.android.build.gradle.internal.dsl.GroupableProductFlavorFactory
So I assume the productFlavors.* part of the Gradle script is not the right place to put code signing configurations.
You can declare signing config for each flavor in buildType. Here is my gradle file for release signing flavors with different keystores.
android {
signingConfigs {
configFirst {
keyAlias 'alias'
keyPassword 'password'
storeFile file('first.keystore')
storePassword 'password'
}
configSecond {
keyAlias 'alias'
keyPassword 'password'
storeFile file('second.keystore')
storePassword 'password'
}
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
}
productFlavors{
flavor1 {
applicationId "com.test.firstapp"
}
flavor2 {
applicationId "com.test.secondapp"
}
}
buildTypes {
release {
productFlavors.flavor1.signingConfig signingConfigs.configFirst
productFlavors.flavor2.signingConfig signingConfigs.configSecond
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
buildTypes block should be placed after productFlavors block, I mean order is important.
Per the user guide, signingConfigs for flavors are supported.
The problem here has to do with the scope of the signingConfigs object. I just assigned it to a variable inside the productFlavors block, but outside the flavor1 flavor block to fix the issue:
productFlavors {
def flavor1SigningVariable = signingConfigs.flavor1
flavor1 {
...
signingConfig flavor1SigningVariable
...
}
The gradle plugin for android only supports signing per build type, not per flavor. The reason for this is that any given variant (build type + flavors) can only be signed by one key, but can be a combination of several flavor groups. For example your flavor groups could be cpu (x86/arm) and version (free/paid), that's four different variants right there.
The solution you're looking for is to create separate build types for your different release versions. For example, your build types might be debug, release, release-beta, like this:
...
android {
...
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.release
}
release-beta {
initWith release
signingConfig signingConfigs.release-beta
}
}
}
The initWith above just tells gradle that release-beta should be a copy of the release build type, only signed with a different key.
Maybe another interesting solution with dynamic flavor signing configs and other advantages
Im fine with defining app id and app name of flavors in gradle (it is clear and just 2 lines for each flavor) but I do not want to define separate signing configs (gradle file would be too long when adding flavors)
I also do not want to have sensitive signing information placed in gradle because of commiting it
Bonus advantage is that debug build has another app id and app name.
.gitignore
...
/keystore.properties
.keystore.properties
storeFile=../mystore.jks
storePassword=...
keyAliasFlavor1=...
keyPasswordFlavor1=...
keyAliasFlavor2=...
keyPasswordFlavor2=...
app/build.gradle
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(rootProject.file('keystore.properties')))
android {
...
buildTypes {
debug {
...
manifestPlaceholders = [appNameSuffix: " Dev"]
applicationIdSuffix ".dev"
}
release {
...
manifestPlaceholders = [appNameSuffix: ""]
productFlavors.all { flavor ->
flavor.signingConfig = android.signingConfigs.create("${flavor.name}")
flavor.signingConfig.storeFile = rootProject.file(keystoreProperties["storeFile"])
flavor.signingConfig.storePassword = keystoreProperties["storePassword"]
flavor.signingConfig.keyAlias = keystoreProperties["keyAlias${flavor.name}"]
flavor.signingConfig.keyPassword = keystoreProperties["keyPassword${flavor.name}"]
}
}
}
productFlavors {
Flavor1 {
applicationId "..."
manifestPlaceholders = [appNameBase: "MyApp 1"]
}
Flavor2 {
applicationId "..."
manifestPlaceholders = [appNameBase: "MyApp 2"]
}
// ... and many other flavors without taking care about signing configs
// (just add two lines into keystore.properties for each new flavor)
}
}
app/src/main/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
...
<application android:label="${appNameBase}${appNameSuffix}" ...>
...
</application>
</manifest>
This is the Kotlin DSL equivalent of ashakirov's answer:
// See https://stackoverflow.com/q/60474010
fun getLocalProperty(key: String) = gradleLocalProperties(rootDir).getProperty(key)
fun String?.toFile() = file(this!!)
// Could also use System.getenv("VARIABLE_NAME") to get each variable individually
val environment: Map<String, String> = System.getenv()
android {
signingConfigs {
create("MyFirstConfig") {
keyAlias = getLocalProperty("signing.keyAlias") ?: environment["SIGNING_KEY_ALIAS"]
storeFile = (getLocalProperty("signing.storeFile") ?: environment["SIGNING_STORE_FILE"]).toFile()
keyPassword = getLocalProperty("signing.keyPassword") ?: environment["SIGNING_KEY_PASSWORD"]
storePassword = getLocalProperty("signing.storePassword") ?: environment["SIGNING_STORE_PASSWORD"]
enableV1Signing = true
enableV2Signing = true
}
create("MySecondConfig") {
keyAlias = getLocalProperty("signing.keyAlias2") ?: environment["SIGNING_KEY_ALIAS2"]
storeFile = (getLocalProperty("signing.storeFile2") ?: environment["SIGNING_STORE_FILE2"]).toFile()
keyPassword = getLocalProperty("signing.keyPassword2") ?: environment["SIGNING_KEY_PASSWORD2"]
storePassword = getLocalProperty("signing.storePassword2") ?: environment["SIGNING_STORE_PASSWORD2"]
enableV1Signing = true
enableV2Signing = true
}
}
productFlavors {
create("flavor1") {
// ...
}
create("flavor2") {
// ...
}
}
buildTypes {
getByName("release") { // OR simply release { in newer versions of Android Gradle Plugin (AGP)
productFlavors["flavor1"].signingConfig = signingConfigs["MyFirstConfig"]
productFlavors["flavor2"].signingConfig = signingConfigs["MySecondConfig"]
// OR alternative notation
// productFlavors {
// getByName("flavor1") {
// signingConfig = signingConfigs["MyFirstConfig"]
// }
// getByName("flavor2") {
// signingConfig = signingConfigs["MySecondConfig"]
// }
// }
}
}
}
Split signing configs between Gms and Hms builds
Just for future ref if anyone has to split their signing configs between Gms and Hms builds.
This adds on the the answer listed here:
Maybe another interesting solution with dynamic flavor signing configs and other advantages
build.gradle
Option 1
gradle.startParameter.getTaskNames().each()
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
signingConfigs {
release {
storeFile file(keystoreProperties["RELEASE_STORE_FILE"])
storePassword keystoreProperties["RELEASE_STORE_PASSWORD"]
keyAlias keystoreProperties["RELEASE_KEY_ALIAS"]
keyPassword keystoreProperties["RELEASE_KEY_PASSWORD"]
}
releaseHms {
storeFile file(keystoreProperties["RELEASE_HMS_STORE_FILE"])
storePassword keystoreProperties["RELEASE_STORE_PASSWORD"]
keyAlias keystoreProperties["RELEASE_KEY_ALIAS"]
keyPassword keystoreProperties["RELEASE_KEY_PASSWORD"]
}
debug {
// use default debug key to sign
}
}
buildTypes {
release {
...
gradle.startParameter.getTaskNames().each { task ->
if (task.toLowerCase().contains("gms")) {
signingConfig signingConfigs.release
}
if (task.toLowerCase().contains("hms") {
signingConfig signingConfigs.releaseHms
}
}
}
debug {
...
gradle.startParameter.getTaskNames().each { task ->
if (task.toLowerCase().contains("gms")) {
signingConfig signingConfigs.debug
}
if (task.toLowerCase().contains("hms") {
signingConfig signingConfigs.releaseHms
}
}
flavorDimensions "serviceplatform"
productFlavors {
hms {
dimension "serviceplatform"
applicationIdSuffix ".huawei"
versionNameSuffix "-huawei"
}
gms {
dimension "serviceplatform"
applicationIdSuffix ".android"
}
}
sourceSets {
main {
res.srcDirs = [
"src/main/res",
"src/main/res/layout/toolbar",
"src/main/res/layout/fragment",
"src/main/res/layout/activity"
]
}
gms {
java.srcDir("src/gms/java")
}
hms {
java.srcDir("src/hms/java")
}
}
Option 2
productFlavors.gms.signingConfig
Ensure your flavorDimensions is before buildTypes
flavorDimensions "serviceplatform"
productFlavors {
hms {
...
}
gms {
...
}
}
buildTypes {
release {
...
productFlavors.gms.signingConfig signingConfigs.release
productFlavors.hms.signingConfig signingConfigs.releaseHms
}
debug {
...
productFlavors.gms.signingConfig signingConfigs.debug
productFlavors.hms.signingConfig signingConfigs.releaseHms
}
}

Categories

Resources