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
- 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
In my case
- clean project
- invalidate and restart
it's work
Another ugly reason for this to be caused is if you're trying to attach a debugger with breakpoint on something that happens during Activity creation.