Skip to content

Latest commit

 

History

History
275 lines (205 loc) · 6.1 KB

README.md

File metadata and controls

275 lines (205 loc) · 6.1 KB

Android SDK

Glossary

  • Android Debug Bridge (ADB)
  • Android Virtual Device (AVD)

CLI

Dependencies

Installation

Android Studio 🌟

  1. Tools -> SDK Manager
  2. Tab: SDK Tools
    • Check "Show Package Details"
  3. Expand "Android SDK Command-line Tools (latest)"
    • Check "Android SDK Command-line Tools (latest)"
    • Click: Apply

Using CLI

# Using Homebrew
brew install --cask android-commandlinetools

# Using Chocolatey
choco install -y android-sdk

Environment

For Bash or Zsh, put something like this in your $HOME/.bashrc or $HOME/.zshrc:

# Android SDK
export ANDROID_HOME="$HOME/Library/Android/sdk" # for Homebrew
# export ANDROID_HOME="$HOME"/Android/Sdk # for Linux
export ANDROID_SDK_ROOT="$ANDROID_HOME"
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$PATH"

#
export PATH="/usr/local/share/android-commandlinetools/cmdline-tools/latest/bin:$PATH"
sudo su - "$USER"

Commands

#
emulator -help
sdkmanager --help
avdmanager -h

Configuration

# Licenses
yes | sdkmanager --licenses

#
sdkmanager --update

Usage

#
adb shell getprop

Issues

TBD

WARNING      | /absolute/path/to/Library/Android/sdk/system-images/android-25/google_apis/x86_64/ is not a valid directory.
WARNING      | emulator has searched the above paths but found no valid sdk root directory.
PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [/absolute/path/to/Library/Android/sdk]!
avdmanager list avd

TBD

avb_ops_user.cpp:217: ERROR: Error writing data.
avb_user_verity.c:205: ERROR: Error writing to partition 'vbmeta'
Skipping /system for remount
[liblp]bool android::fs_mgr::WritePrimaryMetadata(int, const android::fs_mgr::LpMetadata &, uint32_t, const std::string &, const std::function<bool (int, const std::string &)> &) write 740 bytes failed: Operation not permitted
[libfs_mgr]add partition scratch
[liblp]bool android::fs_mgr::WritePrimaryMetadata(int, const android::fs_mgr::LpMetadata &, uint32_t, const std::string &, const std::function<bool (int, const std::string &)> &) write 740 bytes failed: Operation not permitted
[libfs_mgr]add partition scratch
[liblp]bool android::fs_mgr::WritePrimaryMetadata(int, const android::fs_mgr::LpMetadata &, uint32_t, const std::string &, const std::function<bool (int, const std::string &)> &) write 740 bytes failed: Operation not permitted
[libfs_mgr]add partition scratch
Can not mount overlayfs for partitions: No such file or directory
failed to remount partition dev:/dev/block/dm-3 mnt:/vendor: Permission denied
failed to remount partition dev:/dev/block/dm-2 mnt:/product: Permission denied
failed to remount partition dev:/dev/block/dm-1 mnt:/system_ext: Permission denied
remount failed

TODO

Missing Android Home Binary Files

[4527752704]:ERROR:android/android-emu/android/qt/qt_setup.cpp:28:Qt library not found at ../emulator/lib64/qt/lib
Could not launch '<user>/test/../emulator/qemu/darwin-x86_64/qemu-system-x86_64': No such file or directory

Missing cmdline-tools, emulator, platform-tools, binary path in environment $PATH.

Cache Conflict Between Versions

Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
org.xml.sax.SAXParseException; lineNumber: 141; columnNumber: 252; cvc-complex-type.2.4.a: Invalid content was found starting with element 'base-extension'. One of '{layoutlib}' is expected.
	...

Uninstall Android Studio and try a fresh install.

Behind Proxy

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
	...
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
	...

Option 1:

  • macOS
    1. System Preferences
    2. Network
    3. Verify Services

Option 2: jabba alias default openjdk@1.9.0

TBD1

Warning: java.net.ConnectException: Operation timed out (Connection timed out)

TODO

Library Xml Schema

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
	...

Switch to OpenJDK 8.

Device with API

adbd cannot run as root in production builds
  1. Tools
  2. AVD Manager
  3. Create Virtual Device...
  4. Select: Pixel 3 -> Next
  5. Tab: x86 Images
  6. Select: Nougat (Google APIs) -> Next
  7. Finish

TBD2

emulator: ERROR: AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037

TODO

TBD3

Out of memory: Java heap space.
Please assign more memory to Gradle in the project's gradle.properties file.
echo 'org.gradle.jvmargs=-Xmx4096m' >> ./gradle.properties

TBD4

Execution failed for task ':app:validateSigningRelease'.
> Keystore file /xxx/android/app/my-release-key.keystore not found for signing config 'release'.
#
keytool \
  -keypass PASSWORD1 \
  -storepass PASSWORD2 \
  -genkeypair \
  -v \
  -keystore ./app/release.keystore \
  -alias release \
  -keyalg RSA \
  -keysize 2048 \
  -validity 10000

#
Example
IT Department
Example Inc.
Sao Paulo
Sao Paulo
BR
yes

#
cat << EOF >> ./keystore.properties
keyAlias=release
keyPassword=PASSWORD1
storeFile=release.keystore
storePassword=PASSWORD2

EOF

Invalid Certificate (PKIX)

Warning: Failed to download any source lists!
Warning: IO exception while downloading manifest
Warning: IO exception while downloading manifest
Warning: Still waiting for package manifests to be fetched remotely.
#
sdkmanager --list --verbose
Info: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
# Try
jabba use openjdk@1.17.0

Uninstall

# Darwin
rm -fR ~/.android
rm -fR ~/Library/Android*