We are preparing to publish our instant app, however, we are experiencing an issue when attempting to run our AIA app as well as when attempting to upload to the AIA development track in Google Play. This is the first time we are experiencing this issue but have been able to run the AIA in the past. Upon further investigation, it seems as if our base feature apk is somehow being added or referenced multiple times. Any assistance is appreciated.
Android Studio Error:
Failed to finalize session : INSTALL_FAILED_INVALID_APK: Split null was defined multiple times
Google Play Error:
Your Instant App APKs cannot contain more than one base APK.
AIA build.gradle file
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.23.0'
}
}
apply plugin: 'com.android.instantapp'
apply plugin: 'io.fabric'
repositories {
google()
jcenter()
flatDir {
dirs '../libs'
}
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
android {
compileSdkVersion rootProject.compileSdk
buildToolsVersion rootProject.buildTools
defaultConfig {
minSdkVersion rootProject.minSdk
targetSdkVersion rootProject.compileSdk
}
buildTypes {
debug {
}
release {
}
}
flavorDimensions rootProject.flavorDimensions
productFlavors {
flavor1 {
applicationId rootProject.flavor1PackageName
versionCode rootProject.flavor1VersionCode
versionName rootProject.flavor1VersionName
dimension rootProject.flavorDimensions
}
flavor2 {
applicationId rootProject.flavor2PackageName
versionCode rootProject.flavor2VersionCode
versionName rootProject.flavor2VersionName
dimension rootProject.flavorDimensions
}
}
}
dependencies {
implementation project(':features:base')
implementation project(':features:chat')
implementation project(':features:message')
implementation project(':features:search')
}
base feature build.gradle
apply plugin: 'com.android.feature'
repositories {
google()
jcenter()
flatDir {
dirs '../../libs'
}
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
android {
baseFeature true
compileSdkVersion rootProject.compileSdk
buildToolsVersion rootProject.buildTools
defaultConfig {
minSdkVersion rootProject.minSdk
targetSdkVersion rootProject.compileSdk
vectorDrawables.useSupportLibrary true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
flavor1Release {
storeFile file('../../publish/flavor1-release.keystore')
storePassword System.getenv("FLAVOR1_STORE_PASSWORD")
keyAlias System.getenv("FLAVOR1_KEY_ALIAS")
keyPassword System.getenv("FLAVOR1_KEY_PASSWORD")
v2SigningEnabled true
}
flavor2Release {
storeFile file('../../publish/flavor2-release.keystore')
storePassword System.getenv("FLAVOR2_STORE_PASSWORD")
keyAlias System.getenv("FLAVOR2_KEY_ALIAS")
keyPassword System.getenv("FLAVOR2_KEY_PASSWORD")
v2SigningEnabled true
}
debug {
storeFile file('../../publish/debug.keystore')
}
}
flavorDimensions rootProject.flavorDimensions
productFlavors {
flavor1 {
versionCode rootProject.flavor1VersionCode
versionName rootProject.flavor1VersionName
dimension rootProject.flavorDimensions
}
flavor2 {
versionCode rootProject.flavor2VersionCode
versionName rootProject.flavor2VersionName
dimension rootProject.flavorDimensions
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
productFlavors.flavor1.signingConfig signingConfigs.flavor1Release
productFlavors.flavor2.signingConfig signingConfigs.flavor2Release
}
}
}
dependencies {
feature project(':features:chat')
feature project(':features:message')
feature project(':features:search')
application project(':app')
api 'com.android.support:appcompat-v7:26.0.1'
api 'com.android.support:design:26.0.1'
api 'com.android.support:cardview-v7:26.0.1'
api 'com.google.android.gms:play-services-maps:11.0.2'
api 'com.google.android.gms:play-services-gcm:11.0.2'
api 'com.google.android.gms:play-services-location:11.0.2'
api 'com.google.android.gms:play-services-auth:11.0.2'
api 'com.google.firebase:firebase-core:11.0.2'
api 'com.google.firebase:firebase-config:11.0.2'
api...
}
apply plugin: 'com.google.gms.google-services'
Other feature module build.gradle files (all are the exact same)
apply plugin: 'com.android.feature'
repositories {
google()
jcenter()
flatDir {
dirs '../../libs'
}
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
android {
lintOptions {
abortOnError false
}
compileSdkVersion rootProject.compileSdk
buildToolsVersion rootProject.buildTools
defaultConfig {
minSdkVersion rootProject.minSdk
targetSdkVersion rootProject.compileSdk
vectorDrawables.useSupportLibrary true
}
signingConfigs {
flavor1Release {
storeFile file('../../publish/flavor1-release.keystore')
storePassword System.getenv("FLAVOR1_STORE_PASSWORD")
keyAlias System.getenv("FLAVOR1_KEY_ALIAS")
keyPassword System.getenv("FLAVOR1_KEY_PASSWORD")
v2SigningEnabled true
}
flavor2Release {
storeFile file('../../publish/flavor2-release.keystore')
storePassword System.getenv("FLAVOR2_STORE_PASSWORD")
keyAlias System.getenv("FLAVOR2_KEY_ALIAS")
keyPassword System.getenv("FLAVOR2_KEY_PASSWORD")
v2SigningEnabled true
}
debug {
storeFile file('../../publish/debug.keystore')
}
}
flavorDimensions rootProject.flavorDimensions
productFlavors {
flavor1 {
versionCode rootProject.flavor1VersionCode
versionName rootProject.flavor1VersionName
dimension rootProject.flavorDimensions
}
flavor2 {
versionCode rootProject.flavor2VersionCode
versionName rootProject.flavor2VersionName
dimension rootProject.flavorDimensions
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
productFlavors.flavor1.signingConfig signingConfigs.flavor1Release
productFlavors.flavor2.signingConfig signingConfigs.flavor2Release
}
}
}
dependencies {
api project(':features:base')
}
After building the split apk artifact, this is the structure after unzipping:
aia-release.zip
- base-release.apk
- chat-release.apk
- message-release.apk
- search-release.apk
When inspecting the zip file in Android Studio, everything seems to be correct and in line with the multiple samples Google provides surrounding AIA, multiple features, and multiple flavors.
Additional information:
Android Studio 3.0 Beta 2
Gradle plugin: 3.0.0-beta2
Gradle wrapper distribution: 4.1-rc-1
Edit:
We have managed to identify some more information about the issue. When running the multi-feature sample, the generated artifact has several key components our artifact is missing. However, we are using the same configuration, plugin, etc.
When building any of the sample projects, the generated merged manifests includes the following tags that ours does not.
android:isFeatureSplit="true"
split="<name>"
However, our merged manifest only adds the tag:
featureSplit="<name>"
We are still trying to identify why this is occurring and how different our project setup/structure is. But it is a painstaking process as there is limited to no documentation yet around AIA.
More information to follow.
Edit 2:
After working more with the project structure, it seems now our base APK resources are not able to be recognized by our feature module manifests. This is specific to the AIA, NOT the regular "Installed" module. When compiling the normal Installed module, this issue does not occur.
Error:
No resource found that matches the given name...
It is a shame there is no documentation around this as of yet. And we seem to be the only team experiencing these issues.
Final Edit (SOLVED):
DO NOT, I repeat, DO NOT have this in your gradle.properties file
android.enableAapt2=false
This is the sole reason for all of the issues we have been experiencing.