android - 我所有的 xml 文件在 AndroidStudio 项目中都有错误
问题描述
看起来所有 xml 文件 AndroidManifest.xml 和 res xml 文件都有错误,例如“未注册 URI(设置 | 语言和框架 | 架构和 DTD)”和“属性 android:此处不允许”错误。
例如这是我的清单文件:
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<permission
android:name="spartons.com.javadriverapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<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"
tools:replace="android:appComponentFactory"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/map_api_key"/>
</application>
xmlns:android 和 xmlns:tool 标签有 URI 错误,大多数 android 标签有属性是不允许的。
这是我的应用程序 build.graddle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "spartons.com.javadriverapp"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation "com.google.android.gms:play-services-location:16.0.0"
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'
可能是什么问题呢?
解决方案
您需要在 xml 的顶部或父布局中添加工具和 android 属性的架构
像这样
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
如果它已经存在仍然出现错误,则在布局的第一行单击 ALT + ENTER
推荐阅读
- python - 在使用递归的多重嵌套 for 循环的程序中找不到故障
- aws-lambda - 动态 Access-Control-Allow-Origin 标头无服务器
- python - 将 PDF 解析为 CSV
- javascript - 我如何使用 forEach 循环遍历这个
- python - 邮件合并值而不是使用 Python 的公式
- ubuntu - 错误未知/不支持的存储引擎:InnoDB
- javascript - 将 17 位数字字符串转换为整数
- javascript - 在 JavaScript 中将对象数组转换为矩阵?
- python - pyzmq - zmq_req 我可以有一个上下文并使用多个套接字吗?
- mongodb - 无法与 mongo db shell 连接