无法使用 SDK 构建工具 21 或更高版本过滤多种密度的资产

Cannot filter assets for multiple densities using SDK build tools 21 or later

由于使用 gradle 插件 1.3.0 在发布模式下构建我的应用程序时出现问题,我已切换到 1.4.0(测试版 2),它修复了上述构建问题。

然而,尽管某些版本构建完美,但其他版本的构建却因以下错误消息而中止:

Cannot filter assets for multiple densities using SDK build tools 21 or later. Consider using apk splits instead.

我没有找到任何参考上面的句子,我应该如何处理这些口味的资源,甚至为什么这个错误只出现在几个口味而不是所有口味中。

编辑:build.gradle

apply plugin: 'com.android.application'

android {
    signingConfigs {
        config {
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    defaultConfig {
        applicationId "com.example.appname"
        minSdkVersion 8
        targetSdkVersion 23
        versionCode 1
        versionName '0.0.1'
    }
    buildTypes {
        release {
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            minifyEnabled true
            zipAlignEnabled true
            signingConfig signingConfigs.config
        }
        debug {
            applicationIdSuffix 'debug'
            versionNameSuffix '_debug'
        }
    }
    flavorDimensions "googleplay"
    productFlavors {
        noplay {
            dimension "googleplay"
            versionCode Integer.parseInt(defaultConfig.versionCode + "0")
            buildConfigField "boolean", "HAS_GOOGLE_PLAY", "false"

            resConfigs "ldpi", "mdpi"
            // so far we are using the noplay flavor only for old devices, which do not have hidpi
        }
        play {
            dimension "googleplay"
            versionCode Integer.parseInt(defaultConfig.versionCode + "1")
            buildConfigField "boolean", "HAS_GOOGLE_PLAY", "true"
            minSdkVersion 9
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    // Google Play services (analytics)
    playCompile 'com.google.android.gms:play-services-analytics:8.1.0'

    // ActionBar and support libraries
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:support-v4:23.0.1'
}

resConfigs 替换为 APK splits for densities and architectures. Note the following sentence:

When using build tools older than 21 you could also add resConfigs "nodpi", "hdpi" to also limit the density folders that are packaged. Instead, use apk splits to provide different apks to devices with different densities.

有个bug report for this issue.

必须删除有问题的 resConfigs,可以使用 apk 拆分代替。

或者,切换到构建工具 20.0.0 似乎可以解决这个问题。