Compiling react-native project in android - react-native

when I try to compile my project in RN 0.35 using my terminal I receive this error:
What went wrong:
Could not list contents of '/MyProject/node_modules/.bin/detect-newline'. Couldn't follow symbolic link.
Any help?
UPDATED
Seems that the cli.js file was missed in the detect-newline folder.
I created a new project and then I have copied the cli.js file, after that everything worked fine.

Related

react-native build failed, 'native_modules.gradle' line: 182

I init a new project using react native 0.61.2 , using react-native init proj command, after that when I try to react-native run-android, the build fails with this error :
FAILURE: Build failed with an exception.
Where:Script '..\node_modules#react-native-community\cli-platform-android\native_modules.gradle' line: 182
What went wrong:
A problem occurred evaluating script.
Unable to determine the current character, it is not a string, number, array, or object
The current character read is 'D' with an int value of 68
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
as i mentioned, it's a fresh project.
any idea how to fix this ?
I ran into the same issue today and noticed that react recently released new versions to react-native and react.
I downgraded to versions i know work properly which are:
"react": "~16.8.0",
"react-native": "~0.60.0"
cleared all cache and the project loads correctly.
in order to do so change the dependencies in your package.json file
then delete your node_modules directory, package.lock file and run npm cache clean
finally run npm i
perhaps there are still issues in the new releases.
I am aslo facing the same issue. Downgrading works, however i have two other projects that r working fine and they are react native 0.61.2
Only new projects are giving this error. I read in some blogs that removing react community cli from global and trying again might do the trick.
Will try that tomorrow and post my findings.
Look for mistakes in your AndroidManifest.xml!!!
For me, I solved this by replacing the character ” with "
(And also read some people telling that unclosed tags did that too)
As dumb as it looks, I got to this error from following a tutorial.
(tip: VS code would often show these quotes in different colors, unless you have installed another XML files extension)
I ran into the same issue in a fresh project with RN 0.64.0. The project was created inside a monorepo that was using Yarn workspaces. In my case, Yarn had moved or "hoisted" the #react-native-community/cli-platform-android/native_modules.gradle file to the root node_modules directory.
The Android project's settings.gradle and build.gradle files are expecting the #react-native-community/cli-platform-android/native_modules.gradle file to be in the RN project's node_modules directory and not the repo's root node_modules directory.
Try updating line 2 of settings.gradle to something like:
apply from: file("../../../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
And line 222 of build.gradle to something like:
apply from: file("../../../../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
Obviously, you will need to adjust how many leading ../ you add to the path depending on how nested your project is.
You could also look into using the nohoist options available with Yarn to keep packages from moving around.

Problem when linking react-native-vector-icons

I just started a new react-native project from zero, added react-native-vector-icons, but when i try to link it, I get the following, I have no idea why this is happening, I didn't change anything, it's a clen project.
error Something went wrong while linking. Error: ENOENT: no such file or directory, copyfile 'PROJECTFOLDER/node_modules/react-native-vector-icons/Fonts/AntDesign.ttf' -> 'D:\Codes\ReactNative\KosTimer\android\app\src\main\assets\fonts\AntDesign.ttf'
Please file an issue here: https://github.com/react-native-community/react-native-cli/issues
error ENOENT: no such file or directory, copyfile 'PROJECTFOLDER/node_modules/react-native-vector-icons/Fonts/AntDesign.ttf' -> 'D:\Codes\ReactNative\KosTimer\android\app\src\main\assets\fonts\AntDesign.ttf'
Because of this error, all my icons appear with a X inside a square
*PROJECTFOLDER is the place where is my project
The issue is caused by a missing assets/fonts folder inside the android project.
To solve the issue create an assets folder in your project.
Then inside that folder create a folder called fonts.
This is what should have:
<project root>/android/app/src/main/assets/fonts
If you want to do with one command, you can open a terminal at your project root and type:
For mac:
mkdir -p ./android/app/src/main/assets/fonts
For windows:
mkdir ./android/app/src/main/assets/fonts
Then you should be able to link the dependency as normal.

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?

Copied Xcode Project won't build

OS X Version 10.10.5
Xcode version 7.2.1
Very simple steps, yet Xcode can't fathom what to do when you duplicate a folder that contains an Xcode project.
Start with Xcode CLOSED.
Start with an Xcode project that builds and runs perfectly.
Go to Finder window and right click on the directory that contains the buildable Xcode project and hit "Duplicate"
New directory is created, called "SomeProject copy"
Go into this new directory and double-click on the SomeProject.xcodeproj file to open it in Xcode.
Bam... enjoy your build errors.
In my case, it's complaining about an enum.
Tried deleting derived data folder (did so directly using finder)
Tried super-cleaning the build folder by holding down the option key.
Tried removing and re-adding complained about file that contains errors.
Tried changing path to file in Xcode File Inspector from "Relative To Group" to "Absolute Path"
I should also point out that either Finder -> Duplicate doesn't actually do what it says it does. Neither does Finder -> Copy, ~OR~ Xcode for some reason has now adopted not only the original source location as where to get its build files, but also the new location, hence the "Redefinition" error. I noticed that if I open the "copied" project and edit a file, then go back to my original project in an entirely different folder, the file is changed THERE.
And my paths (according to Xcode File Inspector), are RELATIVE TO THE PROJECT IN QUESTION. So in other words, ProjectAAA's files are pointed to the path under ProjectAAA's directory, and the same with copied project, ProjectBBB's files.
So somehow, the copy/duplicate is refusing to actually copy/duplicate.
Any ideas how to solve this?
Per John Elemans comment, moving my original project then revealed in the copied Xcode project a number of build paths and issues that needed resolving. I fixed those, and it worked as expected.
I solved this issue as follows:
After duplicating the root folder of the project, open the podfile of the duplicated project:
Podfile
then comment all the previously added pods by adding "#":
Commented Pods
hit CTRL + S in order to save the changes
Open the terminal and change the directory to the folder of the duplicated project and then perform: "pod install". Yes it will delete all the pods but don't worry we will install again in the next step
Pods deletion
Open again podfile and uncomment the previously commented pods:
Uncommented pods
hit CTRL + S to save the changes
Open the terminal and change the directory to the folder of the duplicated project and then perform "pod install". it will install again all the pods:
Pods installation
Finally, run the Project and it should run without any problem.