android - 新依赖 React native - gradle clean - 无法解析所有依赖

标签 android gradle react-native build.gradle

我最近在我的 react-native 项目中添加了一个库。在添加此依赖项之前,该项目运行良好。但是,当我尝试尝试通过 react-native run-android 运行它时我收到此错误:

File C:\Users\user\.android\repositories.cfg could not be loaded.

FAILURE: Build failed with an exception.

* What went wrong: 
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
   > Could not find com.onesignal:OneSignal:23.0.1.
     Required by:
         project :app
   > Could not find com.onesignal:OneSignal:23.0.1.
     Required by:
         project :app > project :react-native-onesignal

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1 mins 57.711 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

编辑: android 模拟器当然正在运行。
在做了一些研究之后,我发现我可以尝试 npm 卸载和安装,但没有成功。在 build.gradle 中,我指定了我的 onesignal_app_id 和 compile 'com.onesignal:OneSignal:23.0.1'在依赖项下。因此,我尝试了 gradle clean ,它产生了这个错误:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-onesignal'.
      > Failed to notify project evaluation listener.
         > com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED in 1s

最佳答案

我对 Cordova 也有类似的问题。

我通过从 2.2.3 更改 gradle 版本来修复至2.3.3 .

在oneliner下面:

sed -i -E 's/com.android.tools.build:gradle:2.2.[0-9]+/com.android.tools.build:gradle:2.3.3/g' build.gradle

关于android - 新依赖 React native - gradle clean - 无法解析所有依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45045619/

相关文章:

java - Gradle获取父目录的文件集合

react-native - 重新排序 Flatlist 中的项目

ios - 如何在react native中实现 "View slide-in"的效果?

android - 如何在没有互联网连接的情况下与服务器通信?

Android:在 fragment 之间传递一个 JSONobject

Android: Dex 在运行 androidTest 时无法解析 52 字节代码(Espresso 测试)

Android Circle Gradle 警告 : The build VMs have a memory limit of 4G

android - android studio更新后Gradle Sync不刷新项目

java - 尝试将 Intent 转移到另一个适配器时应用程序崩溃

react-native - Formik handleChange - 使用钩子(Hook)