Install Android Studio
Overview
AI Use Case
ai-edge-gallery.apk: Mobile (Android) GenAI Chat app which uses Hugging Face Integration to discover and download various on-device (local) LLM (LiteRT .tflite / .litert .task models). The app apk, built using Google AI-Edge Portal, is installed to demonstrate automation of test runs and presentation of results (TTFT, decode speed, latency) to benchmark performance among LiteRT-optimized models. App activities tested include:
- Ask Image: Obtain an image of a homework problem and ask questions about it: descriptions, solve problems, or identify objects.
- Prompt Lab: Upload a pdf and ask questions: summarize, rewrite, generate code, or use freeform prompts
- AI Chat
- CAUTION: Do a full Backup before proceeding with system-level configurations below.
Prerequisite System Dependencies
- Install XCode Command Line Tools:
xcode-select --install
- Use Homebrew to install tools used for Android dev :
brew install ant brew install maven brew install gradle brew doctor
Install Java
- Install Temurin (an anagram of “runtime”), an open-source, high-performance Java runtime based on OpenJDK, produced by the Eclipse Foundation’s Adoptium Working Group. Install the latest:
brew install --cask temurin
Alternately, install a specific version such as 21:
brew install --cask temurin@21
- Verify: https://jdk.java.net/24/
java -version
openjdk version "23.0.1" 2024-10-15 OpenJDK Runtime Environment Zulu23.30+13-CA (build 23.0.1+11) OpenJDK 64-Bit Server VM Zulu23.30+13-CA (build 23.0.1+11, mixed mode, sharing)
- Confirm:
which java
/usr/bin/java
- VIDEO: What is Temurin?
- jadx - decompiles APK to Java source code
- apktool - decodes resources and rebuilds APKs
Install Android Platform Tools
- To avoid the need to hard-code path, instead of manual https://developer.android.com/studio/install
Alternately, track down the specific version to download, such as:
android-studio-2024.3.2.15-mac_arm.dmgbrew install cask android-platform-tools
- Confirm:
which adb
/opt/homebrew/bin/adb
The above avoids the need to define PATH in .bash_profile or .zshrc, such as:
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.zshrc echo 'export PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"' >> ~/.zshrc
This also avoid need to create a symbolic link (essentially a shortcut) for the adb executable in folder /usr/local/bin which is one of the default locations where Terminal looks for command line tools:
sudo ln -s ~/Library/Android/sdk/platform-tools/adb /usr/local/bin
Install Android Command Line Tools
- Run per https://developer.android.com/tools description of the Adroid Debug Bridge (adb) https://android-sdk-platform-tools-adb.en.softonic.com/mac?ex=RAMP-3252.3#google_vignette
adb version
Android Debug Bridge version 1.0.41 Version 36.0.0-13206524 Installed as /opt/homebrew/bin/adb Running on Darwin 24.5.0 (arm64)
- Install Android CLI:
brew install --cask android-commandlinetools
- Verify:
which sdkmanager
/opt/homebrew/bin/sdkmanager
- Confirm
sdkmanager --version
19.0
- Refresh your shell profile (or restart your terminal app):
source ~/.zshrc or source ~/.bash_profile
.Android folder
REMEMBER: $HOME/.android is the default folder Android uses to store configuration metadata.
- See what’s in the folder:
ls -al $HOME/.android
total 56 drwxr-x---@ 10 johndoe staff 320 Jun 19 01:05 . drwxr-x---+ 104 johndoe staff 3328 Jun 19 01:05 .. -rw-------@ 1 johndoe staff 1704 Jun 9 2024 adbkey -rw-r--r--@ 1 johndoe staff 728 Jun 9 2024 adbkey.pub -rw-r--r--@ 1 johndoe staff 219 Jun 19 00:57 analytics.settings drwxr-xr-x@ 4 johndoe staff 128 Jun 19 00:43 avd drwxr-xr-x 44 johndoe staff 1408 Jun 19 00:07 cache -rw-r--r--@ 1 johndoe staff 4675 Jun 19 01:05 emu-last-feature-flags.protobuf -rw-r--r--@ 1 johndoe staff 67 Jun 19 01:05 emu-update-last-check.ini -rwxr-xr-x@ 1 johndoe staff 171 Jun 19 01:05 modem-nv-ram-5554
Install Android SDK
- To avoid “.android/repositories.cfg could not be loaded” error, create a blank file:
touch ~/.android/repositories.cfg
The equivalent of this for Powershell on Windows 10:
New-Item C:\Users\$username\.android\repositories.cfg -type file
- Use Homebrew to install the Android Software Development Kit (sdk):
brew install --cask android-sdk
This takes several minutes. Just wait while “Installing Cask android-sdk”.
Native Development Kit
- AVOID: Use Homebrew to install the Android Native Development Kit (ndk):
brew install --cask android-ndk
-
Install HAXM for blazing fast emulators. Check out the “Configuring VM Acceleration on Mac” section at:
http://developer.android.com/tools/devices/emulator.html
Edit Terminal start-up CLI
- Edit your
~/.bash_profile
to update environment variables:export ANDROID_SDK_ROOT="/usr/local/share/android-sdk" export ANT_HOME=/usr/local/opt/ant export MAVEN_HOME=/usr/local/opt/maven export GRADLE_HOME=/usr/local/opt/gradle export ANDROID_HOME=/usr/local/opt/android-sdk export ANDROID_NDK_HOME=/usr/local/opt/android-ndk
- Update your paths (bonus points to a better solution to the hardcoded build tools version):
export PATH=$ANT_HOME/bin:$PATH export PATH=$MAVEN_HOME/bin:$PATH export PATH=$GRADLE_HOME/bin:$PATH export PATH=$ANDROID_HOME/tools:$PATH export PATH=$ANDROID_HOME/platform-tools:$PATH export PATH=$ANDROID_HOME/build-tools/19.1.0:$PATH
Version Updates
- Periodically run these commands again to ensure you’re staying up to date:
brew update android update sdk --no-ui
There might be an issue with brew update and the android-sdk formula.
Android Studio
Alternately, you can install and use Eclipse, IntelliJ, or your other favorite IDE.
Alternately, download the dmg from https://developer.android.com/studio/install.html
Alternately, see http://macappstore.org/android-studio/ for manual download. https://classroom.udacity.com/courses/ud808/lessons/4216368924/concepts/43072785890923# is a video mini-course done April 2015 about that approach.
- https://github.com/caskroom/homebrew-cask/blob/master/Casks/android-studio.rb
But the easiest way is:
- To inspect app structure, resources, and permissions during development or security analysis of APK File, install the APK Analyzer (built into Android Studio)
brew install --cask android-studio
- Notice in the install response:
==> Linking Binary 'studio' to '/opt/homebrew/bin/studio'
That means you have an option to open the app by simply:
studio
Alternately, because the app contains a space in its name:
open $HOME/Applications/Android Studio.app
- Click “Open” if the “app downloaded from the Internet” appears.
- Click “Don’t send”.
- Accept.
- Emulator.
- Finish to watching “Downloading Components”.
-
Finish.
- Notice new repositories are created to:
/Users/johndoe/StudioProjects
Install custom apk app on macOS
- Create a folder
cd "$HOME/bomonike" git clone https://github.com/bomonike/ai-edge-gallery APP_FOLDER_PATH="$HOME/bomonike/ai-edge-gallery" cd "$APP_FOLDER_PATH" ls -al
- Download .apk file (to Downloads folder) Yields file ai-edge-gallery.apk.cpgz
- Alternately, use “The Unarchiver” or Keka archive tools
APP_FILE_PATH="$APP_FOLDER_PATH/apk/" mkdir -p "$APP_FILE_PATH" cd "$APP_FILE_PATH" APK_FILE_NAME="ai-edge-gallery.apk" # FIXME: mv "$HOME/Downloads/$APK_FILE_NAME" "$APP_FILE_PATH" # Respond with A for all: unzip "$APK_FILE_NAME" -d "$APP_FILE_PATH" ls -al
- Creates files AndroidManifest.xml, *.properties, *.dex, etc.
- Creates folders assets, com, google, lib, META-INF, okhttp3, org, res
- Use Adroid Debug Bridge (adb) https://android-sdk-platform-tools-adb.en.softonic.com/mac?ex=RAMP-3252.3#google_vignette
```
adb devices
- daemon not running; starting now at tcp:5037
- daemon started successfully
List of devices attached
adb install “$APK_FILE_NAME” adb: no devices/emulators found ```
- Consider files in the repo:
- model_allowlist.json lists LLM models
Use Android Studio app
- Launch the Android Studio DMG file.
- Drag Android Studio into the Applications folder, then launch Android Studio.
-
Choose whether to import previous Android Studio settings, then click OK.
https://developer.android.com/studio/intro/studio-config
-
Complete the Android Studio Setup Wizard, which includes downloading the Android SDK components that are required for development.
https://developer.android.com/courses
https://developer.android.com/teach with Kotlin language Study in a Jam Session
- See https://developer.android.com/tools/releases/platform-tools Select Mac to download https://dl.google.com/android/repository/platform-tools-latest-darwin.zip
- Use
cd /usr/local/tmp/platform-tools; ls adb etc1tool hprof-conv make_f2fs mke2fs NOTICE.txt sqlite3 billday.txt fastboot lib64 make_f2fs_casefold mke2fs.conf source.properties /usr/local/tmp/platform-tools $ ls -l ../platform-tools-latest-linux.zip -rw-r--r-- 1 chronos chronos 7472902 Dec 20 22:44 ../platform-tools-latest-linux.zip /usr/local/tmp/platform-tools $ ./adb --version Android Debug Bridge version 1.0.41 Version 35.0.2-12147458 Installed as /usr/local/tmp/platform-tools/adb Running on Linux 6.6.30-02726-gb84bbdf6955e (x86_64) /usr/local/tmp/platform-tools $ ./fastboot --version fastboot version 35.0.2-12147458 Installed as /usr/local/tmp/platform-tools/fastboot
Use it
-
Pinch 4 fingers together over the touchpad and type “An” to select “Android Studio”.
- Select “Do not import settings.”
- Custom.
- Choose the Default or darker Dracular theme (which uses less battery, I’m told).
- Check “Android Virtual Device”, then Next for /Users/wilsonmar/Library/Android/sdk
- 2 GiB on a 16 GiB machine.
- Finish. It takes several minutes for Downloading and install.
- Provide password to HAXM installation changes.
- When “Silent install Pass!” appears, press Finish.
-
See
Emulate app
- Start an emulator: Launch one from Android Studio’s AVD Manager
- Wait for boot: Make sure the emulator is fully booted before running ADB commands
-
Check if running: Use adb devices to list connected devices
Training
-
Get training
https://www.udacity.com/course/developing-android-apps–ud853 free video course with https://discussions.udacity.com at Android level “Lollipop”.
- https://github.com/udacity/ud851-Sunshine
- https://github.com/udacity/ud851-Exercises
https://developer.android.com/training/basics/firstapp/index.html text-only instructions
More on IoT
This is one of a series on IoT:
-
IoT Acronymns and Abbreviations on Quizlet
- IoT Apprentice school curriculum
- IoT use cases
- IoT reminders prevent dead mobile battery
- IoT text to speech synthesis
- IoT AWS button
- Intel IoT
- IoT Raspberry hardware
- IoT Clouds
- Samsung IoT Cloud
NOTE: Pages about GE’s Predix have been removed.