当前位置: 首页 > 知识库问答 >
问题:

更新后Android资源编译失败

尚楚
2023-03-14

更新android工作室后…我的项目崩溃了,出现以下错误

    Android resource compilation failed
Output:  C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1668: error: <item> inner element must either be a resource reference or empty.
C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1669: error: <item> inner element must either be a resource reference or empty.
C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1670: error: <item> inner element must either be a resource reference or empty.
C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1671: error: <item> inner element must either be a resource reference or empty.
C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1672: error: <item> inner element must either be a resource reference or empty.
C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1673: error: <item> inner element must either be a resource reference or empty.
C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1674: error: <item> inner element must either be a resource reference or empty.
C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1700: error: <item> inner element must either be a resource reference or empty.

Command: C:\Users\aliya\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\c7465495da03cdfc80a78f27c03646df\aapt2-3.2.0-4818971-windows\aapt2.exe compile --legacy \
        -o \
        C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\res\merged\debug \
        C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon:  AAPT2 aapt2-3.2.0-4818971-windows Daemon #0

我的项目级别是

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.2.71'
    repositories {
        mavenCentral()
      //  maven {
        //    url 'https://maven.google.com'
       // }
       // maven { url 'https://maven.fabric.io/public' }
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath 'com.google.gms:google-services:4.0.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "io.realm:realm-gradle-plugin:5.4.1"
       // classpath 'com.android.tools.build:gradle:3.0.0-beta1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        configurations.all {
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                def requested = details.requested
                if (requested.group == 'com.google.android.gms') {
                    details.useVersion '12.0.1'
                }
                if (requested.group == 'com.google.firebase') {
                    details.useVersion '12.0.1'
                }
            }
        }
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

和应用程序级别渐变

    apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'


apply plugin: 'kotlin-android-extensions'

apply plugin: 'realm-android'


android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "waleed.com.eventstoday"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        buildTypes {
            debug {
                buildConfigField "String", "baseUrl", '"www.google.com"'
                buildConfigField "String", "buildName", '"Development"'
                buildConfigField "String", "countryCode", '"+92"'
            }
            release {
                buildConfigField "String", "baseUrl", '"www.google.com"'
                buildConfigField "String", "buildName", '"Release"'
                buildConfigField "String", "countryCode", '"+92"'
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:27.1.1'
    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'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    implementation 'com.intuit.sdp:sdp-android:1.0.5'
    implementation 'com.facebook.android:facebook-login:4.35.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.google.android.gms:play-services-auth:16.0.0'
    implementation 'com.parse:parsetwitterutils-android:1.10.6'
    implementation 'com.parse:parse-android:1.16.3'
    implementation 'io.smooch:core:5.12.1'
    implementation 'io.smooch:ui:5.12.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
}

repositories {
    mavenCentral()
}
realm {
    syncEnabled = true
}
apply plugin: 'com.google.gms.google-services'

如果还需要更多的信息,请告诉我们。任何帮助都将不胜感激。更新后,它没有工作,也试图降级到3.1.0,但它没有工作,只是打开了价值。xml在建立-

urn:oasis:names:TC:xliff:document:1.2显示URI未注册

“xmlns:ns2=”http://schemas.android.com/tools“显示URI未注册

共有3个答案

微生弘
2023-03-14

这是渐变版本问题,我正在使用3.2.0...但是库不支持,所以我必须将版本降级到3.1.4,现在工作正常。

尉迟安民
2023-03-14

在您的项目中,遍历所有 src/主/资源/值/

<item type="id" name="my_id">some random value here</item>

问题是id可以没有值(创建一个新的id)或者引用其他ID(在值字段中使用< code>@id/other_id语法)。只需删除要匹配的值:

<item type="id" name="my_id"></item>

<item type="id" name="my_id"/>
璩慎之
2023-03-14

在整个项目中搜索 type=“id”,然后为每个实例删除项目标签内容,例如:

更改此项:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="item_click_support" type="id">2468</item>
</resources>

至:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="item_click_support" type="id"/>
</resources>
 类似资料:
  • 我刚刚将我的android工作室更新到3.2.1版,并通过android工作室将我的gradle更新到最新版本,但构建项目面临此错误: Android资源编译失败输出:D:\project\myProject\app\build\mediates\增量\mergeDebugResources\merged.dir\值\values.xml:2577:错误:内部元素必须是资源引用或为空。D:\pro

  • 我正在Android Studio上开发一个应用程序,一切都很顺利,但是当我将Android Studio更新到最新的3.2.1时。每当我重建它时,它开始抛出错误,如: 值.xml 此值行中出现错误: 我尝试了一切可能的方式来修复值中的错误,但没有解决方案,每当我对值.xml文件进行更改时,默认文件都会在重建后再次出现。任何帮助将不胜感激 非常感谢您在这件事上花费的时间和帮助。

  • Android Studio更新到3.2.1 Gradle版本后,获取Android资源编译失败:3.3.0在消息视图中获取以下错误 Android资源编译失败E:\AndroidProjects\OnlineMp3\app\build\intermediates\incremental\mergedebugresources\merged.dir\values\values.xml:595:错误

  • 我试过很多方法,但都不奏效... Android资源编译失败输出:C:\users\user\desktop\new Android\test1_tp7\app\src\main\res\layout\activity_main.xml:1:错误:格式不正确(无效令牌)。命令:c:\users\user.gradle\caches\transforms-1\files-1.1\aapt2-3.2.

  • 我使用了NDK,一切都很顺利,但一旦我改变了我的系统,一切都变得很糟糕,无法开始构建/运行项目——我遇到了以下错误 我已经完成了删除. gradle文件夹和清理、重建、删除构建文件夹,但没有成功,请帮我-

  • com.Android.builder.internal.aapt.v2.aapt2exception:Android资源编译失败/users/username/.gradle/caches/transforms-2/files-2.1/94 a628954aabd306de764f6ff2843371/res/values/values.xml:8:5-35:25:aapt:error:资源'a