问题描述
我正在通过向 android
下的 gradle.properties
添加 2 行代码来解决与 AndroidX 相关的不兼容问题.
I am fixing a incompatibility issue related to AndroidX by adding 2 lines to gradle.properties
under android
for my RN 0.59 project.
android.useAndroidX=true
android.enableJetifier=true
现在有另一个与 react-native-gesture-handler
相关的 run-android
错误.然后我 yarn remove
1.2.0
的当前 react-native-gesture-handler
并将其添加回来.新版本是1.3.0
.这是错误:
Now there is another error with run-android
related to react-native-gesture-handler
. Then I yarn remove
the current react-native-gesture-handler
of 1.2.0
and add it back. The new version is 1.3.0
. Here is the error:
> Task :react-native-gesture-handler:compileDebugJavaWithJavac
C:\D\code\js\emps_app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEvent.java:3: error: package android.support.v4.util does not exist
import android.support.v4.util.Pools;
^
C:\D\code\js\emps_app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEvent.java:19: error: package Pools does not exist
private static final Pools.SynchronizedPool<RNGestureHandlerEvent> EVENTS_POOL =
^
C:\D\code\js\emps_app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerStateChangeEvent.java:3: error: package android.support.v4.util does not exist
import android.support.v4.util.Pools;
^
C:\D\code\js\emps_app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerStateChangeEvent.java:19: error: package Pools does not exist
private static final Pools.SynchronizedPool<RNGestureHandlerStateChangeEvent> EVENTS_POOL =
^
C:\D\code\js\emps_app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEvent.java:20: error: package Pools does not exist
new Pools.SynchronizedPool<>(TOUCH_EVENTS_POOL_SIZE);
^
C:\D\code\js\emps_app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerStateChangeEvent.java:20: error: package Pools does not exist
new Pools.SynchronizedPool<>(TOUCH_EVENTS_POOL_SIZE);
^
Note: C:\D\code\js\emps_app\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerButtonViewManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
6 errors
> Task :react-native-gesture-handler:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
该错误与 6 个软件包丢失有关,我猜它仍然与 Androidx 有关.但我不知道如何解决它.有一个问题帖子(对于 RN-gesture-handler)建议降级到 1.0.5
版本进行修复,但我不想使用这么旧的版本.
The error is related 6 packages missing and I guess it is still related to Androidx. But I have no clue how to fix it. There is an issue post (for RN-gesture-handler) suggesting downgraded to version 1.0.5
for fixing but I wouldn't like to use such an old version.
推荐答案
它导致 RN 0.60
出现此错误.您可以通过以下方式解决此问题,
It cause this error for the RN 0.60
.You can solve this by following,
npm i jetifier
npx jetify
在 RN 0.60
上为我修复了它.
fixed it for me on RN 0.60
.
祝您有美好的一天.
这篇关于任务 ':react-native-gesture-handler:compileDebugJavaWithJavac' 执行失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!