首页 > 解决方案 > 无法在本机反应中制作签名的 apk

问题描述

在尝试使用链接 生成签名 APK为我的 react-native 项目制作签名 apk时,出现以下错误。

Unable to resolve module `./touchables` from `C:\Users\pc\Desktop\GSTCalc\node_modules\react-native-gesture-handler\index.js`: The module `./touchables` could not be found from `C:\Users\pc\Desktop\GSTCalc\node_modules\react-native-gesture-handler\index.js`. Indeed, none of these files exist:   * `C:\Users\pc\Desktop\GSTCalc\node_modules\react-native-gesture-handler\touchables(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
* `C:\Users\pc\Desktop\GSTCalc\node_modules\react-native-gesture-handler\touchables\index(.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:\Users\pc\Desktop\GSTCalc\node_modules\react-native-gesture-handler\index.js`: The module `./touchables` could not be found from `C:\Users\pc\Desktop\GSTCalc\node_modules\react-native-gesture-handler\index.js`. Indeed, none of these files exist:   * `C:\Users\pc\Desktop\GSTCalc\node_modules\react-native-gesture-handler\touchables(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
* `C:\Users\pc\Desktop\GSTCalc\node_modules\react-native-gesture-handler\touchables\index(.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:\Users\pc\Desktop\GSTCalc\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:120:15)
    at ResolutionRequest.resolveDependency (C:\Users\pc\Desktop\GSTCalc\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:49:18)
    at DependencyGraph.resolveDependency (C:\Users\pc\Desktop\GSTCalc\node_modules\metro\src\node-haste\DependencyGraph.js:218:16)
    at Object.resolve (C:\Users\pc\Desktop\GSTCalc\node_modules\metro\src\lib\transformHelpers.js:141:30)
    at dependencies.map.result (C:\Users\pc\Desktop\GSTCalc\node_modules\metro\src\DeltaBundler\traverseDependencies.js:373:31)
    at Array.map (<anonymous>)
    at resolveDependencies (C:\Users\pc\Desktop\GSTCalc\node_modules\metro\src\DeltaBundler\traverseDependencies.js:369:18)
    at C:\Users\pc\Desktop\GSTCalc\node_modules\metro\src\DeltaBundler\traverseDependencies.js:188:33
    at Generator.next (<anonymous>)
    at step (C:\Users\pc\Desktop\GSTCalc\node_modules\metro\src\DeltaBundler\traverseDependencies.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\GSTAppDesign\GSTCalc\android\app\build\generated\assets\react\release\index.android.bundle bundle:完成编写 bundle 输出 bundle:复制 7 个资产文件 bundle:完成复制资产

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\GSTAppDesign\GSTCalc\android\app\build\intermediates\incremental\mergeReleaseResources\merged.dir\values-v28\values-v28.xml:11: AAPT: 错误: 资源 android:attr/未找到对话框角半径。

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。

错误:链接引用失败。

标签: androidreact-nativesigned-apk

解决方案


我认为你收到错误是因为你已经安装react-navigation了你的 react native 项目,你还必须安装下面的包。

尝试安装

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%\Temp\react-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

希望这对你有用,对我有用


推荐阅读