android problems sending app to emulator from using terminal - android

I have launched an emulator with a:
android avd
(although the android developers site said do it from platform-tools, i did it from tools because the android command was there ,and not in platform-tools). Anyway the AVD manager appeared and I started one, and it launched just fine.
Then I tried to send my app to the emulator so (following the android developers instructions) I do a:
adb install /newApp.apk
the command prompt jumps to the next line and just blinks.....when i check the emulator nothing has changed...where am i going wrong???

Once you have started the emulator try
adb devices
to check if you can see it
List of devices attached
emulator-5554 device
then you can proceed with the install
adb install <path-to>/newApp.apk

Something looks strange about that path. If the apk is in the same directory you are launching the command from then you don't need that '/'. If this is a linux machine it would be './' for the same directory unless your apk is all the way up on root but that would be bad :)

Related

Nativescript emulator installation headaches

I've been trying to get emulators to work for NativeScript on my brand new clean Windows 10 laptop for three days and nothing is working.
To be more accurate, I think I was able to get the 'emulator-5554' to launch, but it doesn't not load the Groceries app.
I have all the Angular requirements installed since I also build Angular SPAs and they work fine. I read and followed all these articles, and I still can't get emulators to work.
I even installed GenyMotion, but it is not detected. I have not installed Android Studio since I'll be developing with Visual Studio Code, so I used the Android CLI to install the SDK.
https://docs.nativescript.org/start/general-requirements
https://docs.nativescript.org/start/introduction
https://docs.nativescript.org/start/cli-basics
https://docs.nativescript.org/tooling/android-virtual-devices?_ga=2.188319272.1221867054.1547512018-618552819.1547075699
https://docs.nativescript.org/start/quick-setup
https://docs.nativescript.org/start/ns-setup-win - this was my primary emulator setup
I have also read many SO posts and none have solved my problem.
Is there some documentation somewhere that is simple and clear, with step by step instructions on how to get emulators installed that will work with Nativescript? What am I missing?
BTW, when I connect my Samsung Galaxy S8 Active phone to my laptop, it's not recognized by the tns device command either.
I can't believe it's this difficult to get emulators to work. I also can't believe that the Nativescript documentation has left this information out of their instructions.
This might not be the answer most are looking for, but this is what was wrong with my installation and this is how I fixed it:
I noticed that the docs all had $./advmanager [someArg] and I had to be sudo for commands to execute. So I ran sudo chown -R myUser:myUser /usr/local/android thus changing all owner:group permissions from root to myUser.
then I could run ./avdmanager create.... (full command below) without having to be superuser
restarted Nativescript Sidekick
I know this is kinda stupid, but I worked out that if the AVD was created as root, the Sidekick program running as myUser could not see and access it. This was confirmed when I ran avdmanager list avd as sudo and got a result, but after changing my files' ownership from root to myUser, nothing was listed from the same command.
I recreated my virtual devices (AVDs) as a normal user and Sidekick was able to see them.
edit: the actual line I ran to create the AVD (because I see a lot of variation in these):
$ ./avdmanager create avd --name Pixel -k "system-images;android-28;google_apis;x86" --device "pixel"?
The uppercase and lowercase "pixel"s come from one entry from the output of
$./avdmanager list
id: 17 or "pixel"
Name: Pixel
OEM : Google
---------
Do this "create" step for each device you want to emulate.
Install Android Studio and open it. Then (without starting a new project) click on:
Configure --> AVD Manager.
There you can create virtual devices, which will be recodnized by NativeScript Sidekick and its virtual device launcher.

Open Android Device in Genymotion from Expo XDE gives error

I am using Expo XDE version 16.0.0 and I would like to test my app in the Android emulator. I am on a mac. I have installed Genymotion and have started the emulator as the expo.io (https://docs.expo.io/versions/v16.0.0/guides/genymotion.html) docs describes but I get the following error. I have no idea of what it means or how to fix it.
Couldn't start project on Android: could not install smartsocket. listener: Address already in use ADB server didn't ACK * failed to start daemon * error: cannot connect to daemon
I hope someone can help me on this one?
In my case the solution was this on an Ubuntu 17.04
sudo apt remove android-tools-adb
adb kill-server
adb start-server
it's possible you have adb and android-tools-adb installed
After having spent a day figuring it out, I decided to go with using the Android emulation within genymotion. This is for Ubuntu (16.04).
Download Android Studio & go into Tools > Android > AVD Manager.
Download the SDK for whichever device & Android version you are going
to use.
Once downloaded, test the emulator is functional by clicking
on the green play icon under 'actions' (far right in Virtual Devices
screen).
Open genymotion, settings > ADB > 'use custom Android SDK
tools'. Select folder /*/Android/Sdk (wherever Android sdk is
installed)
Test by clicking on 'Start' in main genymotion screen.
Open Expo XDE, load up the project & 'ctrl+d' to load on android
device. It will start the installation of expo app.
vividresponse here worked for me even on linux (he made it on OSX and I see it works for windows too).
Basically, you must check the versions of adb. Like:
adb version
And (using you real path)
/opt/android-sdk/platform-tools/adb version
If they differ, replace /usr/bin/adb (first one) with the second one.
Other important things are that you must set the correct genymotion SDK. And make sure sdk & sdk tools must be present in the PATH variable.

How to install an application on android emulator?

When i enter "adb install asdasd.apk" to cmd returns "error:device not found". How can I fix this?
Just copy that apk file into ( D:\android-sdk\platform-tools ) android sdk platform tools.
and then open the cmd prompt.
then, come into that platform tools path in cmd prompt.
then, give like this in cmd -- adb install (appName).apk
wait few minutes and get success respomse in cmd prompt..
First, familiarize yourself with a concept of AVD. That's basically an instance of the emulator - it has a bunch of settings, like the Android version to use and screen size and an SD card image.
You cannot install stuff "in the emulator" - you can only install stuff into a specific AVD. For that, you need to create and run an AVD first. For that, use "AVD Manager" from Eclipse or standalone.
Under the Android SDK folder in Explorer, run "AVD Manager". Choose an AVD (or create a new one if you don't have any). Select, click "Start".
Does the emulator show up when you run the following command?
adb devices
If not, you might have to boot up the AVD first, but if I remember correctly it should be starting it up by itself.
Have you created a new emulator for your project? And are you using Eclipse? Eclipse has an ADT plugin which is useful as it allows you to open the AVD manager through it. This plugin will give you this option in the Windows tool bar of Eclipse: Windows>AVD manager.
Create a new project based on the emulator and click the run button which will install your project onto the emulator. If you have an Android device I recommend turning USB development mode in your phones settings and running your project straight onto your device as it will be a lot faster. Hope this helps
this is what i did :
first run the "AVD Manager"-> choose an AVD -> click "Start"
immediately after
you click on "Start"
use command on cmd as,
adb install asdasd.apk
then in my case (Windows), asked to place .apk file in data/local/tmp/
what i did was copy and paste .apk file into data/local/tmp
and again use command
adb install asdasd.apk
then cmd prompted-> Success
You can also use command
adb devices
command for check whether emulator is in the list
Actually you may need to run AVD several times

android emulator on eclipse won't open

I've gotten it to work before but now the android emulator on eclipse refuses to open. No new window, nothing. Most of the time the console says nothing when I tell it to launch, other times it says "The connection to adb is down, and a severe error has occured." but if I try again after waiting a bit it goes away then it says Launching.... and does nothing.
I try to delete the avds and it says they are currently running in emulators and cannot be deleted even though there are no windows open. I tried re-installing the (1.6) SDK and that didn't work.
Oh and I'm using Ubuntu
Edit The console is finally working, after complaining about adb, I ran it again and I got
"Launching a new emulator with Virtual Device "XXX" and then nothing
then I tried to launch a different project with the same emulator and got:
Automatic Target Mode: Preferred AVD "XXX" is not available. Launching new emulator.
Launching a new emulator with Virtual Device "XXX"
Run adb kill-server and then sudo adb start-server and then adb devices and see if you see the emulator. Sometimes the emulator is running but it hides somewhere. Also trying running the app in debug mode. Also the emulator can be just damn slow sometimes. adb is a command located in the sdk tools directory I think. Add it to your path and it will save you a lot of time. You can also do install and uninstall of your apps using command. Then tell us what you see.
I did have the same issue and I solved it by running the emulator from the command line. Go to the tools folder in the SDK package and start the emulator from there, use the name of the emulator you setup in Eclipse (in Virtual Device Manager):
./emulator -avd [the name]
The GUI should either come up (the GUI comes up fairly quick but will "idle" quite a bit) or you'll probably get an error on the command line. For me it was a missing library, namely libGL.so. Install a lib with apt-get containing libGL and retry.
sudo apt-get install libgl1-mesa-dev:i386
./emulator -avd [the name]
I did some googling and I'm not the only one, and of course those libs are missing in a 64 bit environment. Here's another one with the same problem.
Hope it helps!

Testing Android Applications on a Clean Emulator

When I want to test an android application, I create a new AVD, start it in the emulator, wait for the emulator to finish booting, and then use ADB to install the application, and when I'm done delete the AVD. Are there any tools that automate all of those steps? I tried writing my own but I couldn't find a way to tell if the emulator was completely booted, as the Android SDK website says not to use "adb wait-for-device install file.apk".
You're right not to use wait-for-device. It does not wait for the package manager to be available, which is what you need. I'm not sure how eclipse does it but you can poll the emulator until the package manager is available using the command adb shell pm path android. The command should return 'package: something'. Check out this python script that uses the technique: www.netmite.com/android/mydroid/1.6/.../adb_interface.py. It's pretty big but if you search for the command above you'll find the relevant piece of the script.
Why do you want to delete the AVD every time?
If you are deleting it every time because the install command throws an error due to the app already existing on the AVD, you can do this: adb install -r file.apk. The -r part is used for reinstalling the app. Here is the full usage instructions for adb.
Are you deleting it to remove the application you are testing and revert to a 'clean' emulator? If so it's not necessary to delete the AVD every time. You can specify the -wipe-data option when starting the emulator. This effectively resets the AVD to how it was when you created it. Here is the emulator documentation.
Hopefully that helps simplify your script.

Categories

Resources