I have a simple 2d mobile game that I'm working on and it was made in Unity. I want to have an option to share info on Facebook, however, when I add the FacebookSDK to the project, even if I'm not even using anything from it besides the Facebook Settings, the project's build stops working and crashes whenever I try to open it.
I checked the problem and it seems to be something related to the FacebookContentProvider, since I had this error showing up in my log:
java.lang.RuntimeException: Unable to get provider com.facebook.FacebookContentProvider: java.lang.ClassNotFoundException: Didn't find class "com.facebook.FacebookContentProvider" on path: ...
Did anyone have problems with this kind of thing before? I tried changing the AndroidManifest file and play a little with some of the settings in the Facebook Developer's page but nothing seems to work.
I'm using Unity 2019.1.14f1 and FacebookSDK 7.17.2, but I also tried with different versions of the FacebookSDK (7.15.1 and 7.16.1), but got the same problem.
EDIT: This problem has not already been resolved in the other suggested SO question
I had a fully working app on the market for over a year, with very few crash reports. Then recently I changed my app into a library, so that it could be included within multiple different "wrapper" projects. This was so that I could easily make different version - free, paid, non-google markets, with/without in-app purchasing etc etc.
The new "library+wrapper" app appeared to work fine. I could run it multiple times, without error. But then a day later (when presumably the OS had closed some or all of the app's activities) I tried to run it and it reported
Unable to instantiate application com.mycompany.mygamelibrary.MyGameApplicationClass: java.lang.ClassNotFoundException: com.mycompany.mygamelibrary.MyGameApplicationClass
The class it failed to find is the first class that runs when the program starts up, MyGameApplicationClass - which extends Application. This class is part of the library.
I suspect something goofy in one of the two manifest files.
The manifest of the wrapper project contains the lines...
<application android:icon="#drawable/mygame_icon"
android:screenOrientation="portrait" android:label="My Game Name"
android:name="com.mycompany.mygamelibrary.MyGameApplicationClass">
Any ideas what could have gone wrong?
EDIT: The library was referenced "the correct way" as defined by yorkw's answer to this SO question.
EDIT: I can not repeat the crash at the moment :-( I don't know what it is the OS does when the app is not used for a day or two.
There are two possibilities. Either you, like me, have a spelling error in your manifest file. Have a co-worker or friend read it to make sure the name is correct. Or you have not referenced the project correctly.
The official document describes how to properly link projects in its documentation.
Why it would first seem to work and later stop working is a bit of a mystery. However, I guess that the VM might still have had the necessary references ready to resolve the classes in the library just fine. A restart of the VM removed all those references and trying to resolve them was unsuccessful.
Update: Regarding the edits in the OP: As you confirm that you have correctly referenced the other project, you can check if the project is included in APK, just to be sure. You can rename and open an APK as any other archive (.rar works fine for me). Sometimes, it happened to me, the project is not correctly included in the APK. A cleaning of your workspace usually remedies the problem and so could a restart of your IDE depending on what you are using. To manually conduct a clean in Eclipse for example, use Project->Clean... or try Android Tools->Fix Project Properties by right-clicking on your project.
As you seem to also have fixed the problem by restarting your device, it could be that the libraries were linked incorrectly. A problem that I have never seen myself but as a very common quote says: "Have you tried turning it off and on again?".
For Android Studio:
Build --> Clean Project
Fixed issue.
Have you tried to make a new subclass of MyGameApplicationClass in your 'main' project and set it in the manifest as Application class?
I had a slew of bugs with Android Studio 3.0 Canary 4 and the way I fixed them was by editing the AndroidManifest.xml by adding in some jibberish to the application name. Then, I clicked build. Obviously, a whole mess of new error messages appeared. I changed the name back to what it should be, built the app, and it just ran.
Sometimes, I just don't know...
EDIT: Just ran into this issue on Android Studio 3.0 Canary 4 on my laptop when switching over. I again went through the same process of changing AndroidManifest.xml file to contain a typo, building, and changing back. That didn't work.
I then noticed that instant run was still enabled. Going into settings (by clicking command + , (comma key)) and typing "instant run", I was able to disable instant run, built the app, and the error of class not found went away.
Summary of Steps to Fix [FOR ME]
Invalidate cache / restart
Clean the project
Manually delete the build folder (need to be in project view for this one)
Make an intentionally errant edit to your AndroidManifest.xml file, build the app, observe the errors, remove the errant edit and build again
Disable instant run
Again, I don't mean to insinuate that this will fix everyone's error, but I have now used some combination of these steps on two different machines (MacOS Sierra) and it has been resolved for me. Hope it helps.
In my case, application id and package were mismatched. This should be same as presented in following images...
AndroidManifest.xml
app/build.gradle
In this case you can see, applicationId and package both are same that is com.mycompany.mygamelibrary
May be its a Build Path Configuration problem.I did the following to solve the issue.
1.Right click on your project and go to Java Build Path.
2.Click on Order and Export tab.
3.Check Android Private Libraries and other 3rd part libraries if you have added.
4.Press ok and clean the project.
I hope it will solve the issue.
Once I had the same error message, but maybe the cause isn't the same.
I did a code and worked for a while, then I wanted to improve it and got the same error and I couldn't run it.
I could fix the problem with
the correct Build Path order (as I can see you've already did this)
I check on the Order and Export tab the android-suppor-v4.jar
and the key was the Android SDK Managert->Upgrade everything and (next) Eclipse->Help->Check for updates.
After I upgraded to the latest android plugin and SDK my app compiled and ran again.
I hope this will help you!
I'm not very sure about this but it might be that your system's debug.keystore license validity has expired as it is valid for only 365 days. You just need to delete the debug.keystore from your computer. The debug.keystore will be generated automatically by Eclipse when you compile your Android App.
Same message seen ... this time it turned out to be different output folders for MyApp/gen and MyApp/src in the Build Path (caused by Maven integration).
Unchecking "Allow output folders for source folders" solved the problem.
I had this issue in an Android application that needed an Application class which was created in wrong path inside the Android Studio project. When I moved the class file to the correct package, it was fixed.
This all Process work for me to solve application class Exception.
Step 1: Open Run(window+R) Search -> Prefetch Remove all file (Some file not Delete)
Step 2: Open Run(window+R) Search -> %temp% Remove all file (Some File not Delete)
Step 3: Open Android Studio -> Build -> Clean Project
OR
Select File > Invalidate Caches / Restart > Invalidate and Restart from Android Studio toolbar.
OR
Close and reopen Android project.
OR
Restart System
I ran into this issue several times and both times it seemed to be caused by some instant run feature.
In my case, deleting the application from the device and then installing it from Android Studio again resolved the issue.
I ran into this problem today. The project runs well for over a year but today it reports this issue, and cannot debug on my testing device.
I fixed it by updating to latest gradle version. Hope this can solve your problem.
I took a fully working application and copied it and made it a library (Properties -> Android, Is Library). I also renamed this project to keep track of it separately - com.mylib.
I then took the original application com.myapp and removed all the .java files except for one with some data (no actual code). I linked this up via Properties -> Android, and in the Library section added in the mylib library. It shows up with a green check.
Changed the myapp's manifest activities to all have the library as the prefix as recommended by Google.
android:name="com.mylib.AppInfo"
Cleaned both the library and the project, and exited and restarted Eclipse as well. Compiles fine, and the program runs the main activity "AppInfo", but attempting to get to other activities always fails with ClassNotFoundException.
I've also tried different name prefixes in the myapp manifest such as:
android:name="com.myapp.AppInfo"
android:name=".AppInfo"
But these fail to get to the main app. Although no activity class names were changed in the library or the myapp manifest, I've reviewed them character by character to be sure they all match up both in case and exact letter.
Using Eclipse under Windows 7 x64, and the app is set for minSdk of 11. Latest SDK tools also loaded (v20.0.3). Also Proguard is not being used (yet), and I'm using actual hardware (Android 4.0).
I'm pulling my hair out trying to get the library to work. I have a completely different library and app pair working the same way on another project, and I've compared every property and option between the two libraries and projects and can't find anything that is missing or added that causes this to fail.
Here's the full error from LogCat:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.myapp/com.myapp.LiveWallpaperSettings}: java.lang.ClassNotFoundException: com.myapp.LiveWallpaperSettings
Any suggestions or ideas on how to track this down?
I've recently refactored my src directory in my IntelliJ Android project now, when I run my App on the device, I'm getting this weird error.
I've marked the confusing part. Why is there a second package? How do I remove it again. Also, when I then run the app manually, i runs fine...
It has always been there. I mean, if you see a second package name it is not an error. You could have an application whose package id is the.package but the main activity could be in another package (e.g. com.something.else.MainActivity). In that case you will see something like:
Launching application: the.package/com.something.else.MainActivity.
What I would take a look at is the Run/Debug configurations which sometimes get corrupted after changing the project structure.
I am working on an Android application (I will call this ProjectA) that is attempting to login to a server through a web service call. This web service call is in another package within my workspace (I will call this ProjectB). I include the jar of ProjectB in ProjectA, and run it. I get this error:
Caused by: java.lang.NoClassDefFoundError: org.apache.commons.configuration.PropertiesConfiguration
Then, I tried adding several uses-library tags in my manifest. I add this:
< uses-library android:name="org.apache.commons.configuration.PropertiesConfiguration" />
I get the following error:
Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
Please check logcat output for more details.
I tried Googling this error, but the only thing that ever seems to come up in the searches with this second error is about the Google API's (mostly referring to the Map). If someone could help out, that would be great. Please let me know if you need more information.
Your app, or some code that it uses, uses the Apache Commons Configuration components. You will need to obtain the .jar file for this code (which may have been supplied with whatever library you're using that needs it) and add it to your libs/ directory to have it built in to your app.