How do you resolve java.lang.ClassNotFoundException - android

This is my Error
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.messaging.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.messaging-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.messaging-1/lib/x86, /system/lib, /vendor/lib]]

Without any code snippets or context around what you were doing when this error occurred, it can be quite difficult to say how to resolve it, however I will do my best to point you in the right direction.
What is java.lang.ClassNotFoundException?
According to this website, the path being specified to load the file does not seem to contain the file that the Java Virtual Machine (JVM) is looking for.
What Can You Do About It?
Change the file path to accurately reflect where the file is found (keeping in mind that different operating systems may arrive at the same destination with minor variations in syntax, e.g. C:\Path\AnotherPath on Windows or usr/path/anotherpath on Linux distributions)
Check to see if the file is actually at the location you specified, assuming the path is correct. Follow the path on your machine to the directory specified and make sure that the file is there.
In the case of the file not being there, either change the path to where the file is actually found or simply move the file to that destination.
If none of the above has worked, perhaps you lost the file or deleted it accidentally, in which case I suggest a rollback on the project or simply starting it up again from scratch if you weren't too far along with it.

Related

Error in Building a Xamarin Project for Android

I have downloaded a sample project from here: https://learn.microsoft.com/it-it/samples/xamarin/xamarin-forms-samples/webservices-azurenotificationhub/
In the building I got the error:
Failed to create JavaTypeInfo for class: Android.Support.V4.View.Accessibility.AccessibilityManagerCompat/IAccessibilityStateChangeListenerImplementor due to MAX_PATH: System.IO.DirectoryNotFoundException:
I use Visual Studio 2019.
Thank you in advance,
Piero Sbressa
So this is definitely related to the MAX_PATH problem on Windows. This is a long dicussion about this here . Hopefully according to microsoft support team they are planing solve this issue and removing MAX_PATH as limit.
I would suggest to move your project to a "shorter" path.
I did not found an alternative. You can follow the discussion, hopefully they fix this issue.
I got the same exception, when I built the mobile application first. Error code was XA4209 and suggested to: The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
After I changed the number of characters in the path, everything worked fine.
you can do a number of things ,
best to move the directory closer to root say your drive name is C the closer to "c:" the shorter the path the less likely this error will appear.
you could change the output path to be in a folder with shorter path , u find that in android project properties > build > output path
you can also change one of the parent folders name to be shorter , in my case i had a path 261 character long, i litteraly deleted one letter in a parent folder and fixed the issue.

System can't find specifed path ndkbuild in android

I want to build an ocr app in android.For that i am using tessaract library.I am following this turorial ocr tutoial it says follow below steps
Download the NDK & extract to C:\ drive-Done
Set NDK Path & Android SDK path to PATH variable in Enviorment Variable.-Done
Download tessaract library and extract it to C:-Done
open command line & go inside tessract folder ibn downloaded library.-
Write ndk-build-Not Done
When i write ndk-build it says the system can't find the specified path.
Please tell me how to resolve this issue.I have already spent lot of hard time on this.
Thanks in advance.
If you re-read the link you posted, you may notice this line from the author:
Attention: if you fail at any of the above steps, you are not ready for this shit yet. Better grab an introduction to android development course, read a book, then come back to this tutorial. You’ll just waste time and nerves and you’ll bitch about it in the comments that this crash, this doesn’t work. (PS. no, I will not send you the source code on your email, stop spamming k thx.)
You should seriously consider his advice - working with the Android NDK only gets more difficult from here.
You're probably getting that error message because cmd couldn't find the ndk-build program, which is located inside the root of android-ndk-r10e. Possible causes:
You made an error when editing your PATH variable - make sure each file path is separated by a semicolon and that you provided the full path to your NDK install.
Your PATH is too long - the max length is 260 characters. See this page for more info. tl;dr: prefix \?\ to your PATH to get around this length limit.
You had cmd open when you set the variables - try restarting the cmd
program or even restarting your machine.

missing a command building android kernel

I have been trying to build an android kernel for a certain device, the Huawei Vitria, they finally uploaded their kernel source about 2 months ago so I try to build it the normal way which fails so I fix the main errors I see and get the kernel to build finally but, then I notice one error while building. I look into this file and see that they are using a weird way of building I think instead of the normal defconfigs, using a generic defconfig then a configuration file to configure their devices ontop of that(they've done this before but not to this extent), which leads me to think I'm missing a command to select the device config ontop of the defconfig to set up the drivers, but don't know what command was used.
So might there be a way to find out the command by looking at these two files
https://raw.githubusercontent.com/KainXS/android_kernel_huawei_y301a2/jellybean/drivers/huawei/hsad/parse_product.pl
https://raw.githubusercontent.com/KainXS/android_kernel_huawei_y301a2/jellybean/drivers/huawei/hsad/parse_product_id.pl
thanks
I'm not sure how much help this is, but the first command seems to want to be called with a parameter of a path to an XML file.
./parse_product.pl /ab/cd/hw_xxy_configs.xml
PRODUCT: xxy
reads: '/ab/cd/hw_xxy_configs.xml'
It pulls out some data from that file and pastes it into a .c file which presumably goes into the build configuration.
So, you're looking for an XML file containing your product-name.
The second file calls the first repeatedly to generate a set of .c files. Now - this second script takes an XML file as an argument, but I'm afraid I can't tell what it might be called. The file looks like it should contain product names and board-ids if that is any help.

Android break up zipping of large files

I am using the following code snippet to zip a directory:
http://www.jondev.net/articles/Zipping_Files_with_Android_(Programmatically)
I noticed that if the directory is big like >3MB. The created zip file is corrupted and I could not open it. It throws "Archive is in unknown format or corrupted." error in Windows.
Any idea how I can prevent this? For example if too big, then just zip till the threshold is reached. Or is there any other method?

File->New->Android Project->Create Project From Existing Code AndroidManifest.xml (The system cannot find the file specified)

I am trying to look at Android examples from Apress and Wiley's books.
Errors occur when looking at code from both companies.
ie. Apress Beginning Android http://www.apress.com/downloadable/download/sample/sample_id/584/
Extracted Chapter7 to Z:\new\Chapter7
FYI Android SDK location Z:\eclipse\Android\android-sdk
File->New->Android Project->Create Project From Existing Code
Selected Z:\new\Chapter7
Build Target Android 2.2
AM able to get HelloWorld and applications typed in to work with current Eclipse setup to run on hardware and simulators, but when attempting to look at others sorce code am getting errors.
When opening source code from either companies books I get similar errors
[2011-07-27 02:26:41 - com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Unable to read Z:\eclipse\Android\android-sdk\samples\android-8\AndroidManifest.xml: java.io.FileNotFoundException: Z:\eclipse\Android\android-sdk\samples\android-8\AndroidManifest.xml (The system cannot find the file specified)
[2011-07-27 02:26:41 - com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Unable to read Z:\eclipse\Android\android-sdk\samples\android-8\AndroidManifest.xml: java.io.FileNotFoundException: Z:\eclipse\Android\android-sdk\samples\android-8\AndroidManifest.xml (The system cannot find the file specified)
[2011-07-27 02:26:45 - com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Unable to read Z:\new\AndroidManifest.xml: java.io.FileNotFoundException: Z:\new\AndroidManifest.xml (The system cannot find the file specified)
[2011-07-27 02:30:41 - com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Unable to read Z:\new\AndroidManifest.xml: java.io.FileNotFoundException: Z:\new\AndroidManifest.xml (The system cannot find the file specified)
Eclipse is trying to create projects from folders Z:\new\ and Z:\eclipse\Android\android\samples\android-8, which I can assure you is wrong. Is there another project you are making in which you are creating from those two paths? I know for a fact that Z:\eclipse\Android\android\samples\android-8 has multiple projects inside and you need to specify the exact project.
For instance, inside android-8, I see that there is ApiDemos and BackupRestore, you need to select those in order for Eclipse to find the AndroidManifest.xml files.
As for the other link (Z:\new\), make sure you have selected Z:\new\Chapter7, it looks like you didn't do that. it's looking in the \new\ folder for the AndroidManifest.xml when it should be looking in \new\Chapter7.

Categories

Resources