You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Google Console上传即时应用APK报错:未声明有效android:targetSandboxVersion

Fix for "Your Instant App APKs do not declare a valid 'android:targetSandboxVersion' attribute" Error

Let's work through resolving this common Instant App upload issue, even if you've already used the com.android.feature plugin and compressed your APKs as instructed:

  • Explicitly add the required attribute to your Feature module's Manifest
    While the com.android.feature plugin is supposed to auto-inject android:targetSandboxVersion="2" (a mandatory requirement for Instant Apps), configuration gaps can sometimes stop this from happening. Open your feature module's AndroidManifest.xml and manually add the attribute to the root <manifest> tag:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.your.feature.package"
        android:targetSandboxVersion="2">
    

    This guarantees the attribute is present, bypassing any plugin-related inconsistencies.

  • Confirm your Gradle plugin setup is correct
    Make sure your feature modules are actually using the com.android.feature plugin (not the standard app plugin):

    • For older Groovy syntax:
      apply plugin: 'com.android.feature'
      
    • For newer Kotlin DSL:
      plugins {
          id("com.android.feature")
      }
      

    Also, verify your base feature module has baseFeature true enabled in its build config:

    android {
        baseFeature true
        // ... other configuration settings
    }
    
  • Check if the attribute exists in your final signed APK
    Use the aapt tool to inspect the actual Manifest content inside your APK. Run this command in your terminal:

    aapt dump xmltree your-instant-app.apk AndroidManifest.xml
    

    If targetSandboxVersion is missing from the output, clean your build cache and rebuild from scratch:

    ./gradlew clean
    ./gradlew assembleRelease
    

    Stale build artifacts often cause the attribute to be omitted during the packaging process.

  • Validate your compressed package content
    Ensure you're zipping the correct Instant App APKs—these should be split feature APKs, not a full installable app APK. Google Console requires the zip to contain only the necessary feature files for the Instant App; double-check that you didn't accidentally include the wrong build artifact in your upload package.

This error typically arises from misconfigured Gradle plugins, stale build caches, or using the wrong APK in your zip. Following these steps should get your Instant App uploaded successfully.

内容的提问来源于stack exchange,提问作者Faisal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:06:17