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

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

Related

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 Error when `run-android`

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.

Calabash Android run error: The first parameter must be the path to the apk file

I am trying to run sample calabash-android test. But I am facing the below error.
C:\Ruby23\TMSampleAndroid-master>calabash-android run TestmunkTest_debug.apk --verbose
The first parameter must be the path to the apk file.
Consider the following:
Separate the project directory from your Ruby23 installation by moving the calabash project inside a Workspace folder for example.
Create a folder to hold your .apk inside the calabash project, for example "APKFile"
In the run command specify the full path to the .apk file and see if it runs, like this:
calabash-android run
C:\Ruby23\TMSampleAndroid-master\TestmunkTest_debug.apk
or for my example:
calabash-android run
C:\Workspace\TMSampleAndroid-master\TestmunkTest_debug.apk
To add logging write "--verbose" after the command. The error that you get might be because of the typo "--v erbose"

ERROR:offline js file is empty

hai in my react native project structure is like this:
Project
• Ios
• Project
• Base.Iproj
• Images.xcassets
• AppDelegate.h
• AppDelegate.m
• Info.plist
• Main.jsbundle
• Main.m
• Project.xcodeproj
• ProjectTests
• Index.ios.js
• Package.json
when i need to run i ma getting error like this Error:Offline js file is empty. see ios/main.jsbundle for instructions
but the main.jsbundile file is in ios/Project/main.jsbundle,
can any one help me how to avoid this error
This is not a linking problem. This is a problem with the main.jsbundle in your iOS application project folder not updating. If you open the existing main.jsbundle it just throws an error, which is what you're seeing on your device.
To fix this create a new main.jsbundle.
From your React project's root (/Project), run the following command in a Terminal shell: react-native bundle --minify. If run successfully it will create a new main.jsbundle and drop it in /Project/iOS/.
Replace the existing main.jsbundle in /Project/iOS/Project with the one created in /Project/iOS/
(Having to do this manually is frustrating and should be automated, or fixed within the React Native script)
Clean, build and re-run the app and it should load on the device.
More from FB on how to run your app on a device:
https://facebook.github.io/react-native/docs/running-on-device-ios.html