如何设置 Facebook Redex 以优化 Android 字节码?

How to setup Facebook Redex in order to optimize Android Bytecodes?

http://fbredex.com/ 的 Redex 页面中有一个很好的说明。

我按照说明操作,但我在两步中遇到问题。

1.I 对第一个命令的 运行 没问题(我的 OS 是 Ubuntu)

sudo apt-get install \
    g++ \
    automake \
    autoconf \
    autoconf-archive \
    libtool \
    libboost-all-dev \
    libevent-dev \
    libdouble-conversion-dev \
    libgoogle-glog-dev \
    libgflags-dev \
    liblz4-dev \
    liblzma-dev \
    libsnappy-dev \
    make \
    zlib1g-dev \
    binutils-dev \
    libjemalloc-dev \
    libssl-dev \
    libiberty-dev
  1. 我在笔记本电脑的某个地方克隆了 folly 存储库

  2. 我通过$ cd android/projects/folly/folly/

  3. 进入目录
  4. 我 运行 git submodule update --init 但是没有任何反应。我什至在 $ cd android/projects/folly/ 中 运行 这个命令,但也没有任何反应。

  5. 我运行autoreconf -ivf && ./configure && make && make install。似乎有效,因为我看到这个过程大约需要一两分钟,并且打印出很多 og 消息。

  6. 我 copy/paste 一个示例 .apk 文件到我的桌面和 运行 redex ~/Desktop/my_android_app.apk -o ~/Desktop/my_android_app-redexed.apk。但是,我在终端上收到此消息。

    No command 'redex' found, did you mean: Command 'redet' from package 'redet' (universe) redex: command not found

我在 /home/hesam/android/projects/folly/folly/home/hesam/android/projects/folly/ 时执行上述命令 运行。但是我得到了相同的输出。

更新

我克隆了 Redex 存储库并遵循了 Bert 的说明。它有效,我可以看到 运行ning git submodule update --init 正在发生一些事情。所以感谢伯特。但是,我在 autoreconf -ivf && ./configure && make && make install 命令结束时出错。

请查看以下输出:

Making all in unit
make[3]: Entering directory `/home/hesam/android/projects/redex/test/unit'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/home/hesam/android/projects/redex/test/unit'
make[2]: Leaving directory `/home/hesam/android/projects/redex/test'
make[1]: Leaving directory `/home/hesam/android/projects/redex'
Making install in third-party/folly/folly
make[1]: Entering directory `/home/hesam/android/projects/redex/third-party/folly/folly'
Making install in .
make[2]: Entering directory `/home/hesam/android/projects/redex/third-party/folly/folly'
make[3]: Entering directory `/home/hesam/android/projects/redex/third-party/folly/folly'
 /bin/mkdir -p '/usr/local/lib'
 /bin/bash ./libtool   --mode=install /usr/bin/install -c   libfolly.la libfollybenchmark.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libfolly.so.57.0.0 /usr/local/lib/libfolly.so.57.0.0
/usr/bin/install: cannot create regular file '/usr/local/lib/libfolly.so.57.0.0': Permission denied
make[3]: *** [install-libLTLIBRARIES] Error 1
make[3]: Leaving directory `/home/hesam/android/projects/redex/third-party/folly/folly'
make[2]: *** [install-am] Error 2
make[2]: Leaving directory `/home/hesam/android/projects/redex/third-party/folly/folly'
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory `/home/hesam/android/projects/redex/third-party/folly/folly'
make: *** [install-recursive] Error 1
hesam: redex (master) $ redex ~/Desktop/my_android_app.apk -o ~/Desktop/my_android_app-redexed.apk 
No command 'redex' found, did you mean:
 Command 'redet' from package 'redet' (universe)
redex: command not found
hesam: redex (master) $ 

你不需要单独克隆folly;它作为 redex 的子模块包含在内。做就是了: git clone https://github.com/facebook/redex.git cd redex git submodule update --init 然后根据说明configure/make。

您在 fbredex and what you see in Github redex 页面中看到的说明有所不同。请按照 Github 页面对 makeinstall 的说明进行操作。

autoreconf -ivf && ./configure && make
sudo make install

关于我的上述问题,Redex 团队的一位开发人员打电话给我,几分钟后他找到并解决了问题。他更新了 Redex 页面上的常见问题解答部分,您可以看到 at here。由于那里没有解释,我 copy/paste 他在聊天中说的。

So, as an optimization, the runtime linker doesn't actually go trawling through everything to look for libs anymore It uses the cache file, which is generated by ldconfig

更新

我忘了说你的 PATH 中必须有 ANDROID_SDK。我的 .profile 中有以下路径。修改后不要忘记 source 它。 ~/android/sdk 是我的 Android SDK 目录的路径。

export ANDROID_HOME=~/android/sdk
export ANDROID_SDK=${ANDROID_HOME}
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools