",android,react-native,npm"/>

首页 > 解决方案 > 用另一个组件替换了一个组件,构建失败并出现错误“无法解析项目"

问题描述

我正在使用 react-native-webview-file-upload-android 但我想用 react-native-webview-android 替换它。

我运行了以下内容:

npm uninstall react-native-webview-file-upload-android
npm install --save react-native-webview-android
npm link react-native-webview-android

我将 app.js 中的导入从

import AndroidWebView from 'react-native-webview-file-upload-android';

import WebViewAndroid from 'react-native-webview-android';

现在,当我尝试 npm run android 时,会发生此错误:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not resolve project :react-native-webview-file-upload-android.
     Required by:
         project :app
      > Unable to find a matching configuration of project :react-native-webview-file-upload-android: None of the consumable configurations have attributes.

我试过 了npm start --clear-cache,,,cd android && gradlew cleannpm unlink react-native-webview-file-upload-android

但是它们都不起作用,为什么旧​​包仍然在这里出错?

标签: androidreact-nativenpm

解决方案


我找到了解决方案,在我的android/app/build.gradleandMainApplication.java中,旧包仍在导入中,所以我删除了导入行并且它有效


推荐阅读