Forked from AbhiTheModder/dex2c_install_termux.sh
Last active
December 14, 2024 08:17
-
-
Save NamasteIndia/3a715e288c0d30082e2f43cb43770010 to your computer and use it in GitHub Desktop.
Setup Dex2C Termux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Ensure the script is run with root privileges | |
| if [ "$EUID" -ne 0 ]; then | |
| echo "Please run as root" | |
| exit 1 | |
| fi | |
| # Update and upgrade system | |
| apt update && apt upgrade -y | |
| # Install required packages | |
| echo "Installing dependencies..." | |
| apt install -y python3 python3-pip git cmake rustc clang make wget zlib1g-dev libxml2-dev libxslt-dev libjpeg-dev build-essential binutils openssl | |
| # Install Python packages | |
| pip3 install --upgrade wheel pillow cython setuptools | |
| CFLAGS="-Wno-error=incompatible-function-pointer-types -O0" pip3 install --upgrade lxml | |
| # Define colors for script output | |
| green="\033[0;32m" | |
| nocolor="\033[0m" | |
| red="\033[0;31m" | |
| yellow="\033[0;33m" | |
| note="\033[0;36m" | |
| # SDK Tools Installation | |
| echo -e "${green}Starting SDK Tools installation...${nocolor}" | |
| cd $HOME | |
| if [ -d "android-sdk" ]; then | |
| echo -e "${red}SDK tools already installed, skipping...${nocolor}" | |
| else | |
| git clone https://github.com/AndroidIDEOfficial/androidide-tools | |
| cd androidide-tools/scripts | |
| ./idesetup -c | |
| cd $HOME | |
| fi | |
| echo -e "${yellow}ANDROID SDK TOOLS Successfully Installed!${nocolor}" | |
| # NDK Installation | |
| echo -e "${green}Starting NDK installation...${nocolor}" | |
| echo "Now you'll be asked which version of NDK to install." | |
| echo -e "${note}If your system is recent, choose ${red}'9'${nocolor}" | |
| echo -e "${note}If you face issues with '9', choose ${red}'8'${nocolor}" | |
| echo -e "${red}For other options, you're experimenting at your own risk.${nocolor}" | |
| if [ -f "ndk-install.sh" ]; then | |
| chmod +x ndk-install.sh && bash ndk-install.sh | |
| else | |
| wget https://github.com/MrIkso/AndroidIDE-NDK/raw/main/ndk-install.sh -O ndk-install.sh | |
| chmod +x ndk-install.sh && bash ndk-install.sh | |
| fi | |
| if [ -f "ndk-install.sh" ]; then | |
| rm ndk-install.sh | |
| fi | |
| # Detect installed NDK version | |
| ndk_version="" | |
| for version in 17.2.4988734 18.1.5063045 19.2.5345600 20.1.5948944 21.4.7075529 22.1.7171670 23.2.8568313 24.0.8215888 26.1.10909125 27.1.12297006; do | |
| if [ -d "$HOME/android-sdk/ndk/$version" ]; then | |
| ndk_version="$version" | |
| break | |
| fi | |
| done | |
| if [ -z "$ndk_version" ]; then | |
| echo -e "${red}No NDK installed. Exiting.${nocolor}" | |
| exit 1 | |
| fi | |
| echo -e "${yellow}ANDROID NDK Successfully Installed!${nocolor}" | |
| # Setup apktool | |
| echo -e "${green}Setting up apktool...${nocolor}" | |
| if [ -f "/usr/local/bin/apktool.jar" ]; then | |
| echo -e "${yellow}apktool is already installed${nocolor}" | |
| else | |
| wget https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.10.0.jar -O /usr/local/bin/apktool.jar | |
| chmod +r /usr/local/bin/apktool.jar | |
| wget https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool -O /usr/local/bin/apktool | |
| chmod +x /usr/local/bin/apktool | |
| fi | |
| # Clone and setup dex2c | |
| echo -e "${green}Cloning and setting up dex2c...${nocolor}" | |
| cd $HOME | |
| if [ ! -d "dex2c" ]; then | |
| git clone https://github.com/ratsan/dex2c | |
| fi | |
| cd dex2c | |
| if [ -f "tools/apktool.jar" ]; then | |
| rm tools/apktool.jar | |
| fi | |
| cp /usr/local/bin/apktool.jar tools/apktool.jar | |
| pip3 install -r requirements.txt || exit 2 | |
| # Update environment variables | |
| if ! grep -q "ANDROID_HOME" ~/.bashrc; then | |
| echo -e "\n# Android SDK and NDK Paths" >> ~/.bashrc | |
| echo "export ANDROID_HOME=$HOME/android-sdk" >> ~/.bashrc | |
| echo "export PATH=\$PATH:$HOME/android-sdk/cmdline-tools/latest/bin" >> ~/.bashrc | |
| echo "export PATH=\$PATH:$HOME/android-sdk/platform-tools" >> ~/.bashrc | |
| echo "export PATH=\$PATH:$HOME/android-sdk/build-tools/34.0.4" >> ~/.bashrc | |
| echo "export PATH=\$PATH:$HOME/android-sdk/ndk/$ndk_version" >> ~/.bashrc | |
| echo "export ANDROID_NDK_ROOT=$HOME/android-sdk/ndk/$ndk_version" >> ~/.bashrc | |
| fi | |
| # Create dex2c configuration | |
| cat > $HOME/dex2c/dcc.cfg << EOL | |
| { | |
| "apktool": "tools/apktool.jar", | |
| "ndk_dir": "$HOME/android-sdk/ndk/${ndk_version}", | |
| "signature": { | |
| "keystore_path": "keystore/debug.keystore", | |
| "alias": "androiddebugkey", | |
| "keystore_pass": "android", | |
| "store_pass": "android", | |
| "v1_enabled": true, | |
| "v2_enabled": true, | |
| "v3_enabled": true | |
| } | |
| } | |
| EOL | |
| # Notify user of successful installation | |
| echo -e "${green}============================" | |
| echo "Great! dex2c installed successfully!" | |
| echo -e "============================${nocolor}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment