Could not end session: INSTALL_FAILED_INVALID_APK: Split null was defined several times

We are going to publish our instant application, however, we encounter a problem when trying to launch our AIA application, as well as when trying to upload to the AIA development track on Google Play. This is the first time we have encountered this problem, but have been able to launch AIA in the past. Upon further investigation, it seems that our basic apk function is somehow added or mentioned several times. Any help 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')
}

core build.gradle function

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 functional modules build.gradle files (they are all the 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 creating the split apk artifact, this is the structure after unpacking:

aia-release.zip
    - base-release.apk
    - chat-release.apk
    - message-release.apk
    - search-release.apk

zip Android Studio . Google AIA, .

:

Android Studio 3.0 Beta 2
Gradle plugin: 3.0.0-beta2
Gradle wrapper distribution: 4.1-rc-1

Edit:

. , . , ..

, .

android:isFeatureSplit="true"
split="<name>"

:

featureSplit="<name>"

- , / . , AIA .

.

2:

, , APK . AIA, "". .

:

No resource found that matches the given name...

, . , , , .

():

, , gradle.properties

android.enableAapt2=false

, .

+4
1

android.enableAapt2 = false

:

: com.android.builder.internal.aapt.AaptException: AAPT2:
: ': Deliver: processDebugAndroidTestResources'.Failed aapt : java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.AaptException: AAPT2:
:
: (94, 5) "@android: attr/windowExitAnimation"
: (94, 5) '@android: attr/windowEnterAnimation'

+1

Source: https://habr.com/ru/post/1684028/


All Articles