【问题标题】:All my xml files have errors in AndroidStudio Project我所有的 xml 文件在 Android Studio 项目中都有错误
【发布时间】:2020-10-14 13:49:32
【问题描述】:

看起来所有 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'

可能是什么问题?

【问题讨论】:

    标签: android xml android-studio gradle


    【解决方案1】:

    显然符号链接的镜像项目文件有所有错误,而原件没有

    原始文件位于 /mnt 下,而 ~/ 保存其符号镜像。图片显示 AndroidManifest.xml 有错误,其中一个有“uri not register”错误

    【讨论】:

      【解决方案2】:

      您需要在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

      【讨论】:

      • 感谢您的回答,但显然问题出现在符号链接的镜像项目文件上。由于某种原因,这些文件有错误,而原始文件没有。
      • 你能显示错误文件的屏幕截图吗?如果可能的话。
      • 我把截图放在答案上
      • 试试这个去 File->invalidate/restart
      • 我在意识到问题原因之前尝试过。此问题已解决。
      猜你喜欢
      • 1970-01-01
      • 2014-10-04
      • 2020-07-15
      • 1970-01-01
      • 2019-04-09
      • 2019-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多