Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 466
DUKE Avatar asked Feb 06 '16 11:02

DUKE


3 Answers

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

like image 51
appersiano Avatar answered Nov 01 '22 06:11

appersiano


In my case there were a few layout unfortunately using ids of the form "@id/android:foo". Turning them into "@+id/foo" solved the issue.

This happened when upgrading to AGP 3.3.

You can search for the regexp ="@\+[^"]*:[^"]*" in your layout folder.

like image 7
Snicolas Avatar answered Nov 01 '22 08:11

Snicolas


Actually you can't even have name like break because you will get similar error from compiler:

Error: break is not a valid resource name (reserved Java keyword)
like image 1
LLL Avatar answered Nov 01 '22 08:11

LLL