今天在新建一个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