Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'ProductFlavor.resConfigs' has a value 'auto' which is obsolete and has not been replaced

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']
        }
        ...     
    }
    ...
}
like image 340
Alexander Savin Avatar asked Mar 26 '18 18:03

Alexander Savin


2 Answers

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

like image 51
MatPag Avatar answered Sep 28 '22 02:09

MatPag


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.
like image 25
Alexander Savin Avatar answered Sep 28 '22 04:09

Alexander Savin