gpt4 book ai didi

reactjs - MainApplication.java 中的 React-Native-Reanimated 错误

转载 作者:行者123 更新时间:2023-12-05 01:35:54 63 4
gpt4 key购买 nike

伙计们

我正在尝试安装 react-native-reanimated,但我一直收到此错误。

C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\android\app\src\main\java\com\tracker\MainApplication.java:17: error: cannot find symbol
import com.swmansion.reanimated.ReanimatedJSIModulePackage;
^
symbol: class ReanimatedJSIModulePackage
location: package com.swmansion.reanimated
C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\android\app\src\main\java\com\tracker\MainApplication.java:45: error: cannot find symbol
return new ReanimatedJSIModulePackage();
^

这是完整的错误日志

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1372 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...

> Task :@mauron85_react-native-background-geolocation-common:compileDebugJavaWithJavac

> Task :mauron85_react-native-background-geolocation:compileDebugJavaWithJavac

> Task :react-native-camera:compileGeneralDebugJavaWithJavac

> Task :react-native-community_async-storage:compileDebugJavaWithJavac

> Task :react-native-gesture-handler:compileDebugJavaWithJavac

> Task :react-native-geolocation-service:compileDebugJavaWithJavac

> Task :react-native-maps:compileDebugJavaWithJavac

> Task :react-native-reanimated:compileDebugJavaWithJavac

> Task :react-native-screens:compileDebugJavaWithJavac

> Task :app:compileDebugJavaWithJavac

> Task :app:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
210 actionable tasks: 210 executed
Note: Some input files use or override 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.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\node_modules\react-native-camera\android\src\main\java\com\google\android\cameraview\Camera2.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\node_modules\@react-native-community\async-storage\android\src\main\java\com\reactnativecommunity\asyncstorage\AsyncStorageModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\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.
Note: C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\node_modules\react-native-geolocation-service\android\src\main\java\com\agontuk\RNFusedLocation\LocationUtils.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override 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.
Note: C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\node_modules\react-native-reanimated\android\src\main\java\com\swmansion\reanimated\NodesManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\node_modules\react-native-reanimated\android\src\main\java\com\swmansion\reanimated\NodesManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override 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.
C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\android\app\src\main\java\com\tracker\MainApplication.java:17: error: cannot find symbol
import com.swmansion.reanimated.ReanimatedJSIModulePackage;
^
symbol: class ReanimatedJSIModulePackage
location: package com.swmansion.reanimated
C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\android\app\src\main\java\com\tracker\MainApplication.java:45: error: cannot find symbol
return new ReanimatedJSIModulePackage();
^
symbol: class ReanimatedJSIModulePackage
Note: C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\android\app\src\debug\java\com\tracker\ReactNativeFlipper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
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.

* Get more help at https://help.gradle.org

BUILD FAILED in 3m 12s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Note: Some input files use or override 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.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\node_modules\react-native-camera\android\src\main\java\com\google\android\cameraview\Camera2.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\node_modules\@react-native-community\async-storage\android\src\main\java\com\reactnativecommunity\asyncstorage\AsyncStorageModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\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.
Note: C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\node_modules\react-native-geolocation-service\android\src\main\java\com\agontuk\RNFusedLocation\LocationUtils.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override 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.
Note: C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\node_modules\react-native-reanimated\android\src\main\java\com\swmansion\reanimated\NodesManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\node_modules\react-native-reanimated\android\src\main\java\com\swmansion\reanimated\NodesManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override 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.
C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\android\app\src\main\java\com\tracker\MainApplication.java:17: error: cannot find symbol
import com.swmansion.reanimated.ReanimatedJSIModulePackage;
^
symbol: class ReanimatedJSIModulePackage
location: package com.swmansion.reanimated
C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\android\app\src\main\java\com\tracker\MainApplication.java:45: error: cannot find symbol
return new ReanimatedJSIModulePackage();
^
symbol: class ReanimatedJSIModulePackage
Note: C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\android\app\src\debug\java\com\tracker\ReactNativeFlipper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
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.

* Get more help at https://help.gradle.org

BUILD FAILED in 3m 12s

at makeError (C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\node_modules\execa\index.js:174:9)
at C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\node_modules\execa\index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pragas\node_modules\@react-native-community\cli\build\index.js:186:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

错误似乎在MainApplication.java,所以这里是文件代码:

package com.tracker;

import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.ocetnik.timer.BackgroundTimerPackage;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.bridge.JSIModulePackage;
import java.util.List;
import com.swmansion.reanimated.ReanimatedJSIModulePackage;

public class MainApplication extends Application implements ReactApplication {
static {
ReactFeatureFlags.useTurboModules = true;
}
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}

@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}

@Override
protected String getJSMainModuleName() {
return "index";
}
@Override
protected JSIModulePackage getJSIModulePackage() {
return new ReanimatedJSIModulePackage();
}
};

@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}

/**
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
*
* @param context
* @param reactInstanceManager
*/
private static void initializeFlipper(
Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.tracker.ReactNativeFlipper");
aClass
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
.invoke(null, context, reactInstanceManager);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}

这是我安装 react-native-reanimated 的步骤 -> https://docs.swmansion.com/react-native-reanimated/docs/installation/在此安装文档中,它说我必须安装它

yarn add react-native-reanimated@alpha

但是,实际上,我正在尝试安装,以便我可以将它与 createDrawerNavigator (react-navigation 5) 和 react-native-gesture 处理程序一起使用,所以我也按照这些步骤安装了 https://reactnavigation.org/docs/getting-started .在此文档中,它安装的是 react-native-reanimated,而不是 react-native-reanimated@alpha。如果我安装 react-native-reanimated@alpha,项目构建正常!但后来我收到了这个错误,我用 createDrawerNavigator createDrawerNavigator | undefined is not a function 在另一个问题中发布了这个错误但是,如果我安装 react-native-reanimated,项目不会构建,它会出现我在这个问题顶部所说的错误。我相信这两个错误是相关的。

有人可以帮帮我吗?

这里是项目依赖:

"dependencies": {
"@mauron85/react-native-background-geolocation": "^0.6.3",
"@react-native-community/async-storage": "^1.9.0",
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/drawer": "^5.8.2",
"@react-navigation/material-bottom-tabs": "^5.1.6",
"@react-navigation/native": "^5.5.1",
"@react-navigation/stack": "^5.0.6",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-action-button": "^2.8.5",
"react-native-animatable": "^1.3.3",
"react-native-background-timer": "^2.2.0",
"react-native-camera": "git+https://git@github.com/react-native-community/react-native-camera.git",
"react-native-geolocation-service": "^5.0.0",
"react-native-gesture-handler": "^1.6.1",
"react-native-linear-gradient": "^2.5.6",
"react-native-maps": "^0.27.1",
"react-native-paper": "^3.6.1",
"react-native-reanimated": "^1.9.0",
"react-native-safe-area-context": "^3.0.5",
"react-native-screens": "^2.9.0",
"react-native-vector-icons": "^6.6.0",
"rn-fetch-blob": "^0.12.0"
},

最佳答案

已修复!

我所要做的就是安装 react-native-reanimated 而不是执行文档显示的手动步骤。似乎那里显示了 react-native-reanimated@alpha 的步骤,(版本 2.x.x)看起来它仍然无法正常工作,特别是 createDrawerNavigation。

yarn add react-native-reanimated@alpha //NO
yarn add react-native-reanimated //YES

关于reactjs - MainApplication.java 中的 React-Native-Reanimated 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62514788/

63 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com