Java.Lang.Noclassdeffounderror: Failed Resolution Of: Landroid/Support/V4/Os/Buildcompat

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/os/BuildCompat

You are getting NoClassDefFoundError & ClassNotFoundException

NoClassDefFoundError in Java comes when Java Virtual Machine is not
able to find a particular class at runtime which was available at
compile time.

FYI

You are using Eclipse. Android Studio is a far simpler way to develop for Android if you manage to get the hang of it. For developers who have been using Eclipse, migrating to Studio is a nightmare for them. Eclipse is dead (My personal opinion).

For your NoClassDefFoundError problem goto rebuild option under Project > Clean and then select the project you want to clean up .Then Restart your Eclipse and run again .

Solutions

Check your classpath contains that jar (AppCompat), if your classpath
doesn't contain the jar then just add that class in your classpath.

You should Use Android Studio instead of Eclipse . Read

  1. Support Library Features

The Gradle build script dependency identifier for this library is as follows:

com.android.support:appcompat-v7:24.2.1

Then Clean-Rebuild-Restart IDE

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/graphics/ColorUtils;

Change these dependencies

compile('com.android.support:appcompat-v7:25.0.1') {
exclude module: 'support-v4'
}
compile('com.android.support:recyclerview-v7:25.0.1')

to

compile('com.android.support:appcompat-v7:25.0.0') 

compile('com.android.support:recyclerview-v7:25.0.0')

Don't know why you exclude v4, but if it's not for some reason I would keep it.

Don't know why its happening, but It happened to me recently and a fix was to match buildToolsVersion with support libraries version.

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/graphics/drawable/DrawableWrapper;

So there are two possible duplicates of this question: here and here. They both come to conclusion that upgrading your Android Support Library to the latest version will fix the problem. Along with that, a clean and rebuild of the project and a restart of Android Studio could also help.

How to resolve NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;

Sometimes after an upgrade, you need to invalidate and clear cache.

Sample Image

There are some known issues in 3.2 so also ensure you are not on Kotlin tools
org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.70

as that causes freeze issues as well.
If that doesn't work, remove your google plugin lines and support libraries, sync and add them again and sync. Sometimes the cache directories just get out of whack.

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/util/ArrayMap

Just moving the comments into an answer.

The 9.8.0 version of the firebase library is outdated and might not work well with the other support libraries.

Try using the current version. (10.0.1 as of this answer). You'll also need to update the other Play Services dependencies accordingly

NoClassDefFoundError: Failed resolution of: Landroid/support/v7/appcompat/R$styleable

You are getting that error because of the following reasons:

In your Gradle build file your app is targeting and compiling with the beta version of Android that is still in development with:

compileSdkVersion 'android-L'
buildToolsVersion '20'

as well as

minSdkVersion 20
targetSdkVersion 20

First thing to note is that this app will not run correctly (at this time) on any device without android-L flashed to it.

The real crux of your issue is in DisplayMessageActivity, it extends via inheritance
[ActionBarActivity]:(https://developer.android.com/reference/android/support/v7/app/ActionBarActivity.html) this is one of the support library classes for AppCompat.

To fix this, change your min SDK to 10 (or 14 which is ice cream sandwich), your max SDK to 19 (Kit Kat) and un-comment the appcompat-v7 library in your dependencies.

As a side note, when you declare widgets in their respective activities/fragments it's usually good practice to have their scope be outside of any methods:

EditText editText;
Button sendMessageButton;

// Then in your onCreate() method
editText = (EditText) findViewById(R.id.editText);
sendMessageButton = (Button) findViewById(R.id.sendMessageButton);

This helps reduce memory re-allocation and make your code a little more readable. Sometimes you may have to bend the rules a bit but this is the common practice.



Related Topics



Leave a reply



Submit