Search code examples
androidfacebookredexfacebook-redex

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


There is a very good instruction in Redex page at http://fbredex.com/.

I follow the instruction but I have problem in two steps.

1.I have no problem with run of first command (my OS is 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. I clone folly repo somewhere on my laptop

  2. I go to the directory by $ cd android/projects/folly/folly/

  3. I run git submodule update --init but nothing happens. I even run this command in $ cd android/projects/folly/ but nothing happens either.

  4. I run autoreconf -ivf && ./configure && make && make install. Seems works as I see process takes around a minute or two and there are a lot og messages print out.

  5. I copy/paste a sample .apk file to my Desktop and run redex ~/Desktop/my_android_app.apk -o ~/Desktop/my_android_app-redexed.apk. However, I'm getting this message on terminal.

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

I ran above command when I am in /home/hesam/android/projects/folly/folly or /home/hesam/android/projects/folly/. But I get same output.

Update

I cloned Redex repo and followed Bert's Instruction. It works and I could see something is happening by running git submodule update --init. So thanks to Bert. However, I got error at the end of autoreconf -ivf && ./configure && make && make install command.

Please have a look at following output:

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) $ 

Solution

  • there is a difference regard instructions you see in fbredex and what you see in Github redex page. Please follow what Github page says for make and install.

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

    Regard my above problem, A developer from Redex team called me and after few minutes he found and solved the problem. He has updated FAQ section on Redex page that you can see at here. Since there is no explanation there I copy/paste what he said on chat.

    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

    Update

    I forgot to mention that you must have ANDROID_SDK in your PATH. I have following paths in my .profile. Don't forget to source it after making change in it. ~/android/sdk is path to my Android SDK directory.

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