簡體   English   中英

索引 40 處的非法字符 <:>:com.recognize.app-mergeDebugResources-33:/values/values.xml)

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

由於此錯誤,我無法編譯我的應用程序

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).

我不知道發生了什么......

build.gradle(模塊)

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(項目)

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

我不知道我應該在這里放什么其他信息。 有沒有可能是因為某個圖書館?

我最近添加了這個庫(在添加這個庫之前構建工作,但我在字符串中添加了更多的東西。xml,新的 Java 類,布局等)但我不知道這是否是它的錯,因為在 GitHub 的問題中沒有人有這個問題....

我的 attrs.xml 文件是

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <attr name="state_error"  />   <======HERE WAS THE PROBLEM
    <declare-styleable name="ValueEditor">
       <attr name="nameShown" format="string"/>
       <... other definitions />
    </declare-styleable>
</resources>

名稱為 state_error 的 attr 導致了問題。 一定是從一些復制粘貼源代碼那里得到的,因為當我刪除它時,問題就消失了。

每個大於該值的實現 'com.google.android.material:material:1.6.0-alpha02' 都會出現問題

我在開發庫時遇到了同樣的問題,經過幾次嘗試,我發現這與 attrs 相關。 庫項目的 attrs.xml 文件中有一個屬性“colorScheme”:

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

但在生成的 \merged.dir\values\values.xml 文件中搜索后,它還有另一個“colorScheme”:

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

所以我把我的“colorScheme”改成了一個獨特的,問題就解決了。

我認為您可以聯系圖書館的作者或分叉圖書館並自己嘗試這些步驟。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM