问题描述
AndroidStudio在版本升级之后也给用户带来了一些原来不存在的问题,虽然说只是一些小毛病,但是强迫症患者实在是不能接受。这不今天就遇到这么个事情:在AndroidManifest文件中,整个<application>警告,如下图所示
警告的完整内容如下
App is not indexable by Google Search; consider adding at least one Activity with an ACTION-VIEW intent filter.
先来看看谷歌官方给出的解释
To enable Google to crawl your app content and allow users to enter your app from search results, you must add intent filters for the relevant activities in your app manifest. These intent filters allow deep linking to the content in any of your activities. For example, the user might click on a deep link to view a page within a shopping app that describes a product offering that the user is searching for.
翻译过来就是:要使Google能够抓取您的应用内容并允许用户从搜索结果中输入您的应用,您必须为应用清单中的相关活动添加意图过滤器。 这些意图过滤器允许深入链接到您的任何活动中的内容。 例如,用户可以点击深层链接以查看购物应用中的页面,该页面描述用户正在搜索的产品。
解决方案
1、添加ACTION-VIEW intent filter
在Manifest文件中加入如下内容:
<action android:name=“android.intent.action.VIEW” />
此时Application部分代码变为如下内容:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
问题解决
2、忽略警告(当然不支持大家这么做)
修改app目录下的build.gradle文件,添加如下内容:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.activitytest"
minSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
lintOptions{
disable 'GoogleAppIndexingWarning'
}
}
其中
lintOptions{
disable ‘GoogleAppIndexingWarning’
}
是为添加部分,修改之后原来的警告就不见啦:)
自此之前被落下的Android又重新捡起来啦!以后会给出进阶过程中所遇到的一些问题以及详细地解决方法,如果大家有什么问题的话也希望能在评论区展开,互相学习哇!希望大家多多关注支持!