更新后Android资源编译失败 [英] Android resource compilation failed after the update

查看:18
本文介绍了更新后Android资源编译失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新android studio后...我的项目因以下错误而崩溃

 Android 资源编译失败输出:C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1668:错误:<item>内部元素必须是资源引用或为空.C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1669:错误:<item>内部元素必须是资源引用或为空.C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1670:错误:<item>内部元素必须是资源引用或为空.C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1671:错误:<item>内部元素必须是资源引用或为空.C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1672:错误:<item>内部元素必须是资源引用或为空.C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1673:错误:<item>内部元素必须是资源引用或为空.C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1674:错误:<item>内部元素必须是资源引用或为空.C:\Users\aliya\Desktop\EventsToday\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1700:错误:<item>内部元素必须是资源引用或为空.命令:C:\Users\aliya\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\c7465495da03cdfc80a78f27c03646df\aapt2-3.2.0-12.windows8exe- 遗产 \-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守护进程:AAPT2 aapt2-3.2.0-4818971-windows 守护进程#0

我的项目级别 gradle 是

//顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项.构建脚本{ext.kotlin_version = '1.2.71'存储库{MavenCentral()//行家{//url 'https://maven.google.com'//}//maven { url 'https://maven.fabric.io/public' }谷歌()jcenter()行家{网址https://maven.google.com"}}依赖{类路径 'com.android.tools.build:gradle:3.2.0'类路径 'com.google.gms:google-services:4.0.2'类路径org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"类路径io.realm:realm-gradle-plugin:5.4.1"//类路径 'com.android.tools.build:gradle:3.0.0-beta1'//注意:不要将您的应用程序依赖项放在这里;他们属于//在单独的模块 build.gradle 文件中}}所有项目{存储库{配置.所有{resolutionStrategy.eachDependency { DependencyResolveDetails 详细信息 ->def 请求 = details.requestedif (requested.group == 'com.google.android.gms') {details.useVersion '12.0.1'}如果(requested.group == 'com.google.firebase'){details.useVersion '12.0.1'}}}谷歌()jcenter()}}任务清理(类型:删除){删除 rootProject.buildDir}

和应用级gradle

 应用插件:'com.android.application'应用插件:'kotlin-android'应用插件:'kotlin-android-extensions'应用插件:'realm-android'安卓 {compileSdkVersion 27默认配置{applicationIdwaleed.com.eventstoday"minSdk 版本 21目标SDK版本27版本代码 1版本名称1.0"testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"}构建类型{构建类型{调试{buildConfigField "String", "baseUrl", '"www.google.com"'buildConfigField "String", "buildName", '"Development"'buildConfigField "String", "countryCode", '"+92"'}释放 {buildConfigField "String", "baseUrl", '"www.google.com"'buildConfigField "String", "buildName", '"Release"'buildConfigField "String", "countryCode", '"+92"'minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}}}依赖{实现文件树(目录:'libs',包括:['*.jar'])实现org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"实现 'com.android.support:appcompat-v7:27.1.1'实现 'com.android.support.constraint:constraint-layout:1.1.3'实现 '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'实现 'com.squareup.retrofit2:retrofit:2.3.0'实现 'com.squareup.retrofit2:converter-gson:2.3.0'实现 'com.squareup.okhttp3:logging-interceptor:3.4.1'实现 'com.intuit.sdp:sdp-android:1.0.5'实现 'com.facebook.android:facebook-login:4.35.0'实现 'com.squareup.picasso:picasso:2.71828'实现 'com.google.android.gms:play-services-auth:16.0.0'实现 'com.parse:parsetwitterutils-android:1.10.6'实现 'com.parse:parse-android:1.16.3'实现 'io.smooch:core:5.12.1'实现 'io.smooch:ui:5.12.1'实现 'com.android.support:recyclerview-v7:27.1.1'实现 'com.android.support:cardview-v7:27.1.1'实现 'com.google.android.gms:play-services-maps:15.0.1'}存储库{MavenCentral()}领域{同步启用 = 真}应用插件:'com.google.gms.google-services'

请告知是否需要更多信息.任何帮助将不胜感激.更新后它不起作用也尝试将gradle降级到3.1.0但它没有用刚刚在 build->intermediates->incremental->mergeDebugResources->merge.dir->values->values.xml 中打开 values.xml 我有错误<块引用>

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

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

解决方案

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

改变这个:

到这个:

After the updating the android studio... my project is crashed with the error below

    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

My Project level gradle is

    // 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
}

And app level gradle

    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'

Please do tell if there is any more information required. Any help will be appreciated. After the update its not working have also tried to downgrade the gradle to 3.1.0 but it did not work Just opened the values.xml in build->intermediates->incremental->mergeDebugResources->merge.dir->values->values.xml i have errors

urn:oasis:names:tc:xliff:document:1.2 showing URI is not registered

" xmlns:ns2="http://schemas.android.com/tools" showing URI is not registered

解决方案

search for type="id" in whole project, then for every instance remove item tag contents, for example:

change this:

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

to this :

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

这篇关于更新后Android资源编译失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆