伙计们
我正在尝试安装反应本机复活,但我不断收到此错误。
C:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasandroidappsrcmainjavacomtrackerMainApplication.java:17: error: cannot find symbol
import com.swmansion.reanimated.ReanimatedJSIModulePackage;
^
symbol: class ReanimatedJSIModulePackage
location: package com.swmansion.reanimated
C:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasandroidappsrcmainjavacomtrackerMainApplication.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:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modulesreact-native-cameraandroidsrcmainjavacomgoogleandroidcameraviewCamera2.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modules@react-native-communityasync-storageandroidsrcmainjavacomreactnativecommunityasyncstorageAsyncStorageModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modulesreact-native-gesture-handlerandroidsrcmainjavacomswmansiongesturehandlerreactRNGestureHandlerButtonViewManager.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:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modulesreact-native-geolocation-serviceandroidsrcmainjavacomagontukRNFusedLocationLocationUtils.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:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modulesreact-native-reanimatedandroidsrcmainjavacomswmansionreanimatedNodesManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modulesreact-native-reanimatedandroidsrcmainjavacomswmansionreanimatedNodesManager.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:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasandroidappsrcmainjavacomtrackerMainApplication.java:17: error: cannot find symbol
import com.swmansion.reanimated.ReanimatedJSIModulePackage;
^
symbol: class ReanimatedJSIModulePackage
location: package com.swmansion.reanimated
C:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasandroidappsrcmainjavacomtrackerMainApplication.java:45: error: cannot find symbol
return new ReanimatedJSIModulePackage();
^
symbol: class ReanimatedJSIModulePackage
Note: C:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasandroidappsrcdebugjavacomtrackerReactNativeFlipper.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:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modulesreact-native-cameraandroidsrcmainjavacomgoogleandroidcameraviewCamera2.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modules@react-native-communityasync-storageandroidsrcmainjavacomreactnativecommunityasyncstorageAsyncStorageModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modulesreact-native-gesture-handlerandroidsrcmainjavacomswmansiongesturehandlerreactRNGestureHandlerButtonViewManager.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:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modulesreact-native-geolocation-serviceandroidsrcmainjavacomagontukRNFusedLocationLocationUtils.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:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modulesreact-native-reanimatedandroidsrcmainjavacomswmansionreanimatedNodesManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modulesreact-native-reanimatedandroidsrcmainjavacomswmansionreanimatedNodesManager.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:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasandroidappsrcmainjavacomtrackerMainApplication.java:17: error: cannot find symbol
import com.swmansion.reanimated.ReanimatedJSIModulePackage;
^
symbol: class ReanimatedJSIModulePackage
location: package com.swmansion.reanimated
C:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasandroidappsrcmainjavacomtrackerMainApplication.java:45: error: cannot find symbol
return new ReanimatedJSIModulePackage();
^
symbol: class ReanimatedJSIModulePackage
Note: C:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasandroidappsrcdebugjavacomtrackerReactNativeFlipper.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:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modulesexecaindex.js:174:9)
at C:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modulesexecaindex.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (C:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modules@react-native-communitycli-platform-androidbuildcommandsrunAndroidrunOnAllDevices.js:94:5)
at async Command.handleAction (C:UsersdanilojldeoDesktopMeuGithubcontrole-de-pragasnode_modules@react-native-communityclibuildindex.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();
}
}
}
}
这是我安装反应原生复活的步骤 -> https://docs.swmansion.com/react-native-reanimated/docs/installation/在此安装文档中,它说我必须安装它
yarn add react-native-reanimated@alpha
但是,实际上,我正在尝试安装,以便我可以将其与createDrawerNavigator(反应导航5(和反应本机手势处理程序一起使用,所以我也按照这些步骤 https://reactnavigation.org/docs/getting-started 安装。在此文档中,它安装了反应本机复活,而不是反应本机reanimated@alpha。 如果我安装 react-native-reanimated@alpha,项目构建正常!但后来我收到这个错误,我用创建抽屉导航器创建抽屉导航器的另一个问题中发布 |未定义不是函数 但是,如果我安装了 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-realive,而不是执行文档显示的手动步骤。 似乎在那里它显示了 react-native-reanimated@alpha(版本 2.x.x(的步骤,看起来它仍然无法正常工作,特别是使用 createDrawerNavigation。
yarn add react-native-reanimated@alpha //NO
yarn add react-native-reanimated //YES
当我用yarn add react-native-reanimated@next
安装它时,我遇到了同样的错误,因为尚未指定要安装的特定版本。
通过运行npm ls react-native-reanimated@nextnpm
您可以选择要安装的版本,例如对我来说最新的版本是 2.0.0-rc.3。清理和重建项目。