Using API 21 multidex behavior even if minSdkVersion < 21

112 views
Skip to first unread message

Csaba Kozák

unread,
Nov 13, 2015, 6:02:43 AM11/13/15
to adt-dev
The multidexing documentation suggest to developer to add a flavor which uses minSdkVersion >= 21.
This way a more effective multidexing can be used during Gradle build, which is faster then legacy multidex.

This is great, but it has a caveat: if a developer uses minSdkVersion >= 21 in the development flavor which he
uses for dev he could unintentionally call APIs which are only available from API 21.
But the real minSdkVersion is lower than 21, so this will cause problems on older Android versions.

Is there a way to instruct the multidexing task to use the API 21 behaviour, but leave the minSdkVersion intact for other tasks (and AS)?

Thanks in advance!

Jake Wharton

unread,
Nov 13, 2015, 3:48:03 PM11/13/15
to adt-dev

That would only be true if you put code in src/fast/java (assuming the variant is named 'fast'). The default config (and thus main code) can retain the normal minSdk.


--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Csaba Kozák

unread,
Nov 13, 2015, 5:00:13 PM11/13/15
to adt...@googlegroups.com
Apparently Android Studio does not work this way. If i select the 'fastDebug' variant, calling
API 21 methods are no longer underlined with red. :( The code is under src/main/java.


--
You received this message because you are subscribed to a topic in the Google Groups "adt-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adt-dev/SY2IZxmOrqU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adt-dev+u...@googlegroups.com.

Xavier Ducrohet

unread,
Nov 14, 2015, 10:55:57 PM11/14/15
to adt...@googlegroups.com
This is a problem we are aware of, and we have plans to fix/improve this in the coming months. Stay tuned.
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

Csaba Kozák

unread,
Nov 15, 2015, 4:27:12 AM11/15/15
to adt...@googlegroups.com
Thanks Xavier for the feedback. Looking forward for it, as my build really slowed down due to multidex.

Csaba Kozák

unread,
Nov 23, 2015, 2:09:45 PM11/23/15
to adt-dev
BTW Xavier, is there any workaround to make AS and LINT think minSdkVersion is lower than 21?
Or leave minSdkVersion on lower value and make dexing think minSdkVersion is at 21?
Reply all
Reply to author
Forward
0 new messages