Related
With 25rc1 of the SDK tools I am having a problem when starting the emulators from $PATH
➜ ~ which emulator
/home/ligi/bin/android-sdk/tools/emulator
➜ ~ emulator #M
Could not launch './qemu/linux-x86_64/qemu-system-i386': No such file or directory
➜ ~ /home/ligi/bin/android-sdk/tools/emulator #M
console on port 5554, ADB on port 5555
Anyone knows a workaround? I could write a script to start emulators and cd in tools before but perhaps there is a better solution.
I encounter this one in android studio 2.3 which use new path for the emulator so try the following:
do not use emulator executable in the: sdk-path/tools/ directory but instead use the one found in the : sdk-path/emulator/
and also remove or rename the emulator found in the sdk-path/tools directory.
and because android sdk shipped with it's own libstdc++.so.6 you need to do the following to avoid the libGL error:
cd $ANDROID_HOME/emulator/lib64/libstdc++
mv libstdc++.so.6 libstdc++.so.6.bak
ln -s /usr/lib64/libstdc++.so.6 $ANDROID_HOME/emulator/lib64/libstdc++
Try this, it work for me on Windows.
Tools -> Android -> SDK Manager -> SDK Tools -> Android Emulator
Then click on Apply.
If you're launching the emulator from command-line, try setting the current directory to your android sdk "tools" folder first.
This works for me as a workaround:
pushd ${ANDROID_HOME}/tools
emulator -avd ${EMULATOR_NAME} -wipe-data&
popd
This one works for me on MacOS Sierra.
Preference -> Appearance & Behavior -> System Settings -> Android SDK -> SDK Tools (tab)
Tick on Android Emulator and Apply
I had the Android Emulator up to date under SDK Tools. But I was still getting the error. Adding the following line to ~/.bash_profile solved the problem for me:
PATH=$ANDROID_HOME/emulator:$PATH
In Ubuntu 19.10!
With the environment variables already configured ($ANDROID_HOME), you should be able to list the AVDs, but if you are unable to start the AVD, do the following:
# Check the AVD target name
emulator -list-avds
# But to start do:
$ANDROID_HOME/emulator/emulator #avd_name
or
/home/$USER/Android/Sdk/emulator/emulator #avd_name
Make sure that ANDROID_EMULATOR_FORCE_32BIT is not set in your environment
In Virtual device configuration, set Emulated performance to Software GLES 2.0
yah my dns is blocked in the region i am visiting so i was searching for a way to add dns servers and start emulator at command line. default emulator in path did not work. instead go to your android SDK home and you'll see a emulator in there. use that emulator executable like this:
emulator -avd Nexus_5X_API_26 -dns-server 8.8.8.8,208.67.222.222,199.85.126.10,8.8.4.4
i think you can give 4 dns's. anyway this is a side note. back to the issue:
people here did not mention much that you need the -avd flag with it. wanted to point that out.
Do not use $ANDROID_HOME/tools/emulator, it will cause error when you launch every time unless you change dir.
There is a another emulator in $ANDROID_HOME/emulator.It is a good choice
How to open the AVD manager on Ubuntu Linux from the command line?
For thoose coming here because the android avd command has been deprecated*, here's how to do it now:
Using Android Studio
Open Android Studio with a valid studio project (if you don't have one, simply create one empty). After you've your project open, go to Tools => Android => AVD Manager. Note that this menu does not appear if you don't have a valid Android Studio project open.
Now you can safely close Android Studio if you only want the AVD Manager.
From command line
If you want to use the command line you'll first need to create the virtual device using avdmanager, located under $ANDROID_HOME/tools/bin/avdmanager like so:
$ANDROID_HOME/tools/bin/avdmanager create avd --force --name testAVD --abi google_apis/x86_64 --package 'system-images;android-23;google_apis;x86_64'
After you created the device to emulate, then you need to open it with emulator, which is located under $ANDROID_HOME/tools/emulator. The command for the previously created device should be something like:
emulator -avd testAVD
If it crashes saying something like...
[140022905190208]:ERROR:./android/qt/qt_setup.cpp:28:Qt library not found at ../emulator/lib64/qt/lib
Ensure you're running the emulator command inside the $ANDROID_HOME/tools folder, otherwise may not work.
If you already added a device VM you can list them all with
emulator -list-avds
Check out the official documentation for more details (thanks to Jeff Xiao for this—in comments).
* The depreaction note says:
The android command is no longer available.
For manual SDK and AVD management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
Use android avd to open the AVD Manager.
For me, ./android avd worked, where android was the shell script under android-studio/sdk/tools.
Sadly commands android sdk and android avd stopped working so to run emulator we need to use different commands to download and build all devices and its dependencies:
Download sdk-tools-linux (tar.gz) from:
https://developer.android.com/studio#downloads
Unpack tools to : ...android-sdk/tools (...wherever you want)
Go to : android-sdk/tools/bin
Install needed sdk libraries:
Execute in cmd
sdkmanager --update
sdkmanager "platform-tools" "platforms;android-29"
sdkmanager "build-tools;29.0.1" "extras;android;m2repository" "tools"
sdkmanager "system-images;android-29;google_apis_playstore;x86_64"
sdkmanager "emulator"
Setup environment variables
Add env to system by editing ~/.bashrc (Linux) in Windows just setup system enviroments.
export ANDROID_HOME=../android-sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
alias emulator="sh $ANDROID_HOME/tools/emulator"
Note: There is possible that You need JAVA_HOME too.
Restart computer or cmd to load environments
Create device:
Go to /bin
avdmanager create avd -n myDevice -k "system-images;android-29;google_apis_playstore;x86_64"
run device:
Got to dir and run
cd android-sdk/tools
emulator -avd myDevice (or sh $ANDROID_HOME/tools/emulator -avd myDevice)
Issues:
qemu emulator not found in /bin....
cd android-sdk/tools/bin
ln -s android-sdk/emulator/ emulator
./android avd is deprecated use ~/Android/Sdk/tools/bin/avdmanager --help instead!
or if it is easier for you, move to the directory and use it like in the old version:
cd ~/Android/Sdk/tools/bin/
./avdmanager
check new [options] with --help or -h before you use avdmanager
first occurence in Android Studio 2.3 !
Android studio:v3.0.1
Get name:
/home/user/Android/Sdk/tools$ android list avd
Start emulator:
/home/user/Android/Sdk/tools$ emulator -avd Nexus_6_API_23
First of all to show all devices
run the following command from the location - ~/Android/Sdk/tools
/home/user/Android/Sdk/tools> ./emulator -list-avds
then you will see the list of devices id, in my case i got following devices
Nexus_5X_API_28
Nexus_9_API_28
Now just run following command with the device id you want to run.
/home/user/Android/Sdk/tools> ./emulator -avd Nexus_9_API_28
I created shortcut with this command
/path/to/Android/emulator/emulator -avd Nexus_5X_API_26
Where "Nexus_5X_API_26" is my virtual device I created in Android Studio (2.3.3). Correct name can be checked from ~/.android/avd/ folder, where are one subfolder (with extension .avd) and one file (with extension .ini) for each. There are qcow2 files which I think could be also run directly with qemu (have not tested yet).
I used a sudo bash command and that worked for me:
sudo ./avdmanager list
Here's the command-line usage for creating an AVD:
android create avd -n -t [- ] ...
Example :
android create avd -n my_android1.5 -t 2
If the target you selected was a standard Android system image ("Type: platform"), the android tool next asks you whether you want to create a custom hardware profile.
Android 1.5 is a basic Android platform.
Do you wish to create a custom hardware profile [no]
Use the create avd command to create a new AVD, specifying the --skin option with a value that references either a default skin name (such as "WVGA800") or a custom skin resolution (such as 240x432). Here's an example:
android create avd -n -t --skin WVGA800
or you can refer from :-
http://developer.android.com/tools/devices/managing-avds-cmdline.html
If for example I have simple android project and I want to run it from command line of Android Studio. How can I do that? I want to enter some commands into command line:
ant debug adb install bin/MyFirstApp-debug.apk
Where can I find command line in Android Studio? Thanks for any help.
Update:
New location in Android Studio: View -> Tool Windows -> Terminal.
Also, the default keyboard shortcut is alt + F12.
Old:
Go to Tools -> Open Terminal. Works great.
I've tried to use the Windows terminal to do the cmd like "adb logcat", but it says "adb is not recognized."
So I just found a solution provided by the following link, which works fine for me:
https://www.youtube.com/watch?v=yjutSsQn2Ic
Steps to setup adb on windows :
1) Open command promt and type adb
you will see this message :'adb' is not recognized
2) Now Download sdk(adt bundle) from
http://developer.android.com/sdk/index.html
the ADT Bundle includes everything you need to begin developing apps: Eclipse + ADT plugin Android SDK Tools Android Platform tools The latest Android platform The latest Android system image for the emulator
3)Extract the zip to c drive with name "AndroidSDK" Open the platform-tools folder, you will find the adb.exe file
4)Now click on my computer and select properties
5) Click on advanced system settings
6) Choose environment variables
7) From system variables, choose path and double click on it
8)At the end of variable values put a semicolon ;
and address of platform tools folder,
for me it is
C:\AndroidSDK\platform-tools
9)Now click OK
10)Open command prompt and type adb
11) You will see it is working
View -> Tool Windows -> Terminal (Alt + F12)
appears to be the menu navigation for newer versions of Android Studio (1.2.1.1, at this time)
To open terminal in android studio Android Studio Arctic Fox
View -> Tool Window -> Terminal (or) Alt + F12
You can either run your apk on an emulator or directly on a device via the adb CLI.
Devices
Find your preferred plugged in device ID:
adb devices
Install onto your device (or emulator if no device ID) with the following command:
adb -s "your-device-ID" install bin/MyFirstApp-debug.apk
You can also run with the following command:
adb shell am start -n com.app.name/com.app.name.LaunchActivity
Emulators / AVDs
List your emulators:
emulator -list-avds
Run a specific emulator:
emulator -avd device_name
eg:
emulator -avd Pixel_5_API_30
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
I finally managed to obfuscate my Android application, now I want to test it by installing the APK file and running it on the emulator.
How can I install an APK file on the Android Emulator?
You can simply drag and drop the .apk file of your application to the emulator and it will automatically start installing.
Another option:
Windows:
Execute the emulator (SDK Manager.exe->Tools->Manage AVDs...->New then Start)
Start the console (Windows XP), Run -> type cmd, and move to the platform-tools folder of SDK directory.
Paste the APK file in the 'android-sdk\tools' or 'platform-tools' folder.
Then type the following command.
adb install [.apk path]
Example:
adb install C:\Users\Name\MyProject\build\Jorgesys.apk
Linux:
Copy the apk file to platform-tools in the android-sdk linux folder.
Open Terminal and navigate to platform-tools folder in android-sdk.
Then Execute this command -
./adb install FileName.apk
If the operation is successful (the result is displayed on the screen), then you will find your file in the launcher of your emulator.
Mac:
PATH=$PATH:~/Library/Android/sdk/platform-tools
Example : PATH=$PATH:/users/jorgesys/eclipse/android-sdk-mac_64/tools
Then run adb.
Mac:
1.Run the emulator,
2.then copy your .apk file and paste into /Users/your_system_username/Library/Android/sdk/platform-tools,
if you are not able to find sdk path in your mac system, do the following steps: Open finder->select Go option on top menu -> select Go to Folder option -> it will popup a window with a textfield: /Users/your_system_username/Library/Android/sdk/ -> now open platform-tools folder and paste your copied .apk file,
Now open the terminal and type the following:
cd Library/Android/sdk/platform-tools
execute the following in your terminal: ./adb install yourapkfilename.apk if you get the following error message: error: no devices found - waiting for device, follow step 5.
Run your emulator from Android Studio, once emulator active then repeat step 4, you will see the success message on your terminal.
If you've created more than one emulators or if you have an Android device plugged in, adb will complain with
error: more than one device and emulator
adb help is not extremely clear on what to do:
-d - directs command to the only connected USB device...
-e - directs command to the only running emulator...
-s <serial number> ...
-p <product name or path> ...
The flag you decide to use has to come before the actual adb command:
adb -e install path/to/app.apk
Nowadays, you can simply drag and drop the Android apk to the emulator and it will automatically starts installing.
go to sdk folder, then go to tools.
copy your apk file inside the tool directory
./emulator -avd myEmulator
to run the emulator on mac
./adb install myApp.apk
to install app on the emulator
go to the android-sdk/tools directory in command prompt and then type
adb install fileName.apk (Windows)
./adb install fileName.apk (Linux or Mac)
Copy .apk file in your SDK's platform-tools/ directory,then install the .apk on the emulator by using cmd(on windows):
adb install <path_to_your_bin>.apk
or
./adb install <path_to_your_bin>.apk
If there is more than one emulator running,
you can find all running emulators by this command:
adb devices
or
./adb devices
then you must specify the emulator upon which to install the application, by its serial number, with the -s option. For example:
adb -s emulator-5554 install path/to/your/app.apk
or
./adb -s emulator-5554 install path/to/your/app.apk
First you need to install Android Studio on your machine. Then simply follow these steps.
Go to you navigation bar and open Android Studio.
From the toolbar open AVD Manager. (If you cannot see it create a new android project)
Create a Virtual Device.
Select a hardware device that you want to install your app.
Select an android image that you want to install on your device. (If you cannot see any images you can download the require image from Recommended, x86 Images or Other images)
Add a name to your AVD.
Now the virtual device has been created and you can simply run it by clicking the play button.
Now you have setup the virtual device and now you need to install the APK file.
Download the APK file that you want to install and Drag and Drop it to the emulator.
The APK file has been successfully installed and you can see it in your applications.
Now you can simply run the installed app.
Drag and drop
Simply drag-and-drop the apk file into your emulator.
You can also run your android emulator without Android Studio.
In Genymotion just drag and drop the *.apk file in to the emulator and it will automatically installs and runs.
http://www.genymotion.com/
Download the Apk file from net and copy it to platform-tools of your SDK folder, then in command prompt go to that directory an type:
adb install filename.apk
press enter it will install in few seconds
Download apk file from browser and then just click on it (notification area). Installation will start automatically.
Goto Shell/Terminal/, reach at android-sdk/tools directory then
adb install fileName.apk // (u can run this command on windows)
or
./adb install fileName.apk //( u can run this command on linux)
Let's suppose you have to install Facebook APK on your emulator.
You can use adb to install the APK to the running emulator in OS X like this:
./adb install ~/FBAndroid-2.1.apk
And on Windows, like this:
adb install %HOMEPATH%\FBAndroid-2.1.apk
Once complete, check the apps screen of the emulator to check that the app has been installed correctly. If you need to force the upgrade of this app from a previous version, add the -r flag, like this on OS X:
./adb install -r ~/FBAndroid-2.1.apk
keep your emulator up and running.
In the command line, go inside the platform-tools folder, in your sdk folder which come with adt bundle and execute following command :
>adb install <yourFilename.apk>
This command detect your running emulator/emulators and show you the list of devices where you can install this app(show if any physical device/devices connected to your computer.). Then you can select any one, if only one emulator is running then app will directly installed on it by default.
Note: For above command your .apk file needs to be in same directory.
for more detailed tutorial follo : This link
From Windows 7 Onwards ,
Shift + Right click in your apk file folder.
Select Open Command Window Here
Type & Hit "adb install AppName.apk"
Drag and drop ".apk" file into the emulator window.
Just drag and drop your apk to emulator
(TESTED ON MACOS)
The first step is to run the emulator
emulator -avd < avd_name>
then use adb to install the .apk
adb install < path to .apk file>
If adb throws error like APK already exists or something alike. Run the adb shell while emulator is running
adb shell
cd data/app
adb uninstall < apk file without using .apk>
If adb and emulator are commands not found do following
export PATH=$PATH://android-sdk-macosx/platform-tools://android-sdk-macosx/android-sdk-macosx/tools:
For future use put the above line at the end of .bash_profile
vi ~/.bash_profile
if use more than one emulator at firs use this command
adb devices
and then chose amulatur and install application
adb -s "EMULATOR NAME" install "FILE PATH"
adb -s emulator-5556 install C:\Users\criss\youwave\WhatsApp.apk
I might be wrong, but on Windows I simply drag and drop the .apk into Android Emulator. I mean, doing all mentioned above seems to be a lot of work.
go to ADT/Android-sdk/tools directory in command prompt
1. adb install fileName.apk (Windows)
./adb install fileName.apk (Ubuntu/Linux or Mac)
06-11-2020
Drag and Drop didn't work for me on Windows 10 Pro.
Put the APK on Google Drive
Access that Google drive using Chrome browser on the Android Emulator
Then install it from there.
Note: You need to enable unknown sources within the Emulator.
Best way is to create a app, which opens the apk file on the emulator. You have to copy the .apk file to the download folder of your emulator. Then replace yourAppName.apk with your .apk name.
here is the code
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "yourAppName.apk")), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
(1) You can also use gradle commands to install your APK while choosing the product and flavor (Debug or Release).
See this Guide.
./gradlew assembleDebug (Incase you don't have the APK generated)
./gradlew installDebug
Incase you want a fresh install, you can remove any earlier installed builds on the device with below commands
./gradlew uninstallDebug
./gradlew installDebug
(2) You can also use the adb commands directly:
Setup adb for command line
export PATH=/Users/mayurik/Library/Android/sdk/platform-tools/adb:/Users/mayurik/Library/Android/sdk/tool
Command line ADB install
adb -d install pathto/sample.apk (on device)
adb -e install pathto/sample.apk (on emulator)
Also check the documentation here
$ adb devices
List of devices attached
emulator-5554 device
emulator-5555 device
$ adb -s emulator-5555 install helloWorld.apk
you write the command on terminal/cmd
adb install FileName.apk.
Now you can just drag and drop the apk in emulator and it will install!
On Linux I do this:
first see which devices I currently have: emulator -list-avds
build the release cd android && ./gradlew assembleRelease
install it at the emulated device "Nexus5" (you are inside the android directory, else use the full path to apk): adb -s '8e138a9c' install app/build/outputs/apk/app-release.apk
Thats it. You can also use ./gradlew installRelease
Follow the steps :
make sure you have allowed installation from unknown sources in
settings.
Use the Android Device Monitor to copy the APK to the sdcard.
Use the builtin browser in Android to navigate to
file:///sdcard/apk-name.apk
When the notification "Download complete" appears, click it.
1) paste the myapp.apk in platform-tools folder , in my case C:\Users\mazbizxam\AppData\Local\Android\android-sdk\platform-tools, this is the link in my case it may change to you people
2)open the directory in CMD CD C:\Users\mazbizxam\AppData\Local\Android\android-sdk\platform-tools
3)Now you are in platform-tools folder , just type adb install myapp.apk
please ensure that your emulator is turn on , if every thing is ok apk will install
Start the console (Windows XP), Run -> type cmd, and move to the
platform-tools folder of SDK directory.
In case anyone wondering how to run cmd in platform-tools folder of SDK directory, if you are running a new enough version of Windows, follow the steps:
Go to platform-tools through Windows Explorer.
While holding shift right click and you will find the option "Open Command window here".
Click on it and cmd will start in that folder.
Hope it helps