Project messed up, cloned from repo now ClassNotFoundExceptions - android

My project got messed up so I started over by just cloning from my repo. After getting all dependencies in order, I tried running my app and it crashes from:
java.lang.RuntimeException: Unable to instantiate activity
java.lang.ClassNotFoundException: org.me.app.activities.Main in loader dalvik.system.PathClassLoader[/data/app/org.me-1.apk]
The class is there, its in the Manifest, everything is good. What can I do?! I feel like my app is burning in flames now!!

It looks like there are several possibilities that could have caused this.
Use of the android name attribute in the manifest, incorrect activity naming convention, .project file corruption, accidentally unchecking "Project -> Build Automatically": here
Incorrect (or inconsistent) package naming: here
Incorrect class loader context: here
Also you might find ideas on the Google Group thread.
Each of these has additional ideas and debugging attempts through the thread responses and comments.
If none of these work for you let us know and maybe we can find a new cause.

Related

error: cannot find symbol class DataBindingComponet after merge two branches

I got the very weird problem, I have two branches and working fine separately. after the merge, All conflicts are resolved carefully many times. But every time we run the project this 3 error will come and No stack trace. T
error: cannot find symbol class DataBindingComponent
error: cannot find symbol class DaggerLoginComponent
Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException:
Compilation failed; see the compiler error output for details.
There is something wrong that stop annotation processor to stop compilation but we didn't find any reason However we checked all the files manually but Not know How we can debug the issue and Identify the root cause of the issue. Anyone who know how we can track why annotation processor is not generating the class.
We have tried listed methods.
Clean -> Rebuild -> Invalidate Restart -> Delete all temporary files.
run build with this command ./gradlew clean assemble --stacktrace --debug
checked every resource and java files manually to find the issue.
We have used below library
lombok 1.16.20, databinding , dagger 2.16 that are using annotation processor
We have conflict in dimen, string and style files. that are resolve very carefully.
If need any more info I would provide.
Updated: Finally get a solution There was a private static import in
other class that causes this problem
Make Sure You don't have any java compiler issue, Even small syntax issue will not compile your binding and I don't know why the error is not printing in logcat. Hope It will resolve in the updated android studio.
Adding up to comments, both times this happened to me, it was related to dagger.
unresolved import in a dagger module class. Spent 4 hours to find this
#Inject annotation on a class that was made abstract. Spent 2 days to find this
The workflow into knowing W*F is wrong, is:
in a small project, inspecting all your classes and layouts might be a viable choice
if you can, go back in commits to reach the last working point, and see from there. This is almost useless advice, because this nasty thing typically happens when you are in the middle of some kind of refactoring
create a destructive branch & do whatever is possible to use the old databinding compiler, android.databinding.enableV2=false. Doing this might require you to remove modules, remove new features that you were using (e.g. experimental databinding in non-feature modules), probably downgrade AGP. But it's worth it, because the old databinding compiler will actually tell you the error instead of this cannot find symbol mess.
Good luck with this exhausting process, and if you can, please file a bug report to databinding guys.
This is most weird problem that i faced before this month. First of all Data Binding is not as mature that it show you all errors with reach point in Error Logs.
However there are some issues that are not caught by lint and lead to errors in all classes related to binding.
Causes:
When there is a field defined in layout component binding that is not available in your model class.
When you have some invalid import in your data binding layout.
Solution
Check your layouts first for invalid imports. Because that will not show in error log.
If you don't find anything, then check your all layouts carefully for the missing model fields, If there is some field not present in model class, and used in layout then you will not get appropriate error.
If this does not help then check your Binding Component names are correct. Because if your partner renamed a layout then you should change its relevant LayoutBinding name in Activity or Fragment.
These solution helped me always to overcome this issue.
Renaming the xml files to another name and check if binding works once it works rename it back to the one that was used.
Hope this may help you

Unable to execute dex: Multiple dex files define

How can I solve this? I had tried many things in here, and nothing seems to work for me.
I had tried importing and cleaning, buildings and restarting eclipse, and nothing seems to work.
"You have problems with your imports probably your project are using the same two libraries (older and new) and do not know with one should be used.
Check your Libs files, lib-project and references"
I finally found the solution.
This error happens when I added a library that is the same I am using in my project, so, I need to exclude the library from my main project and let just the one that comes with the library I imported to my main project.
So,
1. Go to bould path -> Order and Export
2. Uncheck the jar that is the same that the imported library uses. Click ok.
Now, you are ready to continue developing!
I had bad experiences with this annoying issue, it's seldom how both of you explain, older and new but in essence, problem is beyond an older/newer version of a library.jar, this problem may also appear i.e. with a class with the same class name classA and the same package name com.same.package of libraries.jar of different vendors.
In this case, we have no more choice than rename a package name or a class name. Another risky choice is to purge a class if we know, we won't use anymore.

pubnub test application crashes: NoClassDefFound

this is a copy of my question on Pubnub support page:
Hi all, I tried running the PubnubTestApp that is downloadable with the Pubnub API from your git repo.
but when I try and start the test app i firstly get a build path error because apparently you (pubnub guys) have configured the project to look for 2 jar files that don't exist. (bcprov-jdk16-145.jar and commons-codec-1.2.jar).
after I removed those 2 references the project showed no error. but when I tried running it, it crashed again with this error:
"07-04 12:29:11.782: E/AndroidRuntime(754): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.fbt/com.fbt.PubNubTestActivity}: java.lang.ClassNotFoundException: com.fbt.PubNubTestActivity in loader dalvik.system.PathClassLoader[/data/app/com.fbt-1.apk"
after looking over the internet for the reasons for this crash, I noticed that in the manifest.xml file in the project there is a mistake in the name of the activity name. (it's named ".PubNubTestActivity" instead of ".PubnubTestActivity").
after changing the manifest, everything works and the app will install and run but there a a few problems still.
when pressing the "publish" button or the "history" button the app crashes and dies automatically. also it crashed without any clicking of anything (just like that).
here are the crash reports I got from the emulator.
http://pastie.org/private/pojnpnxmznvn9azdg7uyg
apparently the project doesn't recognize the "pubnub.crypto" jar file even though I (and you) added it to the build path and made sure it's in the project.
please let me know how to fix this so I can use (at last) pubnub in my app.
Have you tried the latest build? This should be fixed now.

Unable to reference a Library project - Android

Well, I wanted to create a Library project from my existing sources so that it would help me re-use code for the paid app that I have in mind. When I saw the developer guide on how this was to be done, I thought it was very simple.
Just mark the project as a Library project and it should be converted to one.
But when I tried referencing one of the base classes in an application, the app force closes with the following exceptions
02-04 21:50:06.765: E/AndroidRuntime(699): java.lang.NoClassDefFoundError: in.my.package.name.R$layout
Let me give you some more info. I have referenced the Library project in the application and have also included the manifest entries with fully qualified activity names. I have a BaseActivity which has all the menu and re-usable code bits. The point where the above exception occurs is where I am trying to reference the layout file in this BaseActivity inside the library project.
setContentView(R.layout.apphome);
What is it that I am missing or doing wrongly?
PS: I am just noticing that When I right click on my application and go to the android tab, there is a red cross instead of a green tick in the place where the library project is referenced. But there are no visible errors on the console or in the code of the project.
Seems its a known issue.
Issue link here
Hope Google guys resolve this problem in their next SDK release.
So to be clear, the problem was that my libraries had custom styling capabilities and that was the problem.

NoClassDefFoundError among others...Android

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.

Categories

Resources