React Native Error when `run-android` - react-native

I installed all dependencies and libs like the instructions on https://facebook.github.io/react-native/docs/getting-started.html
Everything is fine.
But when i try to run react-native run-android i throws me errors (see screenshot)
HAXM is installed on my machine as well.
What can i do to run it on my machine in the emulator?
SDK:

"SDK location no found" export/add your sdk location path in PATH variable. For linux maching run following command in terminal:
$ export PATH="/Users/<username>/Library/Android/sdk/platform-tools/:$PATH"
$ react-native run-android

Go to your project android folder. And create a file called "local.properties".
Inside this file write this:
"sdk.dir={sdk_location}"
Just replace {skd_location} with the path to your android sdk.
Then run "react-native run-android" again and it should work.

The error simply specifies that you are not providing the sdk path to you project. So for this you need to create a local.properties file inside your android folder of the project. Inside that local.properties file just add the location for your android SDK as below :-
sdk.dir = /Users/piet/Library/Android/sdk //this is your sdk path
I have provided the path from the screenshot given by you but change the path of your android SDK if it is different.

Related

How to create react native wrappers for native android and iOS SDKs

I am creating a React Native module as a wrapper for existing Android and iOS libraries. The Android library is a jar file and the iOS library is xcframework file. I put the xcframework file inside the ios folder, and the jar file inside android/libs folder ( I created the libs folder). I first tried the iOS library by adding s.preserve_path, s.xcconfig and s.vendored_framework inside the project level podspec file. I am not sure if I need to do anything for the pod spec file, like running it. So I just went along with the next step by trying to import the library's .h in .m file. I tried both using angle brackets <> and using quotes "". But none worked, because firing "react-native run-is" gave me this error: fatal error: file not found. Any help on how to include the libraries in react native is greatly appreciated.
For creating react native wrapper or node module you need use below library.
https://www.npmjs.com/package/react-native-create-library
https://github.com/brodybits/create-react-native-module
Using this library you can create empty react native module project after that you can bind your native code ARR or framework files into that project.
I was able to fix the error by doing the following two steps:
Change "s.vendored_framework" to "s.vendored_frameworks" in the project level .podspec file. My original one is singular (framework), not plural (frameworks).
cd iOS && pod install && cd ..
Step 2 can be found in create-react-native-module's GitHub link:
https://github.com/brodybits/create-react-native-module
I missed the second step when posting my question. I thought then that if I ran "react-native run-ios", it would run "pod install".

React native android emulator: could not create task ':realm:compileDebugJavaWithJavac'

I have macbook M1 and trying to run Android emulator. When I run a command to launch the emulator I get the errorsCould not create task ':realm:compileDebugJavaWithJavac'.
Could not create task ':realm:forwardDebugPort'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/.../btp-react-native-field-data-capture/android/local.properties'.
I don't have this file and what do I need to add there?
Thanks
I ran into the same issue, but was able to resolve by creating a new file named "local.properties" in my android folder.
You just need to add the following line.
sdk.dir = /Users/YOUR_MAC_USERNAME/Library/Android/sdk
Reference below.
React Native android build failed. SDK location not found

React Native Multiple command produce same file

I tried to build a react native app for iOS and I hit this error:
Build system information
error: Multiple commands produce '/Volumes/Data/sources/react-native/test/ios/build/test/Build/Products/Debug-iphonesimulator/test.app/Zocial.ttf':
1) Target 'test' (project 'test') has copy command from '/Volumes/Data/sources/react-native/test/node_modules/react-native-vector-icons/Fonts/Zocial.ttf' to '/Volumes/Data/sources/react-native/test/ios/build/test/Build/Products/Debug-iphonesimulator/test.app/Zocial.ttf'
2) That command depends on command in Target 'test' (project 'test'): script phase “[CP] Copy Pods Resources”
You can try deleting the build folder in ios directory and rebuilding your app again. It might solve this issue
It looks like you have installed some library with fonts that iOS don't have linked. Try this:
Create an empty dir in your project to store some future useful fonts (for example "Nunito" family font). I suggest create fonts folder into assets --> assets/fonts
Create a new file named react-native.config.js in the root of your project and add into it the following:
module.exports = {
project: {
ios: {},
android: {}
},
assets: ['./src/assets/fonts/'],
};
In your project dir run react-native link
Go to ios dir (cd ios) and run pod update
Build
Especial thanks to Alex Biddle: https://medium.com/better-programming/how-to-add-custom-fonts-to-your-react-native-project-c64305281b9
I had this error with react-native-vector-icons installed after I executed react-native link. My solution was to remove fonts copying from XCode Build Phases.

The SDK directory 'C:\Users\ABC\AppData\Local\Android\Sdk\platform-tools;C:\Users\ABC\AppData\Local\Android\Sdk' does not exist

Could somebody help me fix this problem?
When I run react-native run-android in CMD Windows OS, I got this error.
A problem occurred configuring project ':app'.
The SDK directory 'C:\Users\ABC\AppData\Local\Android\Sdk\platform-tools;C:\Users\ABC\AppData\Local\Android\Sdk' does not exist.
I searched everything to fix it but not successful.
I created local.properties in android dir and add this: sdk.dir = C:\\Users\\ABC\\AppData\\Local\\Android\\Sdk
Create ANDROID_HOME variable: C:\Users\ABC\AppData\Local\Android\Sdk and add to path: ...%ANDROID_HOME%platforms;%ANDROID_HOME%platform-tools
but no luck.
Please help.
You can also set android path from CMD.
set ANDROID_HOME=C:\Users\yourusername\AppData\Local\Android\sdk
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
Note: You have to run these two commands every time you open new instance of your CMD
If you have the same error even after configuring the environment variables like the above answer, Check the local.properties file. Most probably there can be different ANDROID_HOME path.
local.properties file located in the android folder of the react native code base.
After installing of Android studio you need run it first and create your device. (i don't remember how but it helped for me)Untill this done you not have android folder. To watch my suggestion open C:\Users\yourusername\AppData\Local
and go to your Local folder
mark 'View/show-hide/hidden items' in as on the pictures.
Then open android studio, and create android device.And you will see how hidden android folder have appeared(can be seen if hidden items marked)

react-native-maps iOS error

Trying to add airbnb/react-native-maps to my react native project and follow the guide at https://github.com/airbnb/react-native-maps/blob/master/docs/installation.md. Option 1,
Option 1: Cocoapods - Same as the included AirMapsExplorer example
Setup your Podfile like the included example/ios/Podfile then run pod install. (If you do not need GoogleMaps support for iOS, then you can probably completely skip this step.)
Open your project in xCode workspace
Drag the following folder into your project:
node_modules/react-native-maps/ios/AirMaps/
If you need GoogleMaps support also drag this folder into your project:
node_modules/react-native-maps/ios/AirGoogleMaps/
After done, I cannot run the project in Xcode, it gives the error, 'RCTImageLoader.h' file not found.
I hv tried run rnpm link and it cannot go through,
rnpm-link info Android module react-native-maps is already linked
rnpm-link info Linking react-native-maps ios dependency
rnpm-link ERR! It seems something went wrong while linking. Error: ENOENT: no such file or directory, open '/Users/nedved/Desktop/NativeCreditcard_office/node_modules/react-native-maps/ios/AirGoogleMaps.xcodeproj/project.pbxproj'
Please file an issue here: https://github.com/rnpm/rnpm/issues
I can find the file /Users/XXXX/node_modules/react-native-maps/ios/AirGoogleMaps.xcodeproj locally, but when clicking, "Project /Users/XXXX/node_modules/react-native-maps/ios/AirGoogleMaps.xcodeproj cannot be opened because it is missing its project.pbxproj file."
Any idea?