The android platform is a beautiful platform and with beauty comes a few quirks.
One of them is the over 65k method constraint.
I ran into this snag recently after over 3 years of writing Android applications. I wasn't all that miffed, I was expecting it sooner or later.
This is also the root error that causes the "java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$attr"
error even after cleaning and re-adding the appcompatv7 library to your project. It can also fix the "java exit with code 2" error while trying to build your app.
Here is a short and direct way to fix this issue and build apps that would work, with the appropriate references at the end of the page.
This article assumes you are familiar with using Android Studio and Gradle.
- You would need to configure you application for multidex support. View below.
// Enabling multidex support.
Note: You can specify the multiDexEnabled setting in the defaultConfig, buildType, or productFlavor sections of your Gradle build file.
<?xml version="1.0" encoding="utf-8"?>
Note : If you have written a custom Application class, just have it extends MultiDexApplication
- Run your application and all should be well with the world.
You might want to check https://developer.android.com/tools/building/multidex.html for reference and an oversight into the limitations of using MultiDexApplication.
Feel free to drop any ideas or comments.