4

我从以下 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 即时应用程序。我尝试了很多东西,但现在尝试按钮从未出现在 Play 商店中。

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

  • 应用程序
  • 即时应用

app 模块的 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"
    ...
}

我的即时应用模块的 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"
   
}

我的应用模块的 AndroidManifest.xml

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

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

    ...

</manifest>

我的即时应用模块的 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>

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

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

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

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

我尝试了许多我现在不记得的组合。但是现在尝试按钮永远不会出现。我找不到的缺失部分是什么?

关于 Instant-app 模块的最大大小有 3 种不同的说法:

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

1 回答 1

3

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

在此处输入图像描述

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

在此处输入图像描述

于 2021-03-31T12:52:25.893 回答