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

2021-6-21 anglehua

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

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: ''

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

repositories { mavenCentral() }

dependencies {
    compile ''
    compile ''
    compile ''
    compile ''
    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

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

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.


Powered by emlog 京ICP备15036472号-3 sitemap