With the Android plugin for Gradle, version 2.2.0 (released in September 2016) you can use multiDexKeepFile api
android { buildTypes { debug { ... multiDexEnabled true multiDexKeepFile file('multidex_keep_file.txt') } } }
Where multidex_keep_file.txt is a file with one class per line, which should be explicitly added to the main dex file
com/example/MyClass.class com/example/MyClass2.class
You can also use multiDexKeepProguard to store the entire package.
-keep class com.example.** { *; }
source share