-1

I am trying to create a release universal build apk on mac machine and wanted to exclude tvdpi drawable folder. But i am not able to do so, I have used the following in my build.gradle file:

splits {
        density {
            enable false
            include "nodpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"
            exclude "ldpi", "tvdpi"
        }
    }

My SDK tool version is 23.0.2 Gradle version : 2.0.0-alpha3

Please let me know how to fix it, am i missing anything here?

Fahim
  • 12,198
  • 5
  • 39
  • 57

3 Answers3

0

If you are just trying to get rid of unused resources, set ShrinkResources to true in your buildType. and set shrinkMode to strict.

How? Check my question a few days earlier which looks related to this one. - Link.

My question was just specific to drawables, but the same thing will take care of all resources.

Community
  • 1
  • 1
Viral Patel
  • 32,418
  • 18
  • 82
  • 110
  • already i have used shrinkResources true in my gradle file – Fahim Dec 21 '15 at 09:04
  • yes but that is not sufficient. Gradle will still do some guessing and leave out some resources it is not sure of being unused. Setting the shrinkMode to strict will ensure that everything not used of removed 100% – Viral Patel Dec 21 '15 at 09:15
  • i want to exclude specific folder from res, but your solution is not working – Fahim Dec 21 '15 at 10:16
0

I think you need to set enable to true as mentioned in this link

enable: enables the density split mechanism
exclude: By default all densities are included, you can remove some densities.
include: indicate which densities to be included
Osama Mohammed Shaikh
  • 1,219
  • 1
  • 16
  • 40
  • But this doesn't solve my problem, i want a single apk with few density folders in them. i dont need separate apks for for all density's – Fahim Dec 24 '15 at 12:25
  • Ok so by following the mentioned code in your question are you getting multiple apk's? – Osama Mohammed Shaikh Dec 24 '15 at 12:33
  • if i make enable=true, it will create multiple apks – Fahim Dec 24 '15 at 12:38
  • Ok, then what does this line means in documentation itself, `"Note that this will also always generate a universal APK with all the densities."` – Osama Mohammed Shaikh Dec 24 '15 at 12:40
  • I didn't got any answer, so at end i have to go with split apk.. so i am assigning you the bounty but i will not accept the answer... i will still for some one to answer it – Fahim Dec 30 '15 at 13:28
0
sourceSets {
    main {
        resources {
            exclude '**/drawable-tvdpi/*'

        }
    }
}

using Gradle 1.1 I am able to achieve this with source path.Hope this will help.

KDeogharkar
  • 10,939
  • 7
  • 51
  • 95
  • This didn't work for me. I can still see those resources inside the apk file. my gradle version is 2.0.0-alpha3 – Fahim Dec 24 '15 at 14:18