【问题标题】:Deeplink empty path error: "android:path cannot be empty"Deeplink 空路径错误:“android:path 不能为空”
【发布时间】:2018-01-04 11:02:10
【问题描述】:

我正在尝试为我的应用配置 deeplinks。我配置了几个选项,例如:

https://myapp.com/news       --->     NewsActivity
https://myapp.com/history    --->     HistoryActivity

带有意图过滤器,例如:

<intent-filter android:label="MyApp">
 <action android:name="android.intent.action.VIEW" />
 <category android:name="android.intent.category.DEFAULT" />
 <category android:name="android.intent.category.BROWSABLE" />
 <data android:scheme="http"
       android:host="myapp.com"
       android:pathPrefix="/news" />
</intent-filter>

<intent-filter android:label="MyApp">
 <action android:name="android.intent.action.VIEW" />
 <category android:name="android.intent.category.DEFAULT" />
 <category android:name="android.intent.category.BROWSABLE" />
 <data android:scheme="http"
       android:host="myapp.com"
       android:pathPrefix="/history" />
</intent-filter>

我还想要一个从基本域指向我的主要活动的链接

https://myapp.com   --->      MainActivity

我希望链接响应基本域,但不响应其他链接,例如:https://myapp.com/playlists,因为播放列表功能当前未在应用中实现,最好重定向到网络。

但是当我设置意图过滤器时:

<intent-filter android:label="MyApp">
 <action android:name="android.intent.action.VIEW" />
 <category android:name="android.intent.category.DEFAULT" />
 <category android:name="android.intent.category.BROWSABLE" />
 <data android:scheme="http"
       android:host="myapp.com"
       android:path="" />
</intent-filter>

我收到以下 lint 警告:

android:path 不能为空

确保您的应用支持该 URL,以获取安装和流量 从 GoogleSearch 到您的应用。

更多信息:https://g.co/AppIndexing/AndroidStudio

尽管有这个警告,但它的行为是正确的。如何解决此警告?

【问题讨论】:

    标签: android


    【解决方案1】:

    有同样的问题,你可以忽略tools:ignore="AppLinkUrlError"的警告

    所以你的意图是:

    <intent-filter android:label="MyApp">
     <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
     <category android:name="android.intent.category.BROWSABLE" />
     <data android:scheme="http"
           android:host="myapp.com"
           android:path=""
           tools:ignore="AppLinkUrlError" />
    </intent-filter>
    

    xmlns:tools="http://schemas.android.com/tools" 添加到您的初始清单标记中(如果它尚不存在)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-06
      • 1970-01-01
      • 1970-01-01
      • 2021-12-05
      • 1970-01-01
      相关资源
      最近更新 更多