Wilson Mar bio photo

Wilson Mar

Hello!

Calendar YouTube Github Acronyms

LinkedIn

Install Android Studio

US (English)   Norsk (Norwegian)   Español (Spanish)   Français (French)   Deutsch (German)   Italiano   Português   Estonian   اَلْعَرَبِيَّةُ (Egypt Arabic)   Napali   中文 (简体) Chinese (Simplified)   日本語 Japanese   한국어 Korean

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
  1. CAUTION: Do a full Backup before proceeding with system-level configurations below.

Prerequisite System Dependencies

  1. Install XCode Command Line Tools:
    
    xcode-select --install 
    
  2. Use Homebrew to install tools used for Android dev :
    
    brew install ant
    brew install maven
    brew install gradle
    brew doctor
    

    Install Java

  3. 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 
    
  4. 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)
    
  5. Confirm:
    which java
    /usr/bin/java
    
  6. VIDEO: What is Temurin?
    • jadx - decompiles APK to Java source code
    • apktool - decodes resources and rebuilds APKs

    Install Android Platform Tools

  7. 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.dmg
    brew install cask android-platform-tools
    
  8. 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

  9. 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)
    
  10. Install Android CLI:
    brew install --cask android-commandlinetools
    
  11. Verify:
    which sdkmanager
    /opt/homebrew/bin/sdkmanager
    
  12. Confirm
    sdkmanager --version
    19.0
    
  13. 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.

  14. 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

  15. 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
  16. 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

  17. AVOID: Use Homebrew to install the Android Native Development Kit (ndk):
    
    brew install --cask android-ndk
    
  18. 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

  19. 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
    
  20. 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

  21. 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:

  22. 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
    
  23. 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
    
  24. Click “Open” if the “app downloaded from the Internet” appears.
  25. Click “Don’t send”.
  26. Accept.
  27. Emulator.
  28. Finish to watching “Downloading Components”.
  29. Finish.

  30. Notice new repositories are created to:
    /Users/johndoe/StudioProjects
    

    Install custom apk app on macOS

  31. 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
    
  32. Download .apk file (to Downloads folder) Yields file ai-edge-gallery.apk.cpgz
  33. 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
  34. 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 ```
  35. Consider files in the repo:
    • model_allowlist.json lists LLM models

    Use Android Studio app

  36. Launch the Android Studio DMG file.
  37. Drag Android Studio into the Applications folder, then launch Android Studio.
  38. Choose whether to import previous Android Studio settings, then click OK.

    https://developer.android.com/studio/intro/studio-config

  39. 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

  40. See https://developer.android.com/tools/releases/platform-tools Select Mac to download https://dl.google.com/android/repository/platform-tools-latest-darwin.zip
  41. 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

  42. Pinch 4 fingers together over the touchpad and type “An” to select “Android Studio”.

  43. Select “Do not import settings.”
  44. Custom.
  45. Choose the Default or darker Dracular theme (which uses less battery, I’m told).
  46. Check “Android Virtual Device”, then Next for /Users/wilsonmar/Library/Android/sdk
  47. 2 GiB on a 16 GiB machine.
  48. Finish. It takes several minutes for Downloading and install.
  49. Provide password to HAXM installation changes.
  50. When “Silent install Pass!” appears, press Finish.
  51. See

    Emulate app

  52. Start an emulator: Launch one from Android Studio’s AVD Manager
  53. Wait for boot: Make sure the emulator is fully booted before running ADB commands
  54. Check if running: Use adb devices to list connected devices

    Training

  55. 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:

  1. IoT Acronymns and Abbreviations on Quizlet

  2. IoT Home Assistant system

  3. IoT Apprentice school curriculum
  4. IoT use cases
  5. IoT reminders prevent dead mobile battery
  6. IoT barn feeder

  7. IoT text to speech synthesis
  8. IoT AWS button
  9. Intel IoT
  10. IoT Raspberry hardware
  11. IoT Raspberry installation

  12. IoT Clouds
  13. Samsung IoT Cloud

NOTE: Pages about GE’s Predix have been removed.