我知道很多相关问题已经问过,但仍然没有一个有效。
错误:
> Configure project :react-native-firebase_firestore
:react-native-firebase_firestore package.json found at /home/username/StudioProjects/agl-admin/node_modules/@react-native-firebase/firestore/package.json......
> Task :app:compileDebugJavaWithJavac FAILED
/home/username/StudioProjects/agl-admin/android/app/src/main/java/com/agladmin/MainApplication.java:12: error: cannot find symbol
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
^
symbol: class RNGestureHandlerPackage
location: package com.swmansion.gesturehandler.react
/home/username/StudioProjects/agl-admin/android/app/src/main/java/com/agladmin/MainApplication.java:49: error: cannot find symbol
packages.add(new RNGestureHandlerPackage());
^
symbol: class RNGestureHandlerPackage
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
....
最匹配的问题:“com.swmansion.gesturehandler.react”出现错误
package.json
{
"name": "agl-admin",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "expo start --dev-client",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web"
},
"dependencies": {
"@expo-google-fonts/poppins": "^0.2.2",
"@react-native-firebase/app": "^14.5.1",
"@react-native-firebase/firestore": "^14.5.1",
"@react-navigation/drawer": "^6.3.1",
"@react-navigation/native": "^6.0.8",
"@react-navigation/stack": "^6.1.1",
"expo": "~44.0.2",
"expo-app-loading": "^1.3.0",
"expo-font": "~10.0.4",
"expo-splash-screen": "~0.14.1",
"expo-status-bar": "~1.2.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-gesture-handler": "^2.3.2",
"react-native-paper": "^4.11.2",
"react-native-reanimated": "^2.4.1",
"react-native-safe-area-context": "3.3.2",
"react-native-screens": "~3.10.1",
"react-native-splash-screen": "^3.3.0",
"react-native-web": "0.17.1",
"react-navigation": "^4.4.4"
},
"devDependencies": {
"@babel/core": "^7.12.9"
},
"private": true
}
我有什么:
在 android\settings.gradle
include ':react-native....
这两个已经在那里了
在
MainAplication.java
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
已经在那里
并且 new RNGestureHandlerPackage() List
不存在,所以我添加了。
rm -rf node_modules
npm cache clean --force
./gradlew clean
然后全部重新安装。
================更新================
我通过 React 降级到
"react-native-gesture-handler": "~2.1.3"
来修复它
和静态缓存。 T
在新版本(RNGH 2)中你必须删除
.react
,所以它只是import com.swmansion.gesturehandler.RNGestureHandlerPackage;
!
确保添加了
react-native-reanimated
插件到 babel.config.js
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: ['react-native-reanimated/plugin'],
};
删除node_modules文件夹
删除package-lock.json
npm i
or
npm i --legacy-peer-deps
cd android
./gradlew clean