【问题标题】:Uploading *.aab bundle to Google play console Problem将 *.aab 包上传到 Google Play 控制台问题
【发布时间】:2021-10-19 04:17:45
【问题描述】:

Uploading react native app bundle to Google play console 进行测试,但它告诉我:您上传了一个带有快捷方式 XML 配置的 APK 或 app bundle,但出现以下错误:元素“”缺少必需的属性, 'android:shortcutId'。 我的shortcuts.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">

<shortcut android:shortcutId="ID_test" android:enabled="true"
android:shortcutShortLabel="@string/compose_shortcut_short_label"
android:shortcutLongLabel="@string/compose_shortcut_long_label">

<intent android:action="android.intent.action.VIEW"  
android:targetPackage="com.nativebasetest2"  
android:targetClass="com.nativebasetest2.MainActivity" />
<!-- If your shortcut is associated with multiple intents, include them
     here. The last intent in the list determines what the user sees when
     they launch this shortcut. -->
  <categories android:name="android.shortcut.conversation" />
<capability-binding android:key="actions.intent.OPEN_APP_FEATURE" />
<capability android:name="actions.intent.OPEN_APP_FEATURE">
  <intent android:action="android.intent.action.VIEW" 
      android:targetPackage="com.nativebasetest2" 
      android:targetClass="com.nativebasetest2.MainActivity">
    <extra android:key="requiredForegroundActivity" 
         android:value="com.nativebasetest2/MainActivity"/>
    </intent>
   </capability>
</shortcuts>

AndroidManifest.xml 文件:

 <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
android:configChanges=
     "keyboard|keyboardHidden|orientation|screenSize|uiMod"
    android:launchMode="singleTask"
    android:screenOrientation="portrait"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
        <meta-data android:name="android.app.shortcuts"
             android:resource="@xml/shortcuts" /> 
  </activity>

TIA,请帮我找出问题所在

【问题讨论】:

    标签: android google-play-console android-static-shortcuts


    【解决方案1】:

    Element '&lt;shortcut&gt;' is missing a required attribute, 'android:shortcutId'. 正在显示,因为 minSdkVersion 必须为 25。

    话虽如此,如果您仍然希望您的应用支持 SDK 25 以下的操作系统,您可以为 SDK 25 创建一个 xml 文件夹:

    xml-v25 将您的快捷方式文件放入其中。 xml-v25/shortcuts.xml

    编辑xml/shortcuts.xml 并删除所有&lt;shortcut&gt; 标记。

    快捷方式将适用于 SDK 25 及更高版本,并且您的应用可以安装任何与您的 minSDKVersion 匹配的应用

    【讨论】:

      【解决方案2】:

      按照以下步骤在您的应用清单中添加对快捷方式.xml 的引用:

      1. 在您应用的清单文件 (AndroidManifest.xml) 中,找到其意图过滤器设置为 android.intent.action.MAIN 操作和 android.intent.category.LAUNCHER 类别的 Activity。

      2. 使用 Activity 中的标签添加对 AndroidManifest.xml 中的快捷方式.xml 的引用,该标签具有 MAIN 和 LAUNCHER 的意图过滤器,如下所示:

      <manifest xmlns:android="http://schemas.android.com/apk/res/android"
                package="com.example.myapplication">
        <application ... >
          <activity android:name="Main">
            <intent-filter>
              <action android:name="android.intent.action.MAIN" />
              <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            
            <meta-data android:name="android.app.shortcuts"
                       android:resource="@xml/shortcuts" /> 
          </activity>
        </application>
      </manifest>
      

      【讨论】:

      • 我做到了,但这对我不起作用。
      【解决方案3】:

      我通过在 android/build.gradle 中进行更改来解决它。

      1. minsdkVersion = 30
      2. taargetsdkVersion = 30

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-04-22
        • 2020-02-01
        • 1970-01-01
        • 2023-04-01
        • 2022-06-16
        相关资源
        最近更新 更多