8

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

DUKE
  • 137
  • 1
  • 1
  • 7

4 Answers4

12

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

appersiano
  • 2,466
  • 20
  • 36
7

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.

Snicolas
  • 36,854
  • 14
  • 106
  • 172
1

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)
LLL
  • 1,510
  • 1
  • 12
  • 27
0

compile 'com.android.support:design:23.1.1' I think you should try "-" instead of colon after design