我正在尝试从源代码构建 React Native 以使用我对其相机胶卷功能所做的一些更改。我已经按照指南进行了操作,但是在尝试编译整个内容时遇到了一些彻头彻尾的神秘错误。
这是整堆:
[armeabi-v7a] Compile++ thumb: yogacore <= Utils.cpp
[armeabi-v7a] Compile++ thumb: yogacore <= YGEnums.cpp
[armeabi-v7a] Compile++ thumb: yogacore <= YGNodePrint.cpp
[armeabi-v7a] Compile++ thumb: yogacore <= YGNode.cpp
[armeabi-v7a] Compile++ thumb: yogacore <= Yoga.cpp
C:/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/../ReactCommon/yoga/yoga/YGEnums.cpp:228:1: fatal error: opening dependency file C:\Users\jon-g\OneDrive\Documents\GitHub\kulaapp\node_modules\react-native\ReactAndroid\build\tmp\buildReactNdkLib/local/armeabi-v7a/objs/yogacore/C_/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/__/ReactCommon/yoga/yoga/YGEnums.o.d: No such file or directory
}
^
compilation terminated.
make.exe: *** [C:\Users\jon-g\OneDrive\Documents\GitHub\kulaapp\node_modules\react-native\ReactAndroid\build\tmp\buildReactNdkLib/local/armeabi-v7a/objs/yogacore/C_/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/__/ReactCommon/yoga/yoga/YGEnums.o] Error 1
make.exe: *** Waiting for unfinished jobs....
[armeabi-v7a] StaticLibrary : libreactnative.a
C:/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/../ReactCommon/yoga/yoga/YGNodePrint.cpp:227:1: fatal error: opening dependency file C:\Users\jon-g\OneDrive\Documents\GitHub\kulaapp\node_modules\react-native\ReactAndroid\build\tmp\buildReactNdkLib/local/armeabi-v7a/objs/yogacore/C_/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/__/ReactCommon/yoga/yoga/YGNodePrint.o.d: No such file or directory
} // namespace facebook
^
compilation terminated.
make.exe: *** [C:\Users\jon-g\OneDrive\Documents\GitHub\kulaapp\node_modules\react-native\ReactAndroid\build\tmp\buildReactNdkLib/local/armeabi-v7a/objs/yogacore/C_/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/__/ReactCommon/yoga/yoga/YGNodePrint.o] Error 1
C:/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/../ReactCommon/yoga/yoga/Utils.cpp:31:1: fatal error: opening dependency file C:\Users\jon-g\OneDrive\Documents\GitHub\kulaapp\node_modules\react-native\ReactAndroid\build\tmp\buildReactNdkLib/local/armeabi-v7a/objs/yogacore/C_/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/__/ReactCommon/yoga/yoga/Utils.o.d: No such file or directory
}
^
compilation terminated.
make.exe: *** [C:\Users\jon-g\OneDrive\Documents\GitHub\kulaapp\node_modules\react-native\ReactAndroid\build\tmp\buildReactNdkLib/local/armeabi-v7a/objs/yogacore/C_/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/__/ReactCommon/yoga/yoga/Utils.o] Error 1
C:/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/../ReactCommon/yoga/yoga/YGNode.cpp:668:1: fatal error: opening dependency file C:\Users\jon-g\OneDrive\Documents\GitHub\kulaapp\node_modules\react-native\ReactAndroid\build\tmp\buildReactNdkLib/local/armeabi-v7a/objs/yogacore/C_/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/__/ReactCommon/yoga/yoga/YGNode.o.d: No such file or directory
}
^
compilation terminated.
make.exe: *** [C:\Users\jon-g\OneDrive\Documents\GitHub\kulaapp\node_modules\react-native\ReactAndroid\build\tmp\buildReactNdkLib/local/armeabi-v7a/objs/yogacore/C_/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/__/ReactCommon/yoga/yoga/YGNode.o] Error 1
C:/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/../ReactCommon/yoga/yoga/Yoga.cpp:3493:1: fatal error: opening dependency file C:\Users\jon-g\OneDrive\Documents\GitHub\kulaapp\node_modules\react-native\ReactAndroid\build\tmp\buildReactNdkLib/local/armeabi-v7a/objs/yogacore/C_/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/__/ReactCommon/yoga/yoga/Yoga.o.d: No such file or directory
}
^
compilation terminated.
make.exe: *** [C:\Users\jon-g\OneDrive\Documents\GitHub\kulaapp\node_modules\react-native\ReactAndroid\build\tmp\buildReactNdkLib/local/armeabi-v7a/objs/yogacore/C_/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/__/ReactCommon/yoga/yoga/Yoga.o] Error 1
make.exe: Leaving directory `C:/Users/jon-g/OneDrive/Documents/GitHub/kulaapp/node_modules/react-native/ReactAndroid/src/main/jni/react/jni'
:ReactAndroid:buildReactNdkLib FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ReactAndroid:buildReactNdkLib'.
> Process 'command 'C:\Users\jon-g\AppData\Local\Android\Ndk\android-ndk-r10e\ndk-build.cmd'' finished with non-zero exit value 2
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
这些对我来说都没有多大意义。这些文件路径完全是荒谬的。
为什么会这样?我如何得到这个编译?
最佳答案
在 Podfile
中添加以下内容:(引用:facebook/yoga#711)
def fix_cplusplus_header_compiler_error
filepath = '../node_modules/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceSizeMeasureMode.h'
contents = []
file = File.open(filepath, 'r')
file.each_line do | line |
contents << line
end
file.close
if contents[32].include? "&"
contents.insert(26, "#ifdef __cplusplus")
contents[36] = "#endif"
file = File.open(filepath, 'w') do |f|
f.puts(contents)
end
end
end
def fix_unused_yoga_headers
filepath = './Pods/Target Support Files/yoga/yoga-umbrella.h'
contents = []
file = File.open(filepath, 'r')
file.each_line do | line |
contents << line
end
file.close
if contents[12].include? "Utils.h"
contents.delete_at(15) # #import "YGNode.h"
contents.delete_at(15) # #import "YGNodePrint.h"
contents.delete_at(15) # #import "Yoga-internal.h"
contents.delete_at(12) # #import "Utils.h"
file = File.open(filepath, 'w') do |f|
f.puts(contents)
end
end
end
def react_native_fix
fix_cplusplus_header_compiler_error
fix_unused_yoga_headers
end
post_install do |installer|
react_native_fix
end
并修改
package.json
修复鱼钩错误:(引用:facebook/react-native#16039)"scripts": {
"postinstall": "sed -i '' 's/#import <fishhook\\/fishhook.h>/#import <React\\/fishhook.h>/' ./node_modules/react-native/Libraries/WebSocket/RCTReconnectingWebSocket.m"
}
相关公关:
facebook/react-native#18492 .
关于react-native - 从源代码构建 React Native 的 Yoga 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48460743/