API 28下Android Studio应用无法被谷歌搜索索引的修复咨询
解决Android Studio中“App is not indexable by Google Search”警告
嘿,这个警告我之前也碰到过,其实就是Google在提醒你——你的应用还没配置让搜索引擎能识别并索引的入口,也就是缺少ACTION_VIEW类型的Intent Filter。下面给你两种解决思路,按需选择就行:
方案一:配置ACTION_VIEW Intent Filter(推荐)
这种方法能让你的应用被Google Search索引,用户搜索相关内容时,你的应用会作为备选打开方式出现,还能提升曝光度。你只需要在MainActivity里新增一个Intent Filter即可,修改后的AndroidManifest.xml代码如下:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.omen.serverforcofe" > <uses-permission android:name="android.permission.NFC"/> <uses-feature android:name="android.hardware.nfc" android:required="true" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" android:launchMode="singleTop"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.nfc.action.NDEF_DISCOVERED" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> </intent-filter> <!-- 新增的用于Google索引的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:scheme="https" android:host="yourdomain.com" android:pathPrefix="/app-content" /> </intent-filter> </activity> </application> </manifest>
关键部分解释:
android:autoVerify="true":让Android自动验证你的应用确实拥有该域名的关联权限,确保Google Search能信任你的应用处理该链接。android.intent.action.VIEW:声明这个Activity可以处理“打开链接”的动作。android.intent.category.BROWSABLE:允许应用通过浏览器链接启动,这是被搜索引擎索引的必要条件。data节点:你需要把yourdomain.com替换成你实际的域名(比如你的官网),pathPrefix可以指定特定路径,这样只有访问该路径的链接才会唤起你的应用。如果暂时没有域名,也可以用自定义scheme(比如android:scheme="mycofeapp"),但HTTPS域名的兼容性和搜索效果更好。
方案二:直接关闭警告(仅当不需要索引时使用)
如果你的应用完全不需要被Google Search索引,也可以直接关闭这个检查:
- 打开Android Studio的
File -> Settings(Mac上是Android Studio -> Settings) - 在搜索框输入
Inspections,找到App Indexing相关的检查项 - 取消勾选该检查,点击
OK保存即可
内容的提问来源于stack exchange,提问作者Евгений Штин
相关产品推荐
相关产品推荐

