即时应用程序,“立即尝试”按钮不会出现在 Play 商店中

oiy*_*yio 5 android google-play android-instant-apps dynamic-feature-module

我从以下 github 项目开始,但这些示例无法正常工作。我按照文档中的说明添加了缺失的部分。 https://github.com/android/app-bundle-samples/tree/main/InstantApps/urlless https://github.com/googlecodelabs/android-dynamic-features

这是我读过的文档。 https://developer.android.com/topic/google-play-instant/getting-started/instant-enabled-app-bundle https://developer.android.com/topic/google-play-instant/feature-module -迁移 https://developer.android.com/guide/app-bundle/instant-delivery

我尝试实现一个简单的 hello world 即时应用程序。我尝试了很多东西,但“立即尝试”按钮从未出现在游戏商店中。

我的应用程序包含 2 个模块:

  • 应用程序
  • 即时应用程序

应用程序模块的build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 30
    defaultConfig {

        minSdkVersion 21
        targetSdkVersion 30
        versionCode 61
        versionName "61"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dynamicFeatures = [':instantapp']
}

dependencies {
    ...
    implementation "com.google.android.gms:play-services-instantapps:17.0.0"
    implementation "com.google.android.play:core:1.9.0"
    ...
}
Run Code Online (Sandbox Code Playgroud)

我的即时应用程序模块的 build.gradle

plugins {
    id 'com.android.dynamic-feature'
}
android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.test.myapp"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 3
        versionName "1.2"
    }
}

dependencies {
    
    implementation "com.google.android.play:core:1.9.0"
   
}
Run Code Online (Sandbox Code Playgroud)

我的应用程序模块的 AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest >

    <dist:module dist:instant="true" />

    ...

</manifest>
Run Code Online (Sandbox Code Playgroud)

我的即时应用程序模块的 AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:dist="http://schemas.android.com/apk/distribution"
    package="com.test.instantapp"
    android:targetSandboxVersion="2">

    <dist:module dist:instant="true" dist:onDemand="false"
        dist:title="Instant app title">
        <dist:fusing dist:include="true" />
    </dist:module>

    <application android:usesCleartextTraffic="false">
        <activity android:name=".InstantMainActivity">
            <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
        </activity>
    </application>

  
</manifest>
Run Code Online (Sandbox Code Playgroud)

我生成了一个签名包并在每次尝试的内部测试中上传它,但它不起作用。我也在产品环境中尝试过。不行!

我尝试将 applicationId“com.test.myapp”放入应用程序模块和即时应用程序模块中。我尝试制作 android:targetSandboxVersion="2" 和 android:targetSandboxVersion="1"。不行 。我的应用程序的版本代码大于我的免安装应用程序的版本代码,如下所示。

我删除了clearTextTraffic并添加了。不行!

有人说我将启用即时应用程序的代码投入生产并上传新升级的即时应用程序版本。我做到了,也没有成功。

我尝试了很多组合,但我现在不记得了。但“立即尝试”按钮从未出现。我找不到的缺失部分是什么?

对于即时应用模块的最大大小有 3 种不同的说法:

  • 4MB
  • 10MB
  • 15 mb 为什么源代码和文档冲突太多,并且 github 中没有可用的代码?如果我没有在 Play 商店中看到工作示例,我会认为即时应用程序已经死了。

oiy*_*yio 4

打开Play商店 -> 选择应用程序 -> 打开高级设置 -> 添加发布类型即时应用程序

在此输入图像描述

然后从仅限即时应用程序选项上传您的即时应用程序:

在此输入图像描述