4

I need to prepare an Alpha testing for an Instant App and It run like a charm on Android Studio but It is failing when I try to upload it to the PlayStore, saying:

Upload failed

Your Instant App APKs should contain at least one base APK.

The app structure is done using three modules:

-base: It contains all the code

-apk: Wrapper to obtains the installable apk

-instantApp: Wrapper to obtain the instantApp apk

This are the build.gradles:

base/build.gradle

buildscript {
    repositories {
        jcenter()
    }
}
apply plugin: 'com.android.feature'

repositories {
    jcenter()
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.0-rc2"

    baseFeature = true
    dataBinding {
        enabled = true
    }

    defaultConfig {

        minSdkVersion 18
        targetSdkVersion 25
        versionCode 7
        versionName "1.1"
    }

    signingConfigs {
        release {
            [...]
        }
    }

    buildTypes {
        debug {
            [...]
        }
        release {
            minifyEnabled false
            signingConfig signingConfigs.release
            [...]
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    lintOptions {
        abortOnError false
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }
}

dependencies {

    application project(":apk")
    [...]
}
apply plugin: 'com.google.gms.google-services'

apk/build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.0-rc2"

    dataBinding {
        enabled true
    }

    defaultConfig {
        applicationId “…”
        minSdkVersion 18
        targetSdkVersion 25
        versionCode 7
       versionName "1.1"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    signingConfigs {
        release {
            [...]
        }
    }

    buildTypes {
        debug {
            […]
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            signingConfig signingConfigs.release
            […]
        }
    }
}

dependencies {
    implementation project(':base')
}

instantApp/build.gradle

apply plugin: 'com.android.instantapp'

dependencies {
    implementation project(':base')
}

And this are the Manifests files

base/Manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package=“…”>

<uses-permission android:name="android.permission.INTERNET" />
[…]

<application
    android:name=“[…].TrgApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppBaseTheme">

    <activity
        android:name=“[…].LauncherActivity"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:scheme="https"
                android:host=“[domain]” />
        </intent-filter>
    </activity>
    <activity
        android:name="[…].RootActivity"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustPan" />

    <activity
        android:name="[…].OnBoardingActivity"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustResize" />

    <activity
        android:name="[…].LocationPickerActivity"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustPan" />

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <service android:name="com.parse.PushService" />
    <receiver
        android:name="com.parse.GcmBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

            <!--
              IMPORTANT: Change "com.parse.starter" to match your app's package name.
            -->
            <category android:name="[…]" />
        </intent-filter>
    </receiver>

    <meta-data
        android:name="com.parse.push.gcm_sender_id"
        android:value="id:[…]" />

</application>
</manifest>

apk/Manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="..." />

This package is different that the app's one

I already tried this solution: (Android Instant-release build not includes base APK) but it didn't work.

I m stuck since the last Friday so any kind of idea could be awesome

Thanks in advance

P.D: Its my first question so I m sorry if I didn't do it propertly ;)

2 Answers2

2

Yeah!!! I found the issue!!!!(and its not in any of the google help documents)

The issue was that I was dropping the instantApp apk file straight away. The solution is to create a zip file with the instantApp apk and the base apk and drop that zip file!!!

Thanks for your help!!! At the end the issue wasnt gradle or the code..it was the PlayStore :)

I hope that if anyone has the same problem this question can help them!!!

1

This sample project seems to be pretty close to what you're trying to achieve. Perhaps you don't need the application project(":apk") in your base/build.gradle since you only have one feature (and that is the base split). You could also try removing base = true.

This section of the docs covers your use case - but it sounds like everything is set up correctly.

Could you also add your AndroidManifests to your original post?

Kyle Venn
  • 4,597
  • 27
  • 41
  • Hi Kyle!! I ve updated the question adding the Manifest files. I ll give it a go right now with your posible solution. Thanks! – Carlos Cabello Ruiz Jun 08 '17 at 08:40
  • I m sorry Kyle but I tried removing the `application project(":apk")` and it is saying the same at the PlayStore and if I removed the `base = true` there is a compilation error that doesnt make any sense for me _attribute 'split' in tag is not a valid split name_ – Carlos Cabello Ruiz Jun 08 '17 at 09:32
  • I m gonna compare the sample project to check if there is something I did wrong and check. Thanks – Carlos Cabello Ruiz Jun 08 '17 at 09:33
  • I modified the build.gradle files to set them as they are set in the sample but I had the same Upload failed error. I m starting to think that it is not an issue with gradle... – Carlos Cabello Ruiz Jun 08 '17 at 10:24
  • @CarlosCabelloRuiz hmm okay that's a toughy. It definitely sounds like it may be gradle. Whats your gradle plugin and gradle wrapper versions? Also did you see this post: stackoverflow.com/a/44367662/1220743 – Kyle Venn Jun 08 '17 at 14:43
  • is this what you ask about gradle wrapper version : **https\://services.gradle.org/distributions/gradle-4.0-milestone-2-all.zip**. Could you tell me what you mean about which gradle plugin?? I m using the last one version : **3.0.0-alpha3** – Carlos Cabello Ruiz Jun 08 '17 at 15:27
  • Kyle I did another test. I renamed the package of the hello world google sample from your link and upload and installable apk. I wait until it was available on the PlayStore and then I try to upload its instant app version but once again it fail with the same bug – Carlos Cabello Ruiz Jun 08 '17 at 16:04