上传失败:您的即时应用APK文件应该至少包含一个基本APK。

4
我需要为一个即时应用程序准备Alpha测试,并且在Android Studio上运行得很好,但是当我尝试将其上传到PlayStore时失败了,显示以下信息:
上传失败
您的即时应用程序APK应包含至少一个基本APK。
该应用程序结构使用三个模块完成:
- base:它包含所有代码 - apk:用于获取可安装apk的包装器 - instantApp:用于获取instantApp apk的包装器
这些是build.gradle文件:
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')
}

这是清单文件:
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="..." />

这个包与应用程序的不同。
我已经尝试了这个解决方案:(Android Instant-release build not includes base APK),但它没有起作用。
自上周五以来,我一直被卡住了,所以任何想法都是很棒的。
提前致谢
P.D: 这是我的第一个问题,如果我做得不好,请见谅;)

你的版本代码应该是1。 - ArteFact
我一直在测试不同的apk,所以我将其从1个增加到7个...无论如何还是谢谢。 - Carlos Cabello Ruiz
是的,但我认为这可能是谷歌所指的。 - ArteFact
1
这没有任何意义,因为如果您要将即时应用程序添加到已经在PlayStore上的应用程序中,它的版本代码永远不会是1,对吧?实际上,我需要即时应用程序用于版本代码现在为40的应用程序,因此当我使其工作时,它将成为41。 - Carlos Cabello Ruiz
尝试这个 https://stackoverflow.com/a/44367662/1220743 - mol
@mol 谢谢,但我在问题中已经尝试了那个解决方案。 - Carlos Cabello Ruiz
2个回答

2

耶!!!我找到问题了!!!(而且这个问题不在任何谷歌帮助文档中)

问题是我直接删除了instantApp apk文件。解决方案是创建一个包含instantApp apk和基础apk的zip文件,然后删除该zip文件!!!

感谢您的帮助!!!最后问题不是gradle或代码...而是PlayStore :)

我希望如果有人遇到相同的问题,这个问题可以帮助他们!!!


这真是奇怪...我不小心尝试上传一个只包含instantApp apk的zip文件,竟然可以工作。 - Carlos Cabello Ruiz
是的,Android Studio会生成一个包含所有即时应用程序的zip文件。您需要上传zip文件本身,而不是单个apk文件。 - ManmeetP

1

这个示例项目似乎非常接近您想要实现的内容。也许您不需要在base/build.gradle中使用application project(":apk"),因为您只有一个功能(即基础拆分)。您还可以尝试删除base = true

文档的这一部分涵盖了您的用例 - 但听起来一切都设置正确。

您能否将您的AndroidManifests添加到原始帖子中?


嗨,Kyle!我已经更新了问题并添加了清单文件。我现在会尝试使用您的可能解决方案。谢谢! - Carlos Cabello Ruiz
抱歉,Kyle,但我尝试删除application project(":apk"),PlayStore上仍然显示相同的错误。如果我删除了base = true,就会出现编译错误,对我来说毫无意义,因为在<manifest>标签中的_attribute 'split'不是有效的拆分名称。 - Carlos Cabello Ruiz
我将比较样例项目,以检查是否有我做错的地方并进行核对。谢谢。 - Carlos Cabello Ruiz
我修改了build.gradle文件,将它们设置为示例中的设置,但是我仍然遇到了相同的上传失败错误。我开始认为这不是gradle的问题了... - Carlos Cabello Ruiz
@CarlosCabelloRuiz 嗯,好的,这是一个棘手的问题。它肯定听起来像是Gradle的问题。你的Gradle插件和Gradle包装器版本是什么?此外,你看到这篇文章了吗:stackoverflow.com/a/44367662/1220743 - Kyle Venn
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接