Android Activity ClassNotFoundException - tried everything
I spent some time play with my own project, and I am able to replicate your problem and get exactly the same exception stack trace when trying to run my main project, so I think this could be the cause:
Just like what I thought, it is all about how you reference your Android library project in the Android main project, a simple Eclipse configuration settings.
The Wrong Way:
Right click main project, choose Properties -> Java Build Path -> Projects -> Add...
, this add the Android library Project as a dependency project in Android main project's build path, this does not work. If all required Android-related resources are defined in main project, you will not get any error at compile time, but when run the application, you get the exception described in the question.
The Correct Way:
Right click main project, choose Properties -> Android
, in the Library section, add your Android library project here. Check out official dev guide Referencing a library project. This should fix all your problem. Also note that you have to use relative path reference the actual Android library project, as stated in the Library Project - Development considerations.
Hope this helps.
How to resolve ClassNotFoundException in Android Studio
This might be the 65k methods limit. Try to use the solutions in the link.
Edit: For others who stumble this issue - @Salman Khan added multiDexEnabled true
to the gradle file (as written in the link) and it solved the problem. It would be still better to read the whole article and follow the steps there.
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.
How to resolve java.lang.ClassNotFoundException in android?
In the view XML file you are using SquareImageView
as the class reference without the full package name. Because you don't include the full package name, Anroid assumes that SquareImageView
is in the android.view
package and cannot find the class. You need to add the full package name in your view XML file.
ClassNotFoundException on Android API 26 for MainActivity (working with API 30)
I looked into the dexing error description and found another question regarding java 8 support. Implementing
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
and
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9'
into the app's build.gradle file solved the problem.
More information here
Android: ClassNotFoundException while class is present
This seems to be a problem with the multidex support. Please see the following thread
FATAL EXCEPTION: main java.lang.NoClassDefFoundError: rx.plugins.RxJavaHooks
Android Studio: ClassNotFoundException
I created a new project in Android studio and copied everything from the old project into the new one. Now it's working again, without any(!) modifications to the code.
ClassNotFoundException: android.view.OnBackInvokedCallback with Compose 1.2.0-alpha07
Try using Activity 1.5.0-beta01 as 1.6.0-alpha01 is only compatible with Android 13 Developer Preview 2 SDK as indicated here: https://developer.android.com/jetpack/androidx/releases/activity#1.6.0-alpha01
Related Topics
How One Interface Can Be Used for Different Background Android Tasks
Navigation View Items Will Not Respond When Pressed
Android Archive Library (Aar) VS Standard Jar
Asynctask.Executeonexecutor() Before API Level 11
Error Inflating When Extending a Class
Android Httppost: How to Get the Result
How to Catch a Firebase Auth Specific Exceptions
Best Way to Implement View.Onclicklistener in Android
How to Save Bitmap to Android Gallery
Java Doesn't Work with Regex \S, Says: Invalid Escape Sequence
Android Days Between Two Dates
Passing a JavaScript Object Using Addjavascriptinterface() on Android
Stream Live Android Audio to Server
Decompile an APK, Modify It and Then Recompile It
Cordova Could Not Reserve Enough Space for 2097152Kb Object Heap
Difference Between Actionbarsherlock and Actionbar Compatibility