Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Illegal char <:> at index 40: com.recognize.app-mergeDebugResources-33:/values/values.xml)

I can't compile my app because of this error

com.android.aaptcompiler.ResourceCompilationException:
Resource compilation failed
(Failed to compile values resource file C:\Users\hesam\AndroidStudioProjects\RecognizeProject\app\build\intermediates\incremental\debug\mergeDebugResources\merged.dir\values\values.xml. 
Cause: java.nio.file.InvalidPathException: Illegal char <:> at index 40: com.recognize.app-mergeDebugResources-33:/values/values.xml).

and I don't know what's going on...

build.gradle (module)

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
    id 'com.google.firebase.crashlytics'
    id 'com.google.firebase.firebase-perf'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.recognize"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation platform('com.google.firebase:firebase-bom:30.0.1')
    implementation 'com.google.firebase:firebase-auth'
    implementation 'com.google.firebase:firebase-database'
    implementation 'com.google.firebase:firebase-storage'
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-crashlytics'
    implementation 'com.google.firebase:firebase-perf'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.6.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'io.github.yanndroid:oneui:2.4.0'
    implementation 'com.mikhaellopez:circularimageview:4.3.0'
    implementation 'com.github.bumptech.glide:glide:4.13.0'
    implementation 'io.github.chaosleung:pinview:1.4.4'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.13.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

build.gradle (project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
        classpath 'com.google.firebase:perf-plugin:1.4.1'
    }
}

plugins {
    id 'com.android.application' version '7.2.0' apply false
    id 'com.android.library' version '7.2.0' apply false
}

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

I don't know what other information I should put here. Is it possible that it's because of some library?

I recently added this library (build works before adding this lib but i was adding more stuff like strings to strings.xml, new Java classes, Layouts etc.) but I don't know if it's its fault because in Issues on GitHub nobody had this problem....

like image 751
thewolf1119 Avatar asked Nov 17 '25 12:11

thewolf1119


2 Answers

I'm facing the same problem while developing a library, after several tries I found this related to the attrs. There is a property "colorScheme" in the attrs.xml file of the library project:

<declare-styleable name="GridColorPicker">
   <attr name="colorScheme" format="string" />
   <attr name="selectorColor" format="color" />
</declare-styleable>

But after search in the generated \merged.dir\values\values.xml file, it has another "colorScheme" in it:

<enum name="standard" value="0"/>
<enum name="wide" value="1"/>
<enum name="icon_only" value="2"/>
</attr>
<attr format="reference" name="colorScheme">
<enum name="dark" value="0"/>
<enum name="light" value="1"/>
<enum name="auto" value="2"/>

So I changed my "colorScheme" to a unique one the problem was solved.

I think you can contact the library's author or fork the library and try these steps yourself.

like image 123
panshen Avatar answered Nov 19 '25 02:11

panshen


I just ran into this as well. From all the searching, it seems to most often occur in attrs.xml

In order to actually find where your problem is, perform the following steps.

  1. Back-up your attrs.xml
  2. Clear it, so it's only:
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>
  1. Compile. If you get a different error, you know for certain it's in attrs.
  2. Add back in half your attributes. E.g. all attributes starting with A-M
  3. Compile. If the error is back, you know it's in the top half. If not, it's in the bottom half.
  4. If you have the error: remove half your attributes (say G-M). If you don't add extra ones (e.g. N-R).
  5. Keep doing this, until you narrow it down to where adding one line causes the issue, and removing it resolves it.
  6. Rename that attribute.

Some things I ran into:

  • With me, it's often enums.
  • Adding dependencies can cause this issue, probably if they have same-named attributes.
like image 26
Daniël van den Berg Avatar answered Nov 19 '25 02:11

Daniël van den Berg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!