在尝试使用链接对我的react原生项目进行签名apk时生成签名的APK我得到以下错误。
Unable to resolve module `./touchables` from `C:UserspcDesktopGSTCalcnode_modulesreact-native-gesture-handlerindex.js`: The module `./touchables` could not be found from `C:UserspcDesktopGSTCalcnode_modulesreact-native-gesture-handlerindex.js`. Indeed, none of these files exist: * `C:UserspcDesktopGSTCalcnode_modulesreact-native-gesture-handlertouchables(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
* `C:UserspcDesktopGSTCalcnode_modulesreact-native-gesture-handlertouchablesindex(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
Error: Unable to resolve module `./touchables` from `C:UserspcDesktopGSTCalcnode_modulesreact-native-gesture-handlerindex.js`: The module `./touchables` could not be found from `C:UserspcDesktopGSTCalcnode_modulesreact-native-gesture-handlerindex.js`. Indeed, none of these files exist: * `C:UserspcDesktopGSTCalcnode_modulesreact-native-gesture-handlertouchables(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
* `C:UserspcDesktopGSTCalcnode_modulesreact-native-gesture-handlertouchablesindex(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
at ModuleResolver.resolveDependency (C:UserspcDesktopGSTCalcnode_modulesmetrosrcnode-hasteDependencyGraphModuleResolution.js:120:15)
at ResolutionRequest.resolveDependency (C:UserspcDesktopGSTCalcnode_modulesmetrosrcnode-hasteDependencyGraphResolutionRequest.js:49:18)
at DependencyGraph.resolveDependency (C:UserspcDesktopGSTCalcnode_modulesmetrosrcnode-hasteDependencyGraph.js:218:16)
at Object.resolve (C:UserspcDesktopGSTCalcnode_modulesmetrosrclibtransformHelpers.js:141:30)
at dependencies.map.result (C:UserspcDesktopGSTCalcnode_modulesmetrosrcDeltaBundlertraverseDependencies.js:373:31)
at Array.map (<anonymous>)
at resolveDependencies (C:UserspcDesktopGSTCalcnode_modulesmetrosrcDeltaBundlertraverseDependencies.js:369:18)
at C:UserspcDesktopGSTCalcnode_modulesmetrosrcDeltaBundlertraverseDependencies.js:188:33
at Generator.next (<anonymous>)
at step (C:UserspcDesktopGSTCalcnode_modulesmetrosrcDeltaBundlertraverseDependencies.js:298:30)
我该怎么办?提前谢谢。
Edit:
When I tried all the solution provided below I started getting a different
error.Which is as follows:
bundle: Writing bundle output to:
C:\Users\pc\Desktop\GSAppDesign\GSTCalc\android\app\build\generated\assets\areact\release\index.android.bundlebundle:完成编写bundle输出bundle:复制7个资产文件捆绑:完成复制资产
C: \Users\pc.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\2e72d58316ce557e86b0d638298e5052\res\values-v28\values-v28.xml:9:5-12:13:AAPT:错误:找不到资源android:attr/dialogCornerRadius。
C: \Users\pc\Desktop\GSAppDesign\GSTCalc\android\app\build\intermediates\incremental\mergeReleaseResources\merge.dir\values-v28\values-v28.xml:11:AAPT:错误:找不到资源android:attr/dialogCornerRadius。
C: \Users\pc.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\2e72d58316ce557e86b0d638298e5052\res\values\values.xml:1304:5-69:AAPT:错误:找不到资源android:attr/fontVariationSettings。
C: \Users\pc.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\2e72d58316ce557e86b0d638298e5052\res\values\values.xml:1304:5-69:AAPT:错误:找不到资源android:attr/ttcIndex。
错误:链接引用失败。
我认为您遇到了错误,因为您在react原生项目中安装了react-navigation
,因此您还必须安装以下软件包。
尝试安装
npm i --save react-native-gesture-handler
react-native link react-native-gesture-handler
尝试这个来清除和重置缓存:
RN < 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
npm >= 5 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
Windows - del %appdata%Tempreact-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache
https://gist.github.com/jarretmoses/c2e4786fd342b3444f3bc6beff32098d
希望这对你有效,对我有效
在构建签名的APK之前,首先确保您的捆绑包位于android文件夹中的资产中。
运行此命令以构建捆绑包
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
此外,为手势处理程序添加此包
npm install -save react-native-gesture-handler