Android break up zipping of large files - android

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?

Related

"the file name must end with .xml" error for jpg file in Android Studio

I am getting this error while building my app. The drawable folder has the valid .jpg file and this is causing the error. How to bypass this? Also, I noticed that the path shown in the error is "main\res\routine\Routine.jpg", but there is no such folder in the project.
AGPBI: {"kind":"error","text":"The file name must end with .xml",
"sources":[{"file":"C:\\Users\\Lenovo\\AndroidStudioProjects\\project3\\app\\src\\main\\res\\routine\\Routine.JPG"}],
"tool":"Resource and asset merger"}```
UPDATE: solved the problem by reuploading the pic and saving it in drawable_V21. still dont know about that error message though. might be a bug
I guess that error you're experiencing is because of the file extension being in .JPG instead of .jpg try changing it. It may help somehow

Error: error while writing **** File name too long

I'm trying to assemble an Android build with my laptop with Ubuntu but I'm getting constantly the error on a file generated by dagger:
error: error while writing DaggerMyLibraryBookmarksComponent$com_testx_baseapplication_presentation_common_dagger_component_ApplicationComponent_userManagerRepository.class (File name too long)
This error is quite weird due that in other computers with same code and same SO I'm able to compile the project without any issue.
Has anyone experienced this issue?
The problem here was that I was using an encrypted folder in my /home partition. I just created a new folder outside the encrypted partition and the problem was solved.
This is due encrypted folders only accepts 144bytes class name files.
Same problem here!
My solution was to create a virtual image using "dd", format it in ext4 and mount it in my working folder. Worked like a charm!
Somthing like this:
https://www.tecmint.com/create-virtual-harddisk-volume-in-linux/

ValueError: can't find recovery API version in input target-files

I am trying to create a patch for different AOSP versions upgrading, without changing the APKs located in app or priv-app folders, which means the APPs version should hold still in the original versions.
I’ve checked the OTA Package Tools out on AOSP website:
Right now, I have the AOSP source code in Ubuntu 12.04 and trying to implement the "incremental updates" with command shown as the website.
However, a ValueError message appears after I do that as the following:
unzipping target target-files...
Traceback (most recent call last):
File "./build/tools/releasetools/ota_from_target_files", line 1119, in <module>
main(sys.argv[1:])
File "./build/tools/releasetools/ota_from_target_files", line 1062, in main
OPTIONS.info_dict = common.LoadInfoDict(input_zip)
File "~/openlinux_kk-amlogic/build/tools/releasetools/common.py", line 120, in LoadInfoDict
raise ValueError("can't find recovery API version in input target-files")
ValueError: can't find recovery API version in input target-files
Could anybody do me a favor to provide some methods possibly solve this problem?
The problem I have successfully gotten the answer, I have to make my patch file with the zip file target_files.zip, not the general zip file, then the python is able to create the patch file.
However, I still have a problem that after I finish creating the patch file, and trying to flash it via adb sideload command,
After finish flashing this procedure, the result after I flashing the zip didn’t work, and a message shown as the following:
system/bin/filename” has unexpected contents
That filename stands for the file I tuned it in the patch file, as the figure shown:
If my method is wrong, does anybody know how to apply the patch I created with sideload flashing?
Thank you in advanced.

Hunting a memory leak with Eclipse and Mat, stuck converting the hprof file

This seems to be a question asked many times. I'm using Eclipse to write an Android app, in OS X. So far, no problem, except the app crashes sometimes, and I want to see whats going on so I can fix the problem. (Its probably related to bitmaps or variables not recycling correctly. But I don't know where else to start to look into it.)
I used the DDMS tool (in eclipse) to create a dump file. Then I downloaded the MemoryAnalyzer application to open it. Here is where I have been stuck for an hour: I have to convert the file first because Eclipse writes the hprof file in a different format. How do I convert it?
The answers to this question, error openning HPROF file, directly address my question. The top answer is the same as the reference for the hprof-conv tool.
The hprof file you get from Android has android specific format. You should convert hprof >file take from Android OS into standard hprof format. For this you can use hprof-conv tool >that is located at AndrodiSDK/tools/hprof-conv.
For example:
hprof-conv android.hprof mat.hprof
And then open mat.hprof in Memory Analyzer.
I have a couple problems with this.
when I open the hprof-conv tool, it shows a handful of lines about it then says "[Process completed]". And there is no place to enter any text. The only relevant info on the screen is this:
Usage: hprof-conf infile outfile
I'm in Terminal, so I open "new command..." or tried using the shell thats also open. Then when I run "hprof-conv dump1.hprof dump1a.hprof" I get the error "command not found". So I think I'm off track. I also tried "hprof-conf", instead of "hprof-conv", the way it suggests in point 1. Same error. Also tried various paths to the file, no change.
if I was on the right track, how do I correctly point this command to the file location? I have it on my desktop, and its named dump1.hprof. I'm not very experienced with Terminal.
Thanks in advance for an answer, or perhaps another suggestion on how to hunt down a memory leak.
If you are on mac add a ./ before the command :
./hprof-conv infile.hprof outfile.hprof
Hello and sorry for a late response. I just went through exactly this problem and wrote some instructions here: http://spragucm.wordpress.com/2013/11/21/debugging-android-project-ddms-heap-dump-in-eclipse/
Method 1: Use the Standalone MAT
go into c:...\sdk-tools\tools and copy hprof-conv.exe
go to whatever folder you saved your dump1.hprof file and paste the .exe file
open a terminal and change directory to the folder with your dump and .exe file (e.g. if folder is c:\Users\YourName\DumpFolder then type cd c:\Users\YourName\DumpFolder)
When you're in the folder type the following in the command prompt and hit enter: hprof-conf infile.hprof outfile.hprof
NOTE: If you get an error about directory not found, you're not in the correct directory in the command prompt
The outfile.hprof file should be in the same folder as the other files.
Method 2: Using MAT in Eclipse
Install the plug-in for MAT in Eclipse
Select to get heap dump as before
Go to Window->Open Perspective->other->Memory Analysis
Look through your tabs for a window with a blue disk icon in top left and expand the tab (this will have some crazy name on it with a very long string of numbers)
Done...you are looking at the heap dump in Eclipse

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