I am trying to create "avd" from python script using command :
android create avd -n avd1 -t android-19 -s QVGA -b x86
Everytime i run this command through Terminal i get avd created but if i am running same command from python script i a getting error which says that "android" command was not found.
Python script:
#!/usr/bin/env python
import sys, os
def main():
cmd = "android create avd -n avd1 -t android-19 -s QVGA -b x86"
print cmd
os.system(cmd)
main()
What could be the possible error.
Environment : Ubuntu 13.04
Path variable set to: export PATH=$PATH:~/android-sdks/tools/:~/android-sdks/build-tools/:~/android-sdks/platform-tools/:~/android-sdks/
From Python's documentation:
Changes to sys.stdin, etc. are not reflected in the environment of the
executed command.
os.system has limitations. The subprocess module is preferable.
Try:
import subprocess
cmd = "android create avd -n avd1 -t android-19 -s QVGA -b x86"
subprocess.call(cmd.split())
Related
I am trying to run the below shell script:
#!/usr/bin/env bash
sdkmanager "emulator" "system-images;android-28;google_apis_playstore;x86_64"
echo no | avdmanager create avd -n "Android" -k "system-images;android-28;google_apis_playstore;x86_64" --device 'Nexus 6P'
$ANDROID_HOME/tools/emulator -avd Android -no-audio -no-boot-anim -no-snapshot -timezone Asia/Phnom_penh
I have added the ANDROID_HOME, ANDROID_AVD_HOME to my PATH (Note: I am using macos with zsh) and i have sourced the zshrc file and also restarted the terminal but keep getting the below error:
./start_emulator.sh: line 3: sdkmanager: command not found
./start_emulator.sh: line 4: avdmanager: command not found
PANIC: Unknown AVD name [ANDROID], use -list-avds to see valid list. ANDROID_AVD_HOME
is defined but there is no file Android.ini in $ANDROID_AVD_HOME/.android/avd (Note:
Directories are searched in the order $ANDROID_AVD_HOME,
$ANDROID_SDK_HOME/avd, and $HOME/.android/avd)
Changing the shell script to below does the job:
#!/bin/zsh
cd $ANDROID_HOME/tools/bin
./sdkmanager "emulator" "system-images;android-28;google_apis_playstore;x86_64"
echo no | ./avdmanager create avd -n "Android" -k "system-images;android-28;google_apis_playstore;x86_64" --device 'Nexus 6P'
$ANDROID_HOME/tools/emulator -avd Android -no-audio-no-boot-anim -no-snapshot -timezone Asia/Phnom_penh
Also running the commands individually(after moving to the folder) seem to work.Not sure if its a permission issue.
I am able to create emulators for android-26 and older using the avdmanager command line, but I am getting the following error when trying to create for android-27 and above:
~/Android/sdk/tools/bin/avdmanager create avd --force -n Tablet -k "system-images;android-27;google_apis;x86" -d 6 --sdcard 200M
Error: Package path is not valid. Valid system image paths are:ository...
system-images;android-26;google_apis;x86
null
The same command for android-26 works:
~/Android/sdk/tools/bin/avdmanager create avd --force -n Tablet -k "system-images;android-26;google_apis;x86" -d 6 --sdcard 200M
Am I missing anything?
P.S.: This is happening in Linux Ubuntu. It seems to work fine in Mac OS.
Your command is correct but problem is that in your system, you don't have "android-27" OS
Please check which OS you have in your system, go into following directory
directory path : ~\Android\Sdk\platforms
if you don't have it please download it first.
download command is : sdkmanager --install "system-images;android-27;google_apis;x86"
I have downloaded the basic Android command line tools from devloper.android.com, now i am creating a new AVD using following command
avdmanager create avd --package 'platforms;android-26;google_apis;x86' -n test-1
Its giving error
Error: Package path is not valid. Valid system image paths are:
I have already installed the package using sdkmanager and its available in my sdk folder under platforms.
First, you need to download the necessary packages.
Here is an example of downloading API 23 packages for x86 emulators:
./sdkmanager "system-images;android-23;google_apis;x86"
and then create your emulator:
./avdmanager create avd -n test -k "system-images;android-23;google_apis;x86" -b x86 -c 100M -d 7 -f
Or you can try with this sample steps:
android update sdk -u --filter platform-tools,android-25
sdkmanager --verbose "system-images;android-25;google_apis;x86"
and then create the avd using:
avdmanager -v create avd -n x86 -k "system-images;android-25;google_apis;x86" -g "google_apis"
I have put the SanAngeles demo to run in my phone.
Here are steps I took:
$ android update project -p . --target android-14
$ ndk-build -B V=1 APP_OPTIM=debug NDK_DEBUG=1
$ ant debug install
It install fine. I saw the program was installed from the list of Apps in my smartphone. If I click on the icon DemoActivity, it runs.
But if I try to do it on host console:
$ adb shell
shell#android: $ am start -a android.intent.action.MAIN -n com.example.sanangeles/com.example.sanangeles.demoactivity
Error type 3
Error: Activity class {com.example.sanangeles/com.example.sanangeles.demoactivity}
does not exist.
Any suggestion?
When I use the Mac OS X Terminal to navigate to the folder with my Android Emulator and type emulator, I get:
command not found
Here's what happens:
$ emulator
-bash: emulator: command not found
How do I get it to work?
The current directory is not normally included in your $PATH on a *nix operating system like OS X; to execute a program in the current directory, precede it with the path to the current directory (.):
$ ./emulator
Emulator can be added with Android Studio https://developer.android.com/studio/run/managing-avds.html
To start emulator: ~/Library/Android/sdk/tools/emulator -avd Nexus_5X_API_23
Related question: How do I launch the Android emulator from the command line?
solutions
1. Symbolic link
steps
create one symbolic link emulator
# soft link
$ ln -s ~/Library/Android/sdk/tools/emulator /usr/local/bin/emulator
call the command
# check all avd
$ emulator -list-avds
$ emulator #avd_name
# OR
$ emulator -avd avd_name
2. system environment
edit env with vim/vscode
# zsh
$ vim ~/.zshrc
# OR
$ code ~/.zshrc
add below lines to the .zshrc file
# export ANDROID_SDK_ROOT=/Users/xgqfrms/Library/Android/sdk
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_AVD_HOME=~/.android/avd
update config
# flush update
$ source ~/.zshrc
refs
https://developer.android.com/studio/run/emulator-commandline
These 3 command works for me on VS Code Terminal (Mac Book Pro M1)
echo 'export PATH=$PATH:~/Library/Android/sdk/emulator/' >> ~/.bash_profile
source ~/.bash_profile
emulator -list-avds
Open Android Studio. Click on AVD Manager (the icon with the android and phone) [example image: AVD Manager]. See the list of emulators. You should see something like "Install Emulator" if you don't have any.
Once this is successful, you'll get the tools folder downloaded to your ~/Library/Android/sdk
That is the folder you want, because it has the android and emulator command line tools.
typcally i use from terminal :
./Library/Android/sdk/emulator/emulator *some action*