【问题标题】:Upload failed: Your Instant App APKs should contain at least one base APK上传失败:您的免安装应用 APK 应至少包含一个基础 APK
【发布时间】:2017-06-07 14:42:53
【问题描述】:

我需要为 Instant App 准备一个 Alpha 测试,它在 Android Studio 上运行起来就像一个魅力,但是当我尝试将它上传到 PlayStore 时它失败了,说:

上传失败

您的免安装应用 APK 应至少包含一个基础 APK。

应用程序结构使用三个模块完成:

-base:包含所有代码

-apk:包装器获取可安装的apk

-instantApp:获取instantApp apk的包装器

这是 build.gradles:

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
  • 我正在使用不同的 apk 进行测试,所以我将它从 1 增加到 7...无论如何,谢谢
  • 是的,但我认为这可能是谷歌的意思
  • 没有任何意义,因为如果您要将即时应用程序添加到已经在 PlayStore 上的应用程序,它的版本代码永远不会是 1,不是吗?实际上,我需要一个版本代码现在为 40 的应用程序的即时应用程序,所以当我让它工作时,它将是 41

标签: android android-studio android-gradle-plugin build.gradle android-instant-apps


【解决方案1】:

是啊!!!我发现了问题!!!!(并且它不在任何谷歌帮助文档中)

问题是我直接删除了 instantApp apk 文件。解决方案是使用 InstantApp apk 和基本 apk 创建一个 zip 文件,然后删除该 zip 文件!!!

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

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

【讨论】:

  • 这很奇怪......我错误地尝试仅使用 InstantApp apk 上传一个 zip 文件,它可以工作
  • 是的,Android Studio 将生成一个包含所有即时 apk 的 zip 文件。您上传 zip 文件本身,而不是单个 apk。
【解决方案2】:

This sample project 似乎非常接近您想要实现的目标。也许您不需要application project(":apk") 中的application project(":apk"),因为您只有一个功能(即基本拆分)。您也可以尝试删除base = true

This section of the docs 涵盖了您的用例 - 但听起来一切都设置正确。

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

【讨论】:

  • 嗨凯尔!我已经更新了添加清单文件的问题。我现在就用你可能的解决方案试一试。谢谢!
  • 对不起,Kyle,但我尝试删除 application project(":apk"),在 PlayStore 中也是如此,如果我删除了 base = true,则会出现编译错误,对我没有任何意义 标记中的属性“split”不是有效的拆分名称
  • 我将比较示例项目以检查我是否做错了什么并检查。谢谢
  • 我修改了 build.gradle 文件以将它们设置为示例中的设置,但我遇到了相同的 Upload failed 错误。我开始认为这不是 gradle 的问题......
  • @CarlosCabelloRuiz 嗯,好吧,这很难。听起来肯定是 gradle。你的 gradle 插件和 gradle 包装器版本是什么?你也看到这个帖子了:stackoverflow.com/a/44367662/1220743
猜你喜欢
  • 2018-05-09
  • 2018-02-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多