Android build error for values-b+sr+Latn

2019-02-24 06:35发布

Hi i am trying to build my first project using Android support libraries in order to support material design for all of the devices on market. At the very begining of my journey i create a project from scratch and when i build from graddle using this module configuration:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "19.1"
    defaultConfig {
        applicationId "com.sunshine.org.weather"
        minSdkVersion 13
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
    testCompile 'junit:junit:4.12'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:support-v13:24.2.1'
}


i get theese errors -->>>


GRADDLE ERROR:
:app:generateDebugResources UP-TO-DATE :app:mergeDebugResources :app:processDebugManifest UP-TO-DATE :app:processDebugResources invalid resource directory name: C:\Users\weather\app\build\intermediates\res\merged\debug/values-b+sr+Latn

FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:processDebugResources'. com.android.ide.common.process.ProcessException: Failed to execute aapt

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED
When i deleted the "values-b+sr+Latn" folder containing the coresponding XML file, it always gets recreated by the studio when i build my project. I Tried to clean and build but that did not serve as solution to my problems.


I am trying to run the app on KitKat(API Level 14) and want to have material design down to HONEYCOMB(API Level 13) and support application up to NOUGAT(API Level 24) Could you please point out my mistakes?

3条回答
男人必须洒脱
2楼-- · 2019-02-24 07:22

Some background

Android 7.0 (API level 24) introduced support for BCP 47 language tags, which you can use to qualify language- and region-specific resources. A language tag is composed from a sequence of one or more subtags, each of which refines or narrows the range of language identified by the overall tag. For more information about language tags, see Tags for Identifying Languages.

To use a BCP 47 language tag, concatenate b+ and a two-letter ISO 639-1 language code, optionally followed by additional subtags separated by +.

Examples:

  • b+en
  • b+en+US
  • b+es+419

https://developer.android.com/guide/topics/resources/providing-resources.html#QualifierRules

How to fix this

Since this feature was introduced in API 24 I suspect updating build tools to at least 24 would resolve the issue.

android {
    buildToolsVersion "27.0.3"
}

Latest Android plugin for Gradle will take care of build tools version automatically so you can remove the line altogether.

查看更多
放荡不羁爱自由
3楼-- · 2019-02-24 07:28

Try this in build.gradle

aaptOptions {
    ignoreAssetsPattern "!values-b+sr+Latn"
}
查看更多
▲ chillily
4楼-- · 2019-02-24 07:38

To expand on powder366's answer, and the comment, since I don't have the rep to comment myself.

Inside the Gradle Script called 'build.gradle' for the Project:Name, there is an 'android' section with brackets. Inside those brackets you can add

aaptOptions { ignoreAssetsPattern "!values-b+sr+Latn" }

So you'd end up with something like

android {
   aaptOptions {
       ignoreAssetsPattern "!values-b+sr+Latn"
   }


}

That fixed it for me right away, when Rebuilding the project

查看更多
登录 后发表回答