6

How to fix the warning below? Are there any alternatives to 'auto'?

Warning:DSL element 'ProductFlavor.resConfigs' has a value 'auto' which is obsolete and has not been replaced. It will be removed at the end of 2018

android {
    ...
    flavorDimensions "device", "paid", "market"
    productFlavors {
        phone {
            // Phone config version for the application
            resConfigs ("auto")
            dimension "device"
            matchingFallbacks = ['mobile']
        }
        ...     
    }
    ...
}
Alexander Savin
  • 1,952
  • 1
  • 15
  • 30

2 Answers2

8

This is the error after updating to Android Studio 3.1:

enter image description here

Based on the official advise here the best thing to do is removing the tag entirely if you support all the languages or supply an array with the language's code your app supports like:

resConfigs "en", "de", "it", "fr" // etc. etc.

More info:

This is one of the resources optimization proposed by the official documentation here so i decided to test this flag with those FirebaseUI dependencies in a sample project

implementation "com.firebaseui:firebase-ui-auth:$firebase_ui_version"
implementation "com.firebaseui:firebase-ui-database:$firebase_ui_version"
implementation "com.firebaseui:firebase-ui-storage:$firebase_ui_version"

creating the debug APK with both the options and those are the results:

  • Using resConfigs "auto" the debug APK was: 3,793 KB
  • Using resConfigs "en" (so 1 language only) the debug APK was: 3,294 KB

This means that with all the string resources for all the languages of those dependencies I got only ~500KB of size increase. That's something you could reason about, you definitely should make a test with the dependencies you use and see if the size increase is negligible or not and consequently decide to provide the list of supported languages or remove the resConfigs option.

PS: If you are using Android FirebaseUI this was one of the suggested optimizations, I've created an issue here about the thing and this has been solved immediately by the awesome guy called SUPERCILEX

MatPag
  • 41,742
  • 14
  • 105
  • 114
1

auto is no longer supported because it created a number of issues with multi-module projects. Instead, you should specify the locale that your app supports. Android plugin 3.1.0 and higher ignore the auto argument, and Gradle packages all string resources your app and its dependencies provide.

com.android.tools.build:gradle:3.2.0-alpha08 BaseFlavor.java

 * <p><b>Note:</b> <code>auto</code> is no longer supported because it created a number of
 * issues with multi-module projects. Instead, you should specify the locale that your app
 * supports, as shown in the sample above. Android plugin 3.1.0 and higher ignore the <code>auto
 * </code> argument, and Gradle packages all string resources your app and its dependencies
 * provide.
Alexander Savin
  • 1,952
  • 1
  • 15
  • 30
  • You mention that "it created a number of issues with multi-module projects". I know the official docs say this, but do you know where I can find more information about specifically what the issues were? For instance I have been trying to find the commit that made `auto` a noop but have been unable to find it (are the sources for the 3.1.0 plugin even published yet?). – Aaron Apr 18 '18 at 14:34
  • 1
    @Aaron Sorry, I don't know where you can find more information about specifically what the issues were. Sources for the 3.1.0 plugin - `https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.0/gradle-3.1.0.pom` – Alexander Savin Apr 18 '18 at 15:06
  • Thanks, but unfortunately the pom only links you to https://android.googlesource.com/platform/tools/base, where I am unable to find sources past 3.0.0. – Aaron Apr 20 '18 at 14:10
  • 1
    @Aaron https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.0/gradle-3.1.0-sources.jar https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle-core/3.1.0/gradle-core-3.1.0-sources.jar etc. – Alexander Savin Apr 20 '18 at 20:13
  • Thanks, I can't believe I overlooked the source jars. Also Google has now published the git history for 3.1.2 and I was able to find the commit I was looking for (though it still doesn't really explain the issue): https://android.googlesource.com/platform/tools/base/+/6b7799c36f1ba5194f73f5c14a7b0365a8428714%5E%21/ – Aaron Apr 25 '18 at 01:10