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.
Related
So I have an App almost finished, which uses a json file located in the documents path of my android device (using the path_provide package). I know that this file will get deleted as soon as I uninstall the app on my phone. For installing the app onto my phone I want to use the command line flutter install (I'm on Windows). So if I add more features to my app and flutter install again on my android, will it update the device leaving the documents directory just as it is or will it delete that and completely reinstall the app?
I don't think that it's going to delete the app and the file.
I found a solution: If you don't already have it installed, then install ADB and on Windows you then must add the folder with ADB to your Path environment variable, so you can easily access it through cmd on Windows (I don't really know about the other platforms). Then you have to create your APK (for example with flutter build apk --split-per-abi) and then run adb install /path/to/your/apk/file.apk.
Source: mannprerak2's comment on this Github issue https://github.com/flutter/flutter/issues/40560
While trying to test the android app am creating with React native, I run into this error
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
I have the emulator(the AMD version) installed in the android studio.
How can I solve this problem
In your scenario before running react native application you need to create emulator using Android Studio. You can view official documentation about running application on device by here
Before running your project make sure you have installed adb drivers - More
First of all create AVD using Android Studio.
Open your project android folder using Android Studio.
1. Click AVD Manager from Android Studio
2. Click Create Virtual Device
3. Select your device from device list and click Next
4. Select the android os version from the available version list and click Next
5. On last keep default settings on device and click Finish
After that you can see your available android emulator device list from AVD Manager window.
* Before run your react native application make sure you have turn on and run the android emulator from android studio
After that run your project using react-native run-android
You can run the command adb devices to check if there is any device attached. It should list atleast one device for it to work
This also may be there is not enough space to run avd, make sure enoug space in hard disk. in my case freed atlest 9gb.
My answer is, If you have changed the directory of avds, you should set ANDROID_SDK_HOME environment variable to the parent directory of .android.
Here is the detail:
It seems like when you run "emulator -list-avds" in cmd, the result is empty. (be sure to first add "ANDROID_HOME" with value of your sdk directory to your user environment variable, and "%ANDROID_HOME%\emulator" in the Path too.)
After checking the official documents:
https://developer.android.com/studio/run/emulator-commandline#starting
It said:
"$ emulator -list-avds
When you use this option, it displays a list of AVD names from your Android home directory. Note that you can override the default home directory by setting the ANDROID_SDK_HOME environment variable: the root of the user-specific directory where all configuration and AVD content is stored. You could set the environment variable in the terminal window before launching a virtual device, or you could set it through your user settings in the operating system."
and in another page:
https://developer.android.com/studio/command-line/variables#envar
it said:
"Some older tools, such as Android Studio 4.3 and below, do not read ANDROID_USER_HOME. To override the user preferences location for those older tools set ANDROID_SDK_HOME to the parent directory you would like the .android directory to be created under."
So I guess the reason is "npx react-native run-android" will invoke "emulator -list-avds" to find the emulator. And "emulator" is really an older tools, so ANDROID_SDK_HOME environment variable is necessay.
And if all goes well, you really don't need to run android studio before run "npx reactive-native run-android".
while installing Android studio SDK in ubuntu 14.04, 64 bit using the wizard; I encountered this error
The following SDK components were not installed: sys-img-x86-addon-google_apis-google-21 and tools
It occurred during "Downloading Google APIs Intel x86 Atom System Image, API 21, revision3"
Can someone please help me where the possible error is.
This solution helped me on Ubuntu 20.04 when I already installed the AS, but couldnt install packages in AVD Manager when I wanted to create a virtual device for the emulator, getting a very similar error. Maybe this will help in your case:
Delete the .downloadIntermediates/ directory from your SDK location /.../Android/Sdk/ (usually the path starts in your home folder).
From what I understood, this folder contains logs for your downloads,
and if something goes wrong, this can stop AS from
resuming/downloading new things properly. Don't worry about deleting,
this folder will recreate itself automatically and it doesnt affect
the program
How to delete it via the console:
Open your terminal, go to your sdk folder, if it's a default location in home folder the command is as follows:
cd Android/Sdk
Then check if the folder ".downloadIntermediates/" exists. Run this command and look for it in the list:
ls -la
If it's there, then proceed with removing it:
rm -r .downloadIntermediates
Now you can run the "ls -la" again to see if it is removed successfully.
Launch Android Studio again. Now try installing all the packages you need, they should install with no errors. Hope this helps in your case! :) And in any case, if nothing else works, an uninstall and clean install can be a good idea.
I am using Android Studio with Ubuntu and it won't create AVDs. Nothing gets created in my ~/.android/avd directory. Instead things are getting created in my /root directory. Which I guess I wouldn't care about, except of course it can't run the emulator for these AVDs if the AVDs are in my root folder. I think it's because for the Android SDK manager to be accessed in Linux, Android Studio has to be run with sudo...but then it puts the AVDs in root instead of home...
I have a few pics outlining this problem very clearly, but stackoverflow won't let me even link to them without 10 rep, what a nuisance of a restriction.
EDIT: Here is the error I get in my terminal when I try to execute the android bash script located in /opt/android-studio/sdk/tools/. It's the same error whether or not Android Studio is open or not.
ss108 tools$ bash android
java.lang.NullPointerException
at java.io.File.<init>(File.java:277)
at com.android.sdklib.internal.avd.AvdManager.parseAvdInfo(AvdManager.java:1516)
at com.android.sdklib.internal.avd.AvdManager.buildAvdList(AvdManager.java:1492)
at com.android.sdklib.internal.avd.AvdManager.<init>(AvdManager.java:346)
at com.android.sdklib.internal.avd.AvdManager.getInstance(AvdManager.java:369)
at com.android.sdklib.internal.repository.updater.UpdaterData.initSdk(UpdaterData.java:252)
at com.android.sdklib.internal.repository.updater.UpdaterData.<init>(UpdaterData.java:120)
at com.android.sdkuilib.internal.repository.SwtUpdaterData.<init>(SwtUpdaterData.java:61)
at com.android.sdkuilib.internal.repository.ui.SdkUpdaterWindowImpl2.<init>(SdkUpdaterWindowImpl2.java:104)
at com.android.sdkuilib.repository.SdkUpdaterWindow.<init>(SdkUpdaterWindow.java:88)
at com.android.sdkmanager.Main.showSdkManagerWindow(Main.java:407)
at com.android.sdkmanager.Main.doAction(Main.java:390)
at com.android.sdkmanager.Main.run(Main.java:150)
at com.android.sdkmanager.Main.main(Main.java:116)
The AVDs are created under /root because you are starting Android Studio with sudo. You need to configure the permissions so that this isn't required. The simplest solution that I have found is to install Android Studio and the Android SDK as my regular user. I install these into $HOME/bin so that I don't have to bother with permission issues at all. When everything is installed, my regular user account has execute permission for all the files I need.
Alternatively, you can use chmod (either manually or with find) to set the permissions on Android Studio and Android SDK files.
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