问题描述
我从以下 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-migration 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 并添加了。不行!
有人说我将启用免安装应用的代码投入生产并上传新的升级的免安装应用版本。我做到了,它也不起作用。
我尝试了很多组合,现在记不清了。但是现在尝试按钮永远不会出现。我找不到的缺失部分是什么?
关于免安装应用模块的最大大小有 3 种说法: