FileNotFoundException: path (reason) - where can I find all possible "reason" messages? - android

Starting from Android 2.2, the FileNotFoundException contains additional information about problem:
java.io.FileNotFoundException: /foo/bar (No such file or directory)
The error message format is:
java.io.FileNotFoundException: path (reason)
I have seen such reasons:
Invalid argument
No space left on device
No such file or directory
Permission denied
Read-only file system
Q: Where can I find all possible reason messages? Documentation, or the source file where they are thrown from.

Exceptions like this are sort of generic, used by other classes, and will generally not contain the "reasons" that you mentioned. Any class could use a java.io.FileNotFoundException exception, so in order to find all of the possible "reasons" you would need to search the Android source code for something like throws FileNotFoundException or new FileNotFoundException.

Related

How do you resolve java.lang.ClassNotFoundException

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.

Android path in the Fileprovider is not recognised

I get this following exception for xlsx, msg and xml
Caused by java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/myadress/aFile.xlsx
at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:744)
I saw several issues related but cannot find where is the error
I am reading the official documentation but do not get where can be the bug because do not understand where is going wrong
Failed to find configured root that contains /data/data/myadress/aFile.xlsx
You should serve from the files directory:
/data/data/<packagename>/files/aFile.xlsx

How to solve java.io.IOException: No such file or directory or Permission denied issue on executing sh file from android in windows machine

I need to execute an sh file using commandline option from the android program. I tried using Runtime.getRuntime().exec. I tried to pass the command as string as well as string[]. But still the issue exists. I have already given permission for read and write in external storage in manifest file.
I tried by using the paths such as
getContext().getFilesDir() +
"/data/user/0//files/..."
Environment.getExternalStorageDirectory() +
path in our system such as C:\Users\...
I tried using cp, rm, ls....and the commands that I needed actually..
For all the above trials, IO Exception occurred. (Either Permission denied or No such file or directory)
Could you know a possible solution to get out of this error and execute the sh file using command line in android program.
Thank you in advance

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?

Format the file name parsed via errorformat in vim

I am trying to write an errorformat to detect errors when compiling android applications using the new gradle build system (http://tools.android.com/tech-docs/new-build-system).
errorformat=%f:%l:\ error:\ %m
This errorformat catches the XML errors but in gradle the filename that comes in the output is not the original source filename, instead it is a temporary build file:
/home/user/Studio/myapp/build/res/all/debug/layout/add_child_dialog.xml:7: error: Error parsing XML: unbound prefix
The original source file is:
/home/user/Studio/myapp/res/layout/add_child_dialog.xml:7: error: Error parsing XML: unbound prefix
As you can see the error shows a file inside the build folder and it contains the build type (debug) in it.
I read the quickfix-window help and found ways to modify the quickfix output using the QuickfixCmdPost and quickfix BufReadPost auto-commands but these take effect after the quickfix window is parsed by the errorformat. As result I can see the correct source file on the quickfix window but vim still jumps to the wrong file.
Is there a way to modify the file (%f) after it is parsed by errorformat?
Is there a way to tell gradle to print the original source file and not the build one?
You could either transform the quickfix list on QuickFixCmdPost (using getqflist() and setqflist(), with the correct file in the filename attribute), or append a script to 'makeprg' that transforms the output (e.g. using sed).
But I agree with you that the tool output is wrong and should be fixed (to state the original files, not temporary copies), instead of working around this in Vim.

Categories

Resources