【问题标题】:You must use the http and https protocols for intent filters. Why receive this error message?您必须对意图过滤器使用 http 和 https 协议。为什么会收到此错误消息?
【发布时间】:2017-07-12 12:42:39
【问题描述】:

当我选择将 android Instant App apk-s zip 上传到 Google Play 开发者控制台时,我收到此错误:上传失败。您必须为意图过滤器使用 http 和 https 协议

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      package="com.example.feature">

<application>
    <meta-data
        android:name="asset_statements"
        android:resource="@string/asset_statements"/>
    <activity android:name=".ui.MainActivity">
        <tools:validation testUrl="https://com.example/"/>

        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <intent-filter
            android:order="1"
            android:autoVerify="true">
            <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="com.example"
                android:pathPattern="/.*"/>
        </intent-filter>

        <meta-data
            android:name="default-url"
            android:value="https://com.example"/>
    </activity>
</application>

【问题讨论】:

  • 也许你应该使用http和https,而不仅仅是https?
  • 我添加但同样的错误被保留

标签: android android-intent android-instant-apps


【解决方案1】:

在我将 AndroidManifest 更改为这种方式之前,我一直遇到这个问题

<activity android:name=".MainActivity"> 
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter android:autoVerify="true">
         <action android:name="android.intent.action.VIEW" />

         <category android:name="android.intent.category.DEFAULT" />
         <category android:name="android.intent.category.BROWSABLE" />

         <data android:host="example.com" />
         <data android:scheme="http" />
         <data android:scheme="https" />
         <data android:pathPattern="/InstantApp" />
    </intent-filter>
</activity>

【讨论】:

    【解决方案2】:

    确保您的intent-filter 至少具有以下属性。 “http”和“https”方案必须同时存在:

             <intent-filter
                android:autoVerify="true"
                android:order="1">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:host="abc.com" />
                <data android:pathPattern="/def" />
                <data android:scheme="https" />
                <data android:scheme="http" />
            </intent-filter>
    

    【讨论】:

      【解决方案3】:

      我使用 Intent-filter 接收动态链接,但也在导航图中集成深度链接,因此还需要在 nav_graph.xml 文档中包含“http”和“https”支持。

      <fragment
              android:id="@+id/someFragment"
              android:name="com.apps.example.SomeFragment"
              android:label="fragment_some"
              tools:layout="@layout/fragment_some" >
              <deepLink
                  android:id="@+id/deepLink1"
                  app:uri="https://example.page.link" />
      
              <deepLink
                  android:id="@+id/deepLink2"
                  app:uri="http://example.page.link" />
        </fragment>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-12-03
        • 2018-12-17
        • 2022-01-05
        • 1970-01-01
        • 2015-01-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多