我将通过本教程开始学习ReactNative:https://openclassrooms.com/fr/courses/4902061-developpez-une-application-mobile-react-native
一切正常,但是当我们将应用程序转换为本地应用程序时,我无法在android上进行编译。
react-native run-android
时总是出现此错误:
error: bundling failed: Invariant Violation: invalid asset resolution
at invariant (C:\laragon\www\React\SampleReactNativeProject\node_modules\invariant\invariant.js:40:15)
at ModuleResolver._getFileResolvedModule (C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:224:9)
at ModuleResolver.resolveDependency (C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:159:19)
at ResolutionRequest.resolveDependency (C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:52:18)
at DependencyGraph.resolveDependency (C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\node-haste\DependencyGraph.js:283:16)
at Object.resolve (C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\lib\transformHelpers.js:261:42)
at dependencies.map.result (C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\DeltaBundler\traverseDependencies.js:399:31)
at Array.map (<anonymous>)
at resolveDependencies (C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\DeltaBundler\traverseDependencies.js:396:18)
at C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\DeltaBundler\traverseDependencies.js:269:33
并在电话上显示它:
这是我的代码:https://gitlab.com/baltus.remi/moviesandme
我已经尝试重新安装所有环境,等等。 如果我运行android un basic react-native应用程序,它的运行就像一个魅力...
感谢您的帮助!
答案 0 :(得分:0)
尝试删除该应用。然后清理项目,运行cd android && ./gradlew clean
然后返回到根目录cd。
然后再次进行调试构建react-native run-android或脚本中的命令
在大多数情况下,如果添加了新软件包,则必须执行这些步骤。