Android error - Caused by: java.lang.NoClassDefFoundError: android.support.v4.util.SparseArrayCompat
Right Click on your project -> Build Path -> Configure Build Path -> Order and Export Tab.
Make sure that "Android Private Libraries" is checked for Export.
If you've added any libraries from the libs/ folder, remove them as they are automatically added in the "Android Private Libraries" section.
Android studio java.lang.NoClassDefFoundError: android.support.v4.app.NavUtilsJB
I had this problem and just found the solution - answer is RTFM! Here are the instructions: https://developer.android.com/tools/building/multidex.html
Multidexing is a new feature and so requires a support library to be compatible with pre-lollipop devices. You need to add the following to your gradle file dependencies:
compile 'com.android.support:multidex:1.0.0'
Also enable multidex output in your gradle file:
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
}
And then add the multidex support application to your manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Note: If your app already extends the Application class, you can override the attachBaseContext() method and call MultiDex.install(this) to enable multidex. For more information, see the MultiDexApplication
reference documentation.
@Override
protected void attachBaseContext(Context context) {
super.attachBaseContext(context);
MultiDex.install(this);
}
Again, see the instruction above for more information...
Hope this helps
java.lang.NoClassDefFoundError when running app with Android 5.1 with Android Studio 2.2RC
Here what we can see in runtime/dex_file.cc
bool DexFile::OpenFromZip(...) {
...
while (i < 100) {
std::string name = StringPrintf("classes%zu.dex", i)
...
}
...
}
So if you have more than 100 dex files you get this NoClassDefFoundError.
There are issues in the tracker for this behavior:
https://code.google.com/p/android/issues/detail?id=234367
https://code.google.com/p/android/issues/detail?id=170485
It is possible to avoid this error by disabling pre-dexing. So you can put something like
subprojects {
project.plugins.whenPluginAdded { plugin ->
if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = false
} else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = false
}
}
}
in the root build.gradle file.
Error java.lang.ClassNotFoundException After Upgrading to AndroidX and Android Studio 4.0
I've already fixed the problem. Found the solution from this answer
java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion
The solution is to add
<uses-library android:name="org.apache.http.legacy" android:required="false" />
on manifest file.
I'm not using google maps, but the error might caused by the apache library.
ANDROID: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/mysql/cj/MysqlType
You cannot use recent versions of MySQL Connector/J on Android, because it uses types and features not available on Android. The specific reason here is that the type com.mysql.cj.MysqlType
implements java.sql.SQLType
(introduced in Java 8 / JDBC 4.2), and judging by the error this type does not exist in Android. In the past, I have also seen errors related to using named groups in regular expressions, which are (or were) also not supported on Android.
In general, you shouldn't use JDBC on Android, and it is better to use a REST API to mediate between your Android application and a database. However, if you really want to use MySQL from Android, you will have to use MySQL Connector/J 5.1.x instead of 8.0.x.
Related Topics
Drawerlayout Double Drawer (Left and Right Drawers Simultaneously)
Error: Status{Statuscode=Developer_Error, Resolution=Null}
Linkedlist Put into Intent Extra Gets Recast to Arraylist When Retrieving in Next Activity
Current Month Facebook Friends Birthdays in Android
Changing Overflow Icon in the Action Bar
Toolbar Navigation Icon Never Set
Restoring State of Textview After Screen Rotation
Uploading a Large File in Multipart Using Okhttp
Multiple Instances of Widget Only Updating Last Widget
Location Needs to Be Enabled for Bluetooth Low Energy Scanning on Android 6.0
How to Get Current Flavor in Gradle
Proguard Causing Runtimeexception (Unmarshalling Unknown Type Code) in Parcelable Class
Androidstudio Cannot Find Layout
Solving "Adb Server Version Doesn't Match This Client" Error
Cursor Adapter and SQLite Example
How to Call Wi-Fi Settings Screen from My Application Using Android