Android Studio——warning:App is not indexable by Google Search

今天在新建一個Activity之後,進入到AndroidManifest.xml文件,發現<application>標籤的代碼一片黃色,原來是發出warning了。(這個warning其實對於app的運行沒有影響,但是看着總覺得不順眼,就看看有啥解決辦法沒)

問題:

警告信息:

App is not indexable by Google Search consider adding at least one Activity with an ACTION-VIEW intent filter. See issue explanation for more details.

應用無法通過Google搜索進行索引,請考慮添加至少一個帶有ACTION-VIEW 的Intent過濾器的活動。 請參閱問題說明以獲取更多詳細信息

在點了more..之後出現了詳細信息

inspection info:Adds URLs to get your app into the Google index, to get installs and traffic to your app from Google Search.

檢查信息:添加URL來使你的應用進入Google索引,從Google搜索獲取安裝和對您應用的訪問量。

解決方法(親測有效):

方法一:

如果你想禁用這個warning,那麼可以在app目錄下的build.gradle的android{}中添加如下代碼

lintOptions {
        disable 'GoogleAppIndexingWarning'
        baseline file("lint-baseline.xml")
    }

並點擊彈出的Sync now即可。

方法二:

忽略GoogleAppIndexingWarning

在鼠標點擊了發出warning的區域後,代碼行左邊會出現一個黃色的小燈泡,點擊後會出現幾個選項

點擊第一個選項後會自動在<manifest>標籤中添加代碼:

 xmlns:tools="http://schemas.android.com/tools"

並且在<application>標籤中自動添加以下代碼:

tools:ignore="GoogleAppIndexingWarning"

方法三:

根據警告信息說添加至少一個帶有ACTION-VIEW 的Intent過濾器的活動,在activity的<intent-filter>標籤中添加如下代碼

<action android:name="android.intent.action.VIEW" />

並點擊Sync Now即可,如下圖

 

參考網站:stackoverflow

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章