I am developing an Android application using RxJava and Retofit. When I test my code on API 23 I get no errors however when I test in API 15, my RxJava doesnt appear to work
Thanks for bikash, his top solution really works.Yet in my program, my Application class has extended another ***Application. I finally solve this by overriding attachBaseContext(Context base) function in my application class to initial MultiDex. In a word, I do like this:
defaultConfig {//first step
multiDexEnabled true
}
dependencies {compile 'com.android.support:multidex:1.0.1'}//second
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);//finally
}
You can get more information from this page
The problem here is may be you have not initialized MultiDex Option
Multidex support for Android 5.0 and higher
Android 5.0 and higher uses a runtime called ART which natively supports loading multiple dex files from application APK files. ART performs pre-compilation at application install time which scans for classes(..N).dex files and compiles them into a single .oat file for execution by the Android device. For more information on the Android 5.0 runtime, see Introducing ART. This is the reason why your app is working fine on API level 21.
Multidex support prior to Android 5.0
Versions of the platform prior to Android 5.0 use the Dalvik runtime for executing app code. By default, Dalvik limits apps to a single classes.dex bytecode file per APK. In order to get around this limitation, you can use the multidex support library, which becomes part of the primary DEX file of your app and then manages access to the additional DEX files and the code they contain.
So, Firstly making sure you have imported correct dependency, which It seems you did it.
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
In your manifest add the MultiDexApplication
class from the multidex support library to the application element.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
// This will solved the problem
android:name="YourAppName">
...
</application>
</manifest>
This is how i solved my problem, even there is closed Git issue regarding the same.
EDIT
public class YouAppName extends MultiDexApplication {
.. ..
}
I hope it will help you out.