当前位置: 代码迷 >> Ruby/Rails >> baksmali反编译出现:UNEXPECTED TOP-LEVEL ERROR:Too many open files
  详细解决方案

baksmali反编译出现:UNEXPECTED TOP-LEVEL ERROR:Too many open files

热度:231   发布时间:2016-04-29 02:11:52.0
baksmali反编译出现:UNEXPECTED TOP-LEVEL ERROR:....Too many open files

解包大型apk文件,可能会出现如下错误,

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)


这是由于Linux文件数限制导致的错误.

可以使用Ulimit -a查看:
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            (512 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
解决的方法就是提高这个上限数,切换到root账户,执行ulimit -n 4096
然后就在root下面执行baksmali就可以.
如果在root下没有java环境,只要source一下java环境设置就可以了.例如我的环境设置文件为:
---------------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
只需要source setup.sh就可以了,这是因为只要离开root账户,或者重开terminal, ulimit的设置就无效了.

  相关解决方案