Unpacking a large apk file, you may receive the following error,
Unexpected top-level ERROR:
java.util.concurrent.executionexception:java.io.filenotfoundexception/./contacts/com/google/common/base/ Optional$1.smali (Too many open files)
At Java.util.concurrent.FutureTask.report (futuretask.java:122)
At Java.util.concurrent.FutureTask.get (futuretask.java:188)
At Org.jf.smali.main.main (main.java:219)
caused By:java.io.filenotfoundexception:/./contacts/com/google/common/base/optional$1.smali (Too many open files)
At Java.io.FileInputStream.open (Native Method)
At Java.io.fileinputstream.<init> (fileinputstream.java:146)
At Java.io.fileinputstream.<init> (fileinputstream.java:101)
At Org.jf.smali.main.assembleSmaliFile (main.java:268)
At org.jf.smali.main.access$000 (main.java:56)
At Org.jf.smali.main$1.call (main.java:210)
At Org.jf.smali.main$1.call (main.java:208)
At Java.util.concurrent.FutureTask.run (futuretask.java:262)
At Java.util.concurrent.ThreadPoolExecutor.runWorker (threadpoolexecutor.java:1145)
At Java.util.concurrent.threadpoolexecutor$worker.run (threadpoolexecutor.java:615)
At Java.lang.Thread.run (thread.java:745)
This is due to a limitation of the number of Linux files.
You can use Ulimit-a to view:
Core file size (blocks,-c) 0
Data seg Size (Kbytes,-D) Unlimited
Scheduling Priority (-e) 20
File size (blocks,-f) Unlimited
Pending signals (-i) 16382
Max locked Memory (Kbytes, L) 64
Max memory Size (Kbytes,-m) unlimited
Open files (-N) 1024
Pipe Size (bytes,-p) 8
POSIX message queues (bytes,-Q) 819200
Real-time priority (-R) 0
Stack size (Kbytes,-s) 8192
CPU time (seconds,-t) unlimited
MAX User Processes (-u) Unlimited
Virtual Memory (Kbytes,-V) Unlimited
File locks (-X) Unlimited
The solution is to increase the maximum number, switch to the root account, execute ulimit-n 4096
Then you can execute Baksmali under root.
If you do not have a Java environment under root, just source the Java environment settings. For example, my environment settings file is:
---------------setup.sh------------------------------
Java_home=/opt/jdk1.7.0_71
Export Java_home
Android_java_home=/opt/jdk1.7.0_71
Export Android_java_home
Path=/opt/jdk1.7.0_71/binpath
Export PATH
Only the source setup.sh is required, because the Ulimit setting is invalid if you leave the root account or re-open the terminal.
Baksmali anti-compilation appears: unexpected top-level error: .... Too Many open files