错误:':'不是有效的资源名称字符

DUK*_*UKE 8 r.java-file android-studio

我已将我的eclipse项目导入到android studio.I谷歌搜索但没有得到正确的答案.发生这些错误 -

D:\***\app\src\main\res\values\strings.xml
Error:Error: ':' is not a valid resource name character
:app:mergeDebugResources FAILED
Error:Execution failed for task ':app:mergeDebugResources'.
> D:\****\app\src\main\res\values\strings.xml: Error: ':' is not a valid resource name character
Run Code Online (Sandbox Code Playgroud)

我的bulid gradle应用程序代码是

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.******.***"
        minSdkVersion 21
        targetSdkVersion 22
        multiDexEnabled true     }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories { mavenCentral() }

dependencies {
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.google.android.gms:play-services:+'
    compile files('libs/httpmime-4.1.1.jar')
    compile files('libs/ormlite-android-4.43.jar')
    compile files('libs/ormlite-core-4.43.jar')
}
Run Code Online (Sandbox Code Playgroud)

请解决我的问题.谢谢

app*_*ano 11

错误:':'不是有效的资源名称字符

意味着你有一个像这样的资源名称

<string name="not:valid">Foobar</string>
Run Code Online (Sandbox Code Playgroud)

但不允许冒号.

试试这个:

  • 打开你的 string.xml

  • 键入Ctrl+ F(在Win/Linux上)

  • 检查正则表达式 并搜索"[A-Za-z_]*:[A-Za-z_]*"

  • 删除冒号,必要时用下划线替换 _

  • 编译你的 apk


Sni*_*las 7

在我的情况下,有一些布局不幸使用表单的ID "@id/android:foo".把它们变成了"@+id/foo"解决问题的方法.

升级到AGP 3.3时会发生这种情况.

您可以="@\+[^"]*:[^"]*"在布局文件夹中搜索正则表达式.

  • 是的,升级到AS 3.3带来了这个 (2认同)