元数据中 EnableSafeBrowsing 的 Lint 警告 'Element meta-data is not allowed here'
Lint warning 'Element meta-data is not allowed here' for EnableSafeBrowsing in Metadata
我在清单文件中添加了 EnableSafeBrowsing。这基于此处提供的信息:https://android-developers.googleblog.com/2017/06/whats-new-in-webview-security.html
当我 运行 对我的应用程序进行 Lint 分析时,我在此清单声明中收到以下警告:Element meta-data is not allowed here
(此检查突出显示 [=25= 中不允许的 XML 标记] 资源文件和 AndroidManifest.xml)
<meta-data
android:name="android.webkit.WebView.EnableSafeBrowsing"
android:value="true" />
目前我正在抑制此警告 (<!--suppress AndroidElementNotAllowed -->
)。关于是否或何时将不再被 Lint 视为警告,是否有任何消息?
清单中的位置:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.xxxxx.xxxxxx">
<!--suppress AndroidElementNotAllowed -->
<meta-data
android:name="android.webkit.WebView.EnableSafeBrowsing"
android:value="true" />
改为将其添加到应用程序标签中。如果您阅读 docs,您将看到 meta-data
标签可以包含的标签列表:
<activity>
<activity-alias>
<application>
<provider>
<receiver>
<service>
意味着它不允许作为 manifest
标签的子标签。改为将其放在 application
标签下。
您链接的博客包含错误信息,documentation of Safe Browsing 也对此进行了备份 - 此特定元数据位于应用程序标签下
也有可能您已将所有标签和属性都放在正确的包含父标签中,但可能错过了在 build.gradle 文件中放置:versionCode、versionName 和 allowBackup。
解决这个问题试试这个:
defaultConfig {
applicationId "com.example.mypackagename"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
此外,如果 AndroidManifest.xml 文件中有如下标签
android:platformBuildVersionCode
android:platformBuildVersionName
删除它们(它将被 gradle 构建系统添加到清单中),
它对我有用。
我在清单文件中添加了 EnableSafeBrowsing。这基于此处提供的信息:https://android-developers.googleblog.com/2017/06/whats-new-in-webview-security.html
当我 运行 对我的应用程序进行 Lint 分析时,我在此清单声明中收到以下警告:Element meta-data is not allowed here
(此检查突出显示 [=25= 中不允许的 XML 标记] 资源文件和 AndroidManifest.xml)
<meta-data
android:name="android.webkit.WebView.EnableSafeBrowsing"
android:value="true" />
目前我正在抑制此警告 (<!--suppress AndroidElementNotAllowed -->
)。关于是否或何时将不再被 Lint 视为警告,是否有任何消息?
清单中的位置:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.xxxxx.xxxxxx">
<!--suppress AndroidElementNotAllowed -->
<meta-data
android:name="android.webkit.WebView.EnableSafeBrowsing"
android:value="true" />
改为将其添加到应用程序标签中。如果您阅读 docs,您将看到 meta-data
标签可以包含的标签列表:
<activity> <activity-alias> <application> <provider> <receiver> <service>
意味着它不允许作为 manifest
标签的子标签。改为将其放在 application
标签下。
您链接的博客包含错误信息,documentation of Safe Browsing 也对此进行了备份 - 此特定元数据位于应用程序标签下
也有可能您已将所有标签和属性都放在正确的包含父标签中,但可能错过了在 build.gradle 文件中放置:versionCode、versionName 和 allowBackup。
解决这个问题试试这个:
defaultConfig {
applicationId "com.example.mypackagename"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
此外,如果 AndroidManifest.xml 文件中有如下标签
android:platformBuildVersionCode
android:platformBuildVersionName
删除它们(它将被 gradle 构建系统添加到清单中), 它对我有用。