Decompress Rar file in Android - android

I want to learn how to decompress a .rar file in android. Zip files can be easily decompressed using ZipStream. Is there any similar way for rar files.

I just realized this with jUnrar from here
https://github.com/edmund-wagner/junrar
Create a new package within your Android src directory called
com.github.junrar
You should delete com.github.junrar.vfs2 because it has some dependencies and you probably won't use it anyway.
You will probably get some errors about the logger class. You can either remove the few logging lines or like i did write a tiny wrapper which communicates with android.util.Log. I did that and changed the includes.
If you finished importing the code take a look at jUnrars testutils.
I used this and it worked out of the box:
https://github.com/edmund-wagner/junrar/blob/master/testutil/src/main/java/com/github/junrar/testutil/ExtractArchive.java
Hope it helps

RAR isn't very commonly used (except in certain niches), so you won't find support for it built into the Android libraries. Probably the easiest thing to do is to get a Java library that handles RAR files, as covered in this question:
RAR archives with java

Related

How to make a third dependency or jar in Android studio?

As a new android developer, I just know how to import the third dependencies made by other android developers.But now ,I write a simple custom view ,including a class : enter image description here and a declare-styleable:enter image description here,for convenience for the future,I want make it to a dependency or a jar.I don't know how to do it.Thanks for your help!
A .jar is a compiled Java bitcode for the jvm. Google android Java compiles into dex and it packed into a .apk. I would be utterly shocked if you could ever use a jar file. In general android apks files contain everything needed to run the app they don't tend to depend on anything else.
You can setup intents to pass things around throughout the larger environment but in general if you need the code for several projects, just include the source to be recompiled. You might be able to directly include a .dex but it would certainly not be preferred.

How to include a android native extension (.so) into an AIR native extension (.ane)?

I'm currently trying to find a solution to have an AIR native extension including a C - library for Android that is using JNI.
So far, I tried to pack the .so lib into a jar, which then is packaged into the ane.
As I learned here, I have to unpack the .so from the .jar first in order to access it.
The code found there seems to be working for a regular android project, unfortunatly when doing this for a .jar which is then packaged into an .ane, it seems to lose scope, resulting in a
FileNotFoundException: File path/to/my/lib was not found inside JAR
I already double and triple checked all paths and the contents of my jar. It's all there and spelled correctly.
Q1: How do I get access to the .so from actionscript?
Q2: Is there any other way to package/address the .so besides the regular extension-jar into the ane?
Q3: I really don't know much about the inner working of the .ane mechanism. Is it also possible to skip the .jar-wrapping and use the .so directly from actionscript?
As always, many thanks for any input.
It becomes a bad habit of me to answer my own questions, but anyway...
Sometimes the docs can help. Here in the adobe docs I finally found the solution.
Simply copying the .so to the libs/armeabi-v7a folder in my ane package directory includes the lib into the ane, so I can use the .so from inside the java code of my extension.
Sorry for bothering.

Android: Why is the size of apk file smaller than the entire project

I am definitely a noob at understanding this as of now, I noticed usually that the apk file is much smaller than my Android Projects. How is that happening? Is it always like this? I got this doubt while I was compressing an entire project to zip file, it was showing that the disk size is 128MB...(noticed it then the first time) whereas the actual apk is only 22.4 MB. why is this difference?
An APK is an Android application package file. Each Android application is compiled and packaged in a single file that includes all of the application’s code (.dex files), resources, assets, and manifest file. The APK file is basically a .zip file
Your project contains all of your source files and files used only by the IDE. The apk only contains compiled files which are smaller.
Also, images/resources etc are compressed in the apk.
Android projects (in general) contain source code, which gets compiled to class files that end up in the APK.
Compiled files are smaller than the source code - for example they strip all the comments out of the file (you do include comments in your source files don't you!)
In addition to the other answers, you're probably using something called ProGuard which further compresses your project by shortening field names, removing dead (unused) code, merging classes, and dozens of other tricks.
Check out the FAQ for more about ProGuard.
It has to do with how Android compiles your project. It basically dumps the bulk, compresses the resources, and compiles everything into a simple binary. It will happen with almost every type of programming, your final build will usually be smaller than your total project (unless you include outside sources in your build). There is a lot of bulk in code that get's stripped during compilation.

p7zip on Android-Extracting 7z archive on Android

I'm writing an Android application that need to extract 7z archives.Pressed for time,I've searching of third-party libraries or source code which can be used in my project.
At first, i find J7zip from http://sourceforge.net/projects/p7zip/files/J7Zip/
After modifying the two sample classes, it works in my project, that's exciting! but the problem was: 1. It would cause out of memory errors when extracting larger archives 2. It only support archives with Copy or LZMA codec. I'am so sad about this...
Then, i find this:"J7zip on Android - Extracting From an Archive and Listing Contents" in StackOverflow. My requirement is seriously similar to this question.As it mentioned andro7z, it contains C/C++ code from: http://sourceforge.net/projects/p7zip/files/p7zip/; I believe this's a good solution for me.
andro7z not contains "How to use" doc and I'm new about JNI, i have no idea about how to modify the andro7z to suit my project. So, anyone had implemented extracting 7z archive with andro7z? Could You share me the demo code or steps to implement this? thanks!
I have finished this project by myself,the classes under folder "jni/7z" and "src" need implemented by yourself;if you need to support encrypted archive, you should call methods in 7z.dll or modify the source code in C/CPP folder, C/CPP are 7z source code.

Editing framework.jar in android

I'm trying to modify framework.jar. My purpose is to modify the contents of SQLiteDatabase.java inside this jar. I've googled this quite a lot, and found that the way is to edit the .smali file and repackage and pushing the updated jar to the system. But the source of .smali seems to be hard enough to edit (as it's assembly code), so I was wondering if there's any other workaround to avoid this, and edit the Java source instead and then pushing it to the device. I'd really appreciate some help, thanks.
One possible hybrid approach might be to download a version of AOSP as close to what's used on your device as possible, make the changes you want to SQLiteDatabase.java in the AOSP source, and then build a framework.jar from AOSP, disassemble it with baksmali, and then copy over the SQLiteDatabase.smali from the AOSP build to your device-specific framework.jar.
There's one other kink you should be aware of - If your device is pre-odexed/pre-oated, then you'll need to deodex the entire framework and all pre-odexed/pre-oated apps, because modifying framework.jar will invalidate any existing oat/odex file.

Categories

Resources