I'm a newbie in React-native. In the first project. I init react project with command line react-native init <project name>
This environment:
nodejs: v4.5.0, npm: 4.1.2 and ANDROID_HOME.
When I run adb device
But when I run project react-native run-android
I try run command line adb reverse tcp:8081 tcp:8081 but it not working.
Who can tell me fix this error. Thanks
Install Android SDK v23 should resolve your problem.
Update answer:
Android API 23 I installed but when I install Android SDK Build-tool
23.0.1 it's working while Android SDK Build-tool 23.0.2 or 23.0.3 not working
Because 23.0.1 is the default SDK version for a React Native project. I don't know how to modify this but if you want to see the build version, checkout this file android/app/build.gradle. You would see a section with following content:
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
}
Did you enable developer options on your phone? if not check this line: enable developer options on android device
You need to install the Android build tools via Android Studio.
Open Android Studio
Go to Tools > Android > SDK Manager
Click "Launch Standalone SDK Manager" at the bottom of the window
Find the referenced package and check it (see below)
Click "Install packages..."
Agree to the licences
You should then be able to build onto the device.
Related
I am trying to figure out if all the methods to create a build using expo must go through EAS (Expo Application Services) since apparently they limit the free tier to 30 builds per month.
Can I build the web-app locally without an EAS account / 100% for free?
The documentation isn't clear to me.
I do not have enough rep to comment so I will ask here and edit/delete later.
Have you tried building your application manually using android studio / xcode? You should be able to generate a build folder for both platforms and open that folder with android studio or xcode, make, build and run the project to test.
For android:
Step 1: install OpenJDK
Step 2: install android studio
Step 3: CD in your application folder and locate package.json.
Step 4: Run npm android in the same directory where package.json is located
This should open up android studio for you in the same directory and you can start debugging there with the android studio built in emulator. You can also build an APK of your application and install it to your device or connect your mobile device to android studi via wifi pairing and install the application on your android.
According to this video, using eas build --local should do the trick
I created my app in react native using Expo but when i run the npm start command its showing me this:
running metro bundler on port 8081
and then
loading dependency graph, done
and never end. what to do?
Here is the complete console output.
First of all if you have a bundler like the one that you have used then it would suggest that you have used react-native init to create you application, instead of expo.
Expo bunders look like this:
If you have created a react-native init and as it suggests in your screenshot that you are building the app on a Windows machine, that means you will be developing on Android.
The instructions for using Android and running react-native are quite long and complicated, they can be found here. For the sake of brevity I am not going to repeat them here asyou can just follow this link. Make sure to choose Building Projects with Native Code -> Development OS: Windows -> Target OS: Android to find the instructions that are pertinent to your situation.
https://facebook.github.io/react-native/docs/getting-started.html
If you are planning on developing on an emulator then you will need to make sure that you have one installed (the link above has all the info that you need). Also you need to make sure that you launch your emulator before running react-native run-android if you do that then it should load on to the emulator and you should be able to see what you are developing on.
If you want to run on your own Android device then you should follow the instructions on this page https://facebook.github.io/react-native/docs/running-on-device (again choosing the options for your situation).
Expo
If this feels like too much effort, you can always try Expo. It doesn't require you to be able to deal with native code. And depending on your use case can be a better option than creating a project with react-native init, plus you can always eject from the expo project and turn it in to a full fledged react-native app.
You install the expo-cli with
npm install -g expo-cli
Then download the expo app from the App Store or the Google Play Store (depending on the mobile that you are using).
Then you can use
expo init
to create your application
Check out the expo documentation for more information https://docs.expo.io/versions/v32.0.0/workflow/up-and-running
Well, Nice question, First of all, I totally understand what's exactly your problem is, let me give you a solution in a very appropriate way.
Basically, there is two way to install and setup React Native Project on your mac and windows machines
1st React Native (native) Method: (That's basically you're using right know
Note: If you're using Apple product - Like MacBook then you can do IOS and Android both platform by using this method, if you're using Windows or Linux you can only do this part for Android platforms
In this method, we have to follow these simple steps
Download Nodejs from Offical website link here
Installing the React Native Cli
npm install -g react-native-cli
If you get an error like Cannot find module 'npmlog', try installing npm directly: curl -0 -L https://npmjs.org/install.sh | sudo sh.
(Only for mac)
Install the Xcode from Appstore (Only for Mac user/macos users)
otherwise
download and install the Android Studio (Stable version) from the official website of Android studio
Setup Xcode (Simulator) or Setup Android Studio for Android devices use (emulator)
by learn and guide from this link here
Note: Basically in your scenario, I'm pretty sure you didn't set up your emulator for android and simulator for IOS that's why you didn't see anything after
2nd React Native with Expo Method: that's you're not using a loading dependency graph
Use
For Android
react-native run-android
For IOS
react-native run-ios
2nd React Native without Expo (that's not your case):
In this method, we have to follow these simple steps
Download Nodejs from Offical website link here
installing expo cli
npm install -g expo-cli
expo init yourprojectname
cd yourprojectname
npm start
Note: Simulators and emulators way same for both
This is my first time setting up react native on Ubuntu 18.04 LTS. I have done the setup and I was trying to run the app on the device using the react-native run-android command.
Here is the output what I get in terminal,
ron#lenovo:~/react/app$ react-native run-android
Scanning folders for symlinks in /home/ron/react/app/node_modules (9ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Starting a Gradle Daemon, 1 busy Daemon could not be reused, use --status for details
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /home/ron/Android/Sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
File /home/ron/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Build-Tools 26.0.3 in /home/ron/Android/Sdk/licenses
License for package Android SDK Build-Tools 26.0.3 accepted.
Preparing "Install Android SDK Build-Tools 26.0.3 (revision: 26.0.3)".
<=============> 100% CONFIGURING
> IDLE
It stays in this IDLE position forever. What is the fix or this issue?
The solution is to install Android SDK rev. 26.0.3. Your can install it from Android Studio's SDK Manager menu in File > Settings. Hope this helps.
I got the same error today. The solution is to create a file named local.properties and write in it this line:
sdk.dir=[the position of android sdk]
example:
sdk.dir=N\:\\Users\\andy\\AppData\\Local\\Android\\Sdk
you can get the sdk android via android studio: Android Studio - How to Change Android SDK Path
hope this will help you and other people out there who just begin learning react native.
iam using genymotion emulator to run react native on mac,
react-native-cli: 2.0.1
react-native: 0.53.0
node:v8.9.4
while i running react-native run-android i got error like this
...
.....
Installing APK 'app-debug.apk' on 'GNexus5623 - 6.0' for app:debug
11:17:39 E/DeviceMonitor: Adb connection Error:EOF
11:17:39 E/DeviceMonitor: Connection attempts: 1
Installed on 1 device.
BUILD SUCCESSFUL
Total time: 14.691 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
Starting the app (/Users/yan/Library/Android/sdk/platform-tools/adb shell am start -n com.vero/com.vero.MainActivity...
error: no devices/emulators found
does anyone give me solution, thanks
this worked for me (For debian based systems only), make sure you have configured genymotion to use your android Sdk by:
Open Genymotion
Click on the settings icon
go to ADB tab
Click on use Custom Sdk tools.
navigate to the folder you downloaded
and then add this to your .bashrc
export PATH=/home/{username}/Android/Sdk/tools:/home/{username}/Android/Sdk/platform-tools:$PATH
$ ionic run android --device
Running command: "C:\Program Files\nodejs\node.exe" C:\Users\user\Desktop\transroads\jvdappNew\jvdApp\hooks\after_prepare\010_add_platform_class.js C:/Users/user/Desktop/transroads/jvdappNew/jvdApp
add to body class: platform-android
ERROR running one or more of the platforms: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
You may not have the required environment or OS to run this project.
It was working properly but when i updated my Android Studio there is installed another SDK also now i am having two SDK in the ANDROID_HOME path those are SDK and SDK1. SDK is having API23 and SDK1 API24.
whenever i am running command "ionic run android --device" terminal always shows that error i have discuss above.
Before update of Android Studio everything was working properly but after the update i am unable to run ionic application on my mobile device.ANDROID_HOME path is C:\Users\user\AppData\Local\Android\sdk; and i am having SDK1 folder also after the Android Studios updation on that location.
AVD Manager.exe and SDK Manager.exe those files are only in SDK and SDK1 having nothing like that.Please help me out of this.
Anyone please tell me both the platform can run over a SDK Manager?
You need to update your cordova android platform. Basically the older version till 6.2.0 used android command which is deprecated in the SDK.This was patched in 6.2.0
Check this answer for more info.
Update your cordova cli first:
npm install -g cordova#latest
You can update to the latest platform by doing:
ionic platform add android#6.2.3
Or
ionic platform add android#latest
For IONIC CLI v3 the command is:
ionic cordova platform add android#latest