There was a path error when Ubuntu created AVD via avdmanager - android-emulator

I used the command line tools provided by Android to download the SDK tools.Use the command avdmanager create avd -n nexus5_23 -k "system-images;android-23;google_apis;x86_64" --device "Nexus 5" to create the emulator, I found that the mirror path in the file config.ini was image.sysdir.1=sdk/system-images/android-23/google_apis/x86_64/.
Compared with the emulator path created by Win10, the emulator can be started normally after changing it to image.sysdir.1=system-images/android-23/google_apis/x86_64/.
I can't find a solution to this problem in Google.Can you give me some Suggestions? thank you.
The environment:
Ubuntu 16.04 Server
bash.rc
...
export REPO_OS_OVERRIDE=linux
# ANDROID SDK
export ANDROID_HOME=/home/yaorc/android/sdk
export ANDROID_SDK_ROOT=/home/yaorc/android/sdk
export PATH=$PATH:${ANDROID_HOME}/emulator
export PATH=$PATH:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin
export PATH=$PATH:${ANDROID_HOME}/platform-tools
export PATH=$PATH:${ANDROID_HOME}/build-tools/29.0.3
export PATH=$PATH:${ANDROID_HOME}/platforms/android-29

I found the answer after several attempts.
Because my command-line tools are in the SDK root,This causes the system image path to be confused when the avdmanager creates the AVD.
Solution:
I created the cmdline directory in the SDK root, cut the tools folder into the cmdline, and modified the environment variable file to properly create and start avd.

Related

How to add mac os support to a flutter package project?

I have tried running the terminal command:
flutter config --enable-macos-desktop
but it gives me error:
The "--platforms" argument is not supported in package template
for an existing project just run
flutter create --platforms=macos .
See also here some official docs from the flutter website:
https://docs.flutter.dev/development/platform-integration/desktop#add-desktop-support-to-an-existing-flutter-app
I have found work around:
copy mac os folder from a new natural flutter project(non-package):
open terminal & run:
cd example/macos
3.run:
pod install
then
flutter run

flutter doctor 'zsh: command not found'

I have installed flutter and set up the path with the zsh file for Catalina version of mac however when I run flutter doctor or flutter precache, I receive zsh: command not found: flutter. NOTE: I managed to get through these steps previously and set up android studio however I had issues when I tried to connect the simulator for Xcode and now I have had to start again.
UPDATE: When running 'flutter' or 'flutter doctor', I receive this error: Error when reading '../../../../documents/flutter/bin/cache/dart-sdk/bin/snapshots/pub.dart.snapshot': No such file or directory and it says that pub upgrade failed after 10 tries.
How would I solve this?
When I run ls -a in the home directory, I see that there's a .bash_profile, a .zshrc file and a .zprofile (which I created previously) in there. Is this related to the problem?
This looks like you don't have flutter on your PATH in ZSH.
Open your .zshrc file in your terminal with
nano .zshrc
You should see the following at the top of the file
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH
Add on the second line the path to the bin directory of your flutter SDK location, like mine:
export PATH=$HOME/bin:/usr/local/bin:$PATH:/Users/joaosoares/Projects/flutter/bin

Getting error while running cordova build android phonegap

I'm getting so many errors in phonegap
#cordova build android
Error: Please install Android target: "android-23".
Hint: Open the SDK manager by running: /home/deb/android-studio/bin/studio.sh
You will require:
"SDK Platform" for android-23
"Android SDK Platform-tools (latest)
"Android SDK Build-tools" (latest)
I have checked my cordova android requirements. Requirements check results for android:
#cordova requirements android
Java JDK: installed .
Android SDK: installed
Android target: not installed
Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
Gradle: not installed
Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
Looked here: /home/deb/sdk/android-sdk-linux/tools/tools/templates/gradle/wrapper
in my ~/.profile file I've added these lines
#~/.profile
if [ -d "$HOME/opt/gradle" ]; then
export GRADLE_HOME="$HOME/opt/gradle"
PATH="$PATH:$GRADLE_HOME/bin"
fi
export ANDROID_HOME="/home/deb/sdk/android-sdk-linux/tools"
export ANDROID_PLATFORM_TOOLS="/home/deb/sdk/android-sdk-linux/platform-tools"
export PATH="$PATH:$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS"
I have solved the problem after lots of research and if you are facing the same problem it could help you.
First, install Gradle if you haven't. Don't set up the env for now so just follow the steps before gedit ~/.profile this command
Install ant if you haven't sudo apt-get install ant
Install android sdk if you haven't.
https://gist.github.com/wenzhixin/43cf3ce909c24948c6e7
We'll avoid set path we'll do it later. Now check your env by printenv in case you tried earlier unset the variables.
unset ANDROID_HOME
Whatever variable you have used just unset them and type to clear the paths:
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
Now we're good to go. Paste this:
gedit ~/.zshrc
Please note that you have to use your path to android sdk for mine it's $home/sdk/android-sdk-linux
$home means /home/username/
export ANDROID_HOME=$HOME/sdk/android-sdk-linux
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platforms:$PATH
export GRADLE_HOME=$HOME/opt/gradle
PATH=$PATH:$GRADLE_HOME/bin
export ANT_HOME=/usr/bin/ant
export PATH=$PATH:$ANT_HOME/bin
source ~/.zshrc
Now if you type cordova requirements android you will get error of target not installed!
We'll solve it here. Use your path to sdk then type the command
sudo ln -s /home/deb/sdk/android-sdk-linux/tools/./android /usr/local/bin/android
Now if you type android in your terminal, Android SDK manager will open.

"ERROR : No emulator images (avds) found" running ionic on osx 10.10

This is the full error message I got after running ionic emulate android
*running cordova emulate android
Running command: /Users/DeadLift/Documents/ionic/myApp/hooks/after_prepare/010_add_platform_class.js /Users/DeadLift/Documents/ionic/myApp
add to body class: platform-android
Running command: /Users/DeadLift/Documents/ionic/myApp/platforms/android/cordova/run --emulator
ANDROID_HOME=/usr/local/Cellar/android-sdk/24.1.2
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
/Users/DeadLift/Documents/ionic/myApp/platforms/android/cordova /node_modules/q/q.js:126
throw e;
^
ERROR : No emulator images (avds) found.
1. Download desired System Image by running: /usr/local/Cellar/android-sdk/24.1.2/bin/android sdk
2. Create an AVD by running: /usr/local/Cellar/android-sdk/24.1.2/bin/android avd
HINT: For a faster emulator, use an Intel System Image and install the HAXM device driver
Error: /Users/DeadLift/Documents/ionic/myApp/platforms/android/cordova/run: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23) *emphasized text*
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)*
I follow all the above by creating an avd and it give me the same message again.
Thanks.
Vikas's answer is pretty spot on, however (sometimes) just running android avd won't work, which is what I found out after hours of trying to get it working.
When ever I ran android avd in my terminal it would give me the following error:
zsh: command not found: android
This is because I needed to add the Android SDK paths for the platform-tools and tools to my zshrc file (you might be running bash or something else on your terminal).
Simple fix was to add these files to my zshrc PATH environment, You can do this too by using your favourite text editor and depending on what shell you're using.
This link: http://docs.phonegap.com/en/2.8.0/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android helped me out a hell of a lot getting this fixed.
So I used subl ~/.zshrc (because sublime is my text editor and i've setup symlinks)
I Found my exports PATH and changed it to represent the following:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/dev/.rbenv/versions/2.2.3/bin/ruby:/Users/dev/Library/Android/sdk/platform-tools:/Users/dev/Library/Android/sdk/tools:$PATH"
I then saved the file, closed down sublime and ran source ~/.zshrc in my terminal window, and now I can run android avd and it now opens the Android Virtual Device Manager with no problems.
A reminder your shell might be different to mine (i.e. not running with zsh)and your exports PATH might look different as well, but it's pretty easy to figure out, and the link above will also help if you get stuck.
Actually it is not able to find AVD (Android virtual device). You have to create one.
Type "android avd" from Command Promt to use the graphical manager to setup an emulator image to work with for running your app on. The graphical tool is fairly straight forward to use.

how to run apk file in android

I try to run apk file in android, i follow these steps
1. First get the Android SDK and unzip it somewhere on your hard drive
2. Add SDK_ROOT to your system variables pointing to /tools folder under the sdk
3. Run the emulator
4. Copy the apk file to /tools folder
5. Change directory to /tools and run from commandline $adb install your_application.apk 6. Now check applications list in the emulator and you should see the new application installed and ready.
but i get this type of error :
" [2011-01-11 17:02:15 - Logcat]device not found
com.android.ddmlib.AdbCommandRejectedException: device not found
at com.android.ddmlib.AdbHelper.setDevice(AdbHelper.java:736)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:373)
at com.android.ddmlib.Device.executeShellCommand(Device.java:284)
at com.android.ddmuilib.logcat.LogPanel$3.run(LogPanel.java:527) "
can you help me any one.... ?
Try to start first the emulator. Navigate to the $SDK_ROOT/tools directory and execute the file 'emulator.exe'. Wait couple of minutes until it loads. Now run :
$adb install your_application.apk
If all went without errors then you should be seeing your newly installed APK on the emulator.