3

I try to publish the Android Instant App via Google Play. I might following problem enter image description here

I try to solve this problem by adding the attribute android:targetSandboxVersion = "2", still not work.

In general, the problem has these settings(build.gradle)

buildscript {

    repositories {
        maven { url 'https://maven.google.com' }
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta5'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url 'https://maven.google.com' }
        jcenter()
        google()
    }
}


ext {
    minSdkVersion = 26
    targetSdkVersion = 26
    compileSdkVersion = 26
    buildToolsVersion = '26.0.1'
    androidSupport = '26.0.0'
    versionCode = 5
    versionName = "1.1"
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

======

As commented, I revise the base feature by adding the statement android:targetSandboxVersion = "2", then I cannot go through the compiling as errors shown, even if I clean, rebuild the project.

enter image description here

csytang
  • 119
  • 3
  • 10
  • As the message says, you need targetSandboxVersion in the manifest of your published installable app. Please post the manifest of the installable version of the app if it still doesn't work. – philo Sep 12 '17 at 16:49
  • I revise the problem as suggested, but why should I add that statement? – csytang Sep 12 '17 at 17:35
  • That only affects Android O devices. It places some restrictions on the app's behavior which unfortunately are not documented anywhere. We do have a high-priority bug to document that, but the hope is that it shouldn't be too burdensome to add it now since it only affects O. The reason it's required is to allow easier upgrading to installed app on O. – philo Sep 12 '17 at 20:07
  • @philo I have the exact same problem. I added the requested attribute in the application tag of all the manifests, and still get the error. You can see my project here: https://github.com/BoD/JRAForg – BoD Sep 13 '17 at 17:34
  • @BoD I try to set the targetSdkVersion = 25, it can pass the Google Play Console, however, it cannot be used as an Instant App, which means the URL cannot jump to your instant app – csytang Sep 14 '17 at 05:18
  • @philo Any update? We are unable to publish anything - which is kind of an urgent problem. Is Instant App supposed to be production ready? Any workaround? – BoD Sep 14 '17 at 09:21
  • @cstyang, you confirmed over email that you were able to publish after setting targetSandboxVersion = 2. Your email suggested that, after publishing, you weren't able to launch the instant app. I think that's what you mean here by "it cannot be used as an Instant App". I'm happy to take a look, but it would be most helpful to others if you post that as a new question and let this one stand on its own. – philo Sep 14 '17 at 17:30
  • Yes, these days I check the source code of android 8.0, the targetSdKVersion must be set to 26 rather than 25. Otherwise, it cannot be used as an Instant App. As posted in Google I/O, they said it support Android 6.0 or above, I personally think it is not true. I think only 8.0 – csytang Sep 19 '17 at 08:59
  • @csytang `minSdkVersion` <= `targetSdkVersion`. According to our logs, Instant Apps supported down to Android 5.1 – Volo Sep 22 '17 at 12:38
  • @Idolon have you try to publish your app with targetSdkVersion = 5.1 on Google Play? Is it successfully pass the Google Console check and verification? Any link for your app on Google Play? I want to have a try. – csytang Sep 23 '17 at 05:59
  • @csytang You seem to be confusing `minSdkVersion` and `targetSdkVersion`. The former specify minimal Android API version supported by the app, while the latter specifies the API Level against which the application is built. We publish our Instant App (you can check the product name in my profile) with `minSdkVersion = 19` and `targetSdkVersion = 26`, which means it could be run on a device having at least Android 4.4, but we're able to use all available API on the latest OS versions. – Volo Sep 24 '17 at 23:25
  • @csytang I made a significant update to my answer. The attribute is no longer required. – philo Oct 09 '17 at 22:10

2 Answers2

4

Updated answer:

This was a bug that has since been fixed. You no longer need to add targetSandboxVersion to your installable app, and I don't recommend doing so, since the feature isn't yet documented or described anywhere.

When I recommended adding the attribute originally, I believed that documentation would be forthcoming, before the release of an O phone. Instead, the team responsible for adding this validation realized their mistake.

However, you do still need targetSandboxVersion in your instant app. Since we don't allow instant apps without that attribute, just consider it a required magic phrase.


Original answer:

As the message says, you need targetSandboxVersion in the manifest of your published installable app.

Doing so places some restrictions on your installed app on O devices, and that makes it easier for the O installer to upgrade your instant app to installed.

philo
  • 3,580
  • 3
  • 29
  • 40
  • I experience the same problem, even after adding this attribute. @philo I am still unable to publish - what is the best way to obtain support (I feel like StackOverflow comments is not the best way)? Thank you. – BoD Sep 16 '17 at 09:56
  • `android:targetSandboxVersion` is an attribute of the top-level manifest. You put yours on the application tag. – philo Sep 16 '17 at 23:05
  • 2
    @philo Do you know, why the usage of `android:targetSandboxVersion` is still undocumented on developer.android.com? – Volo Sep 18 '17 at 20:50
  • Hi, there, please check the source code in Android 8.0, the targetSandboxVersion should be set to 2 in order to use Instant App, Please check the  /tools/apksig/src/main/java/com/android/apksig/ApkVerifier.java in Android 8.0 source code, Here, I use android8.0_r4 – csytang Sep 19 '17 at 08:56
  • 1
    @Idolon Turns out the attribute wasn't ready for installable apps, and that's why it wasn't documented. Someone made a mistake in adding this validation. The attribute is no longer required. – philo Oct 09 '17 at 22:15
  • 1
    @philo Thanks for the update! Correct me if I'm wrong here, but AFAIU, if the installable app was deployed to the production with `android:targetSandboxVersion="2"` it's no longer possible to revert the value back to `1`? – Volo Oct 10 '17 at 15:20
4

I had the same problem and it gave me a headache for a while. The solution is to move|add the targetSandboxVersion to the root element of the AndroidManifest.xml file. e.g:

    <manifest android:hardwareAccelerated="true" 
     android:versionCode="20008" android:versionName="2.0.8"  
     package="com.yourapp.id" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:targetSandboxVersion="2">

Develop > Guides > App Manifest File

Prags
  • 2,457
  • 2
  • 21
  • 38