I have an Android Studio project that is working fine on devices with Android build version Lollipop but is throwing an exception when trying to run it on a device with andr
This is how I solved the problem if anyone gets here.
After I searched deeply about the problem, I found out that it's not an inflating exception though that's what the logcat said, the real exception was OutOfMemory exception caused by the infamous 65K problem click here for more information about the problem and it was wrapped with the inflate excpetion.
To solve the problem, I firstly added the multidex support library in my build.gradle file:
compile 'com.android.support:multidex:1.0.0'
Then I followed these three simple steps to make it work:
If you’re not implementing an Application class yourself, you can simply define the library’s MultiDexApplication in your Android Manifest file under the application tag:
android:name="android.support.multidex.MultiDexApplication"
If you are implementing your own Application class, you can either simply override the MultiDexApplication file:
public class MyAwesomeApplication extends MultiDexApplication {
Or if your application class is already extending another class, you can just override attachBaseContext method and add the following call to it:
@Override protected void attachBaseContext(Context base) { super.attachBaseContext(context); Multidex.install(this); }
I already had my own application class that extends from class "Application" so I jumped directly to step 3 and voila it worked on Kitkat and on Lollipop.
Hope this helps anyone. Happy Coding.