Error: ':' is not a valid resource name character

DUKE picture DUKE · Feb 6, 2016 · Viewed 22.8k times · Source

I have imported my eclipse project to android studio.I googled but not getting right answer. These errors are occurred-

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

My bulid gradle app code is

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')
}

Please resolve my issue. Thank you

Answer

appersiano picture appersiano · Feb 6, 2016

Error: ':' is not a valid resource name character

means that you have a resource name like

<string name="not:valid">Foobar</string>

but colon are not allowed.

Try this:

  • Open your string.xml

  • Type Ctrl + F (on Win/Linux)

  • Check Regex and search by "[A-Za-z_]*:[A-Za-z_]*"

  • Remove colon and if necessary replace with an underscore _

  • Compile your apk