How do you install an apk on the emulator in Android Studio from the terminal?
In Eclipse we did
/home/pcname/android-sdks/platform-tools/adb -s emulator-5554 install /home/pcname/Downloads/apkname.apk
Now how about in Android Studio?
Run simulator -> drag and drop yourApp.apk into simulator screen.
Thats all.
No commands.
EDIT: Even though this answer is marked as the correct answer (in 2013), currently, as answered by #user2511630 below, you can drag-n-drop apk files directly into the emulator to install them.
Original Answer:
You can install .apk files to emulator regardless of what you are using (Eclipse or Android Studio)
here's what I always do: (For full beginners)
1- Run the emulator, and wait until it's completely started.
2- Go to your sdk installation folder then go to platform-tools (you should see an executable called adb.exe)
3- create a new file and call it run.bat, edit the file with notepad and write CMD in it and save it.
4- copy your desired apk to the same folder
5- now open run.bat and write adb install "your_apk_file.apk"
6- wait until the installation is complete
7- voila your apk is installed to your emulator.
Note: to re-install the application if it already existe use adb install -r "your_apk_file.apk"
sorry for the detailed instruction as I said for full beginners
Hope this help.
Regards,
Tarek
For those using Mac and you get a command not found error, what you need to do is
type
./adb install "yourapk.apk"
Start your Emulator from Android Studio Tools->Android-> AVD Manager then select an emulator image and start it.
After emulator is started just drag and drop the APK Very simple.
Just drag APK file to android emulator it will install automatically.
In android studio emulator to run an apk file just drag the apk into the emulator.The emulator will install the apk
Much easier is just to start your emulator, then go to sdk/platform-tools and use adb from there to install apk. Like:
adb install xxx.apk
It will install it on running emulator.
Drag and drop apk if the emulator is launched from Android Studio. If the emulator is started from command line, drag and drop doesn't work, but #Tarek K. Ajaj instructions (above) work.
Note: Installed app won't automatically appear on the home screen, it is in the apps container - the dotted grid icon. It can be dragged from there to the home screen.
For Linux: once emulator is running, the following worked for me.
Because I installed the Android SDK on my home directory, I have the following file structure:
home/Android/Sdk/platform-tools/adb
home/AndroidStudioProjects/Metronome.adk
AndroidStudioProjects is a file folder I made for my Android projects. "Metronome.adk" is the file I want to run.
So, using Terminal from the home directory...
./Android/Sdk/platform-tools/adb install ./AndroidStudioProjects/Metronome.adk
Being a Linux novice, I often forget the need to put the "./" in when trying to locate a file or run a command.
After the command achieves "Success", the app is in the Apps area of the emulator and can be run.
When you start Android studio Look for Profile or Debug apk.
After clicking you get the option to browse for the saved apk and you will be able to later run it using emulator
If Android Studio is already open:
Click on File you can find Profile or Debug apk in this menu too
Just download the apk from talkback website
Drag the downloaded apk to the started emulator, Go to settings on emulator > Search for talkback, you will now find it there
1.Install Android studio.
2.Launch AVD Manager
3.Verify environment variable in set properly based on OS(.bash_profile in mac and environment Variable in windows)
4. launch emulator
5. verify via adb devices command.
6.use adb install apkFileName.apk
Upload your apk file on the cloud , then make a direct download link for downloading and then copy that link and paste it on the emulator browser for download it :) ;
In Android Studio: View - Tool Windows - Gradle
In the Gradle tool window navigate to your :app - Tasks - install
and then execute (by double-clicking): any of your install*tasks: e.g. installDebug, installRelease
Note: the apk will also automatically installed when you Run your application
Related
I need to export my Android Studio project to an Android phone. I've generated a signed APK already but I don't know what to do after this. What else do I need to do to export my project?
Install it. Look for the apk file in the project folder and transfer it to your phone and click it.
Another way, connect your android phone to your laptop and click on instant Run.
This isn't called exporting, it's called installing.
By default, the APK should be under
app/release/
in your project directory, as app-release.apk.
You can use the Android Studio terminal tab (check the bottom toolbar) to install it directly:
adb install -r app/release/app-release.apk
If you have Android Emulator, then you can directly run and check your app contents.
Or
If you want your app to run on your phone, then go to the app folder of your Android project
Directory : app/release/release.apk
Connect your data cable and move that release.apk in your phone directory and install that apk file in your Android phone.
I want to launch the React Native application on Android emulator using Ubuntu 16.04. Following the react native docs it should be dove by running
react-native run-android
OR
npm run android
Both these commands are not working without sudo for some reason, but that's not an issue. The issue is when I run them every time I get the same error:
Error running adb: No Android device found. Please connect a device
and follow the instructions here to enable USB debugging:
https://developer.android.com/studio/run/device.html#developer-device-options.
If you are using Genymotion go to Settings -> ADB, select "Use custom
Android SDK tools", and point it at your Android SDK directory.
I don't want to connect device via USB and I don't use Genymotion, I just want an emulator. I tried to run the project via Android Studio, but faced with another issue :
Error: please select Android SDK
I tried syncing the files, removing the project, restart the studio - nothing. (However I can see the Nexus 5X in the devices list and even start it)
Please someone help me, I've tried everything I could find - nothing helps
Both these commands are not working without sudo for some reason, but
that's not an issue.
Probably, this is the root cause.
Because, if you have ever installed your Android SDK / Tools using "sudo" or you installed it into the directories of root user, then those files may not be accessible or executable by a normal account. So, try below steps:
Delete the hidden dirs ~/.gradle ~/.idea ~/.m2 and ~/.android using command
sudo rm -rf ~/.gradle ~/.idea ~/.m2 ~/.android.
This step is to clear up your previously installed files with root previlige. If you don't have those folders, ignore this step.
Re-install your Android Studio into your normal user home directory, e.g. ~/android
Create your AVDs using the newly installed Android Studio.
Don't use any "sudo" for your newly configured environment. Because anything installed with root privilege will go to root directory, i.e. /, but not your normal user home dir, i.e. ~/. If you start your Android Studio with a normal user, usually, it will only be able to refer to your setups under ~/. This is probable the reason for not being able to find your "installed" Android SDK.
My question is when i click on run button it runs gradle command to check change files and build class and then dex to create apk.
If i know there is no change in my files still gradle runs to check.
As i have many libraries attached to my app module to reduce run time. if anyone knows to install apk in device from android studio without running gradle.
Note : I want to install on device which is connected to my system not to emulator,etc.
Note : I want to install from android studio not by using any other software.
One more solution is using terminal to install apk on devices.
Once you have built your APK using the File>Build APK, it shows you the path in which new apk is present.
Just go to the path on terminal like below
generated apk path on my system -$cd /Android_App_Code/UpdatedCodeForCheckOut/Projects/IMS/source/apps/Android/flowtalk/app/build/outputs/apk
and type -$ adb install -r app-debug.apk
this command just installs the build on your connected device.
and now every time when there is no change in code, just run install command on terminal. It's super fast you will see.
You can't skip a Gradle build unless you want a constant APK that has no changes.
Go to File>Build APK. Then, Gradle will build once. After that, a bubble at the top-right corner will appear indicating a successful APK generation.
Click "Show in explorer", copy the generated APK and move it to your connected device. Then, go on your device>Your File Manager>The APK you just moved. Click it and install the application. There you have it.
There is no way for you to run without a Gradle build, and you're not the only one who thinks it is utterly STUPID for a force rebuild every time you want to build an APK or run an app with no changes since the last build.
I use this method to install the generated APK to the device using bash script since I'm working on Linux(didn't try this on windows or os x).
When you run the app in the android studio the run tab will print out the commands which android studio uses to install the app on the device.
I just copy these commands into a file and save it as run.sh
run.sh
#!/bin/sh
adb push /home/gautam/sample/app/build/outputs/apk/debug/app-debug.apk /data/local/tmp/com.example.sample.sample
adb shell pm install -t -r "/data/local/tmp/com.example.sample.sample"
adb shell am start -n "com.example.sample.sample/com.example.sample.sample.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
save the file in you project directory(although you can keep it any where).also add it to you gitignore if you need. Then open you terminal in android studio and run the script file to install the APK.
chmod a+x run.sh
./run.sh
This will install the apk to the connected device. If more then one device are connected the script will throw error in which case you will have to provide the device id refer this.
Hope this helps.
Generate apk (gradle build)
Select generated apk in the project tree
Right-click to .apk -> install APK
via plugin: install apk
Actually you can.
Just create a new Run/Debug configuration (Edit configuration on the drop down list on the left of the "Run" arrow). Then remove "Gradle-aware Make" in the "Before launch" section of your configuration.
To run this configuration you need to have an existing APK generated otherwise it doesn't work, as this new configuration will just install the existing one.)
For people who use Flutter, Do as the following instruction.
Connect your Android device to your computer with a USB cable.
Enter cd where is your application directory.
Run flutter install.
Flutter: Install an APK on a device
There's a much easier way now.
Windows:
To install an App that you you have the APK file for:
Start the Device Emulator.
Drag the .apk file onto the emulator.
EOL
In Android Studio 2.2 there is a new property "build cache". To install it you open gradle.properties file of your project and add there:
android.enableBuildCache=true
like described here
And if you have no changes, your gradle will build in few seconds.
EDIT: Description of Build Cache from here:
Android Studio 2.2 Beta 3 introduces a new build cache feature that can speed up build times (including full builds, incremental builds, and instant run) by storing and reusing files/directories that were created in previous builds of the same or different Android project.
In other words, Build Cache reuses unchanged files rather then rebuild them.
If you haven't changed anything on your files and it's not the first time you run the app on the device, you can navigate to the app on your device and open it from there. If your device is connected to your computer, you would still be able to access logcat of the app.
If the modifications you've done is on an existing file, like the layout or .java file or any file that already exist, you can simply click on the apply changes button which is besides the run button as shown:
The apply changes button to the right of the run button in android studio
works with android 3.0.1 and later.
If you've added any new resources or created a new java file or new activity, the you must run from scratch to rebuild the hgradle.
Just create new configuration "install" with Launch Options -> Launch: Nothing
I have a problem with AVD. If I launch it from eclipse, load well but doesn't appear in screen. After that, I try it from terminal but I got the "Segmentation fault" message. Reading another topic I read that it is problem with 20 version of android SDK and to fix it, I should try: .../tools/emulator-arm #nameAVD. It works.
But I still have a problem, I need launch AVD from eclipse to debug applications! Can somebody help me?
Thak you a lot.
Can you tell us a bit more about your system, build, and what version of Android/Eclipse you are using?
if not, try uninstalling and re-installing eclipse, but use the Eclipse Classic version from http://www.eclipse.org/downloads/
then if it doesn't work still, try to delete and redownload the android SDK.
if that still doesn't work then chances are you have something wrong with your system settings
======================
EDIT*** here is a possible TEMPORARY solution..
only use Eclipse to clean/Build your projects, and use your terminal to install your app onto your emulator.
to build an APK without running, right click on your project, go to "Android Tools" and hit "Export Unsigned Package", which will prompt you to store the APK on to some place. Then, open up your AVD emulator and terminal. on your terminal, "cd" into the directory that you saved your APK file (like inside /...../Your Project/bin/) and then run the terminal command "adb install yourAPKfileName.apk"
this will automatically install the newest APK to your emulator and run it. since this process for building is a little slower than usual, i would recommend only building/running when you need to, and always export the APK to the same place, and have your terminal open to the same place, so that when you press "up" on the terminal, it repeats the last command you used :)
I have made application in Netbeans7.1.2 .
my application working perfectly in emulator which is configured android 2.1 but after copying bin folder in Android device(tablet) that gives error "Application not installed".
what is this problem plz if someone know about this ?
Copying bin/ folder is not sufficient enough to warrant an install.
You can do it this way:
Use the Android's SDK tool called adb to install it directly on to the device. For example, suppose your package-name in your project is called org.foo.bar.app and an apk file is generated and called foobar.apk (This will be found in the bin/) folder typically, or where you specify Eclipse to generate the apk, via from within Eclipse:
Right click on project
Click on Android Tools
Click on Export the unsigned Application Package
OR
Click on Export Signed Application Package.
Then:
Plug in cable to device, and issue the command from within Windows Cmd or Linux Terminal, in this manner, adb install foobar.apk
To uninstall an app from the device, specify the package-name, like this adb uninstall org.foo.bar.app