7

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

Ali Yar Khan
  • 1,231
  • 2
  • 11
  • 33
  • Please check the following link. I hope it helps :) [https://stackoverflow.com/questions/52076491/android-inner-element-must-either-be-a-resource-reference-or-empty](https://stackoverflow.com/questions/52076491/android-inner-element-must-either-be-a-resource-reference-or-empty) – Kylo Ren Sep 26 '18 at 13:40
  • Did you try to clean and build? – MidasLefko Sep 26 '18 at 13:41
  • @KyloRen i have checked and it doesn't solve my problem – Ali Yar Khan Sep 26 '18 at 15:23
  • @MidasLefko yeah i have tried to clean and build it again but nothing happend ! – Ali Yar Khan Sep 26 '18 at 15:28

4 Answers4

8

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>
AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
  • 2
    it was gradle version problem i was using 3.2.0 ... but the libraries didn't support so i have to degrade the version to 3.1.4 and its working fine now .. By the way thanks for your help – Ali Yar Khan Oct 06 '18 at 16:28
4

In your project, go through all of the src/main/res/values/<name>.xml files and look for constructs like:

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

The thing is IDs can either have no value (creates a new ID) or refer to other IDs (using @id/other_id syntax in the value field). Just remove the values to match:

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

or

<item type="id" name="my_id"/>
Izabela Orlowska
  • 7,431
  • 2
  • 20
  • 33
  • 1
    it was gradle version problem i was using 3.2.0 ... but the libraries didn't support so i have to degrade the version to 3.1.4 and its working fine now .. By the way thanks for your help – Ali Yar Khan Oct 06 '18 at 16:29
0

In my case I changed <color name="colorBlack">#00000</color> to <color name="colorBlack">#000000</color> I'd look for something similar and fix it

alliumvault
  • 3
  • 1
  • 3
0

it was gradle version problem i was using 3.2.0 ... but the libraries didn't support so i have to degrade the version to 3.1.4 and its working fine now.

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/25557392) – veben Mar 09 '20 at 08:36
  • 1
    @veben it was my own question and i have answered it. So it might help others kindly accept it as answer. Thanks –  Mar 09 '20 at 10:50