Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Due to an issue building my application in release mode with the gradle plugin 1.3.0, I have switched to 1.4.0 (beta 2), which fixes said build issue.

However, whereas some flavors build perfectly, others have their build aborted with the following error message:

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

I haven't found any reference to the sentence above, what should I do with the resources of these flavors, or even why this error only appears in a couple of flavors and not in all of them.

Edit: 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'
}
like image 321
Jose Gómez Avatar asked Sep 21 '15 12:09

Jose Gómez


People also ask

Where is buildToolsVersion located?

For the compileSdkVersion you can goto Tools > Android > SDK Manager . This will pull up a window that will allow you to manage your compileSdkVersion and your buildToolsVersion .

What is the buildToolsVersion for Android SDK 32?

Android SDK Build-Tools — 32.0. 0. NDK (Side by Side) — 23.1. 7779620.

What is Buildtype in Gradle Android?

Build types define certain properties that Gradle uses when building and packaging your app, and are typically configured for different stages of your development lifecycle.

What is missingDimensionStrategy?

void missingDimensionStrategy ( String dimension, String requestedValue) Specifies a flavor that the plugin should try to use from a given dimension in a dependency. Android plugin 3.0. 0 and higher try to match each variant of your module with the same one from its dependencies.


1 Answers

resConfigs is replaced by 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.

There is a bug report for this issue.

The offending resConfigs have to be removed, and apk splits can be used in their instead.

Alternatively, switching to build-tool 20.0.0 seems work around this problem.

like image 113
Hexise Avatar answered Oct 23 '22 10:10

Hexise