首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android主项目build.gradle中的插件部分和缺少的模块

Android主项目build.gradle中的插件部分和缺少的模块
EN

Stack Overflow用户
提问于 2020-01-12 04:28:01
回答 2查看 1.4K关注 0票数 0
  1. 我得到以下错误:

在56s错误中生成失败: Plugin id:'de.undercouch.download‘在以下任何一个来源中都找不到:

  • Gradle Core插件(插件不在'org.gradle‘命名空间中)-插件库(插件依赖关系必须包括此源的版本号)

我想知道这个插件部分。

我正在看下面的指南:

Android级插件

但是它是零碎的,我希望看到完整的build.gradle文件示例。

  1. 如何在"/nbproject"中集成以下内容

/@react-native-community/cli-platform-android/native_modules.gradle

我所能看到的只有路径中的以下文件夹:

代码语言:javascript
复制
/@react-native-community/cli
  1. 缺少react-native-unimodules in /nbproject。在这篇文章的末尾是我的settings.gradle:那么我应该使用什么命令而不是:

npm install

代码语言:javascript
复制
//apply from: "../../node_modules/react-native-unimodules/gradle.groovy"
apply from: "/Users/lion/Documents/Project/ReactNative/Libraries/rn_mac_kitchensync/node_modules/react-native-unimodules/gradle.groovy"
include ':react-native-screens'
project(':react-native-screens').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-screens/android')
include ':react-native-reanimated'
project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
//==
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
//
include ':ReactAndroid'
//
project(':ReactAndroid').projectDir = new File(
        rootProject.projectDir, '../node_modules/react-native/ReactAndroid')
//
includeUnimodulesProjects()
//includeUnimodules([
//        modulesPaths: ['../../node_modules']
//])

rootProject.name = 'NativebaseKitchenSink'

include ':app'
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-01-12 10:25:08

关于第1点,我碰巧在path中学习了build.gradle,在这里我可以看到缺失插件的条目:

"/node_modules/react-native/ReactAndroid"

这个声明存在于我的settings.gradle中:

代码语言:javascript
复制
//
include ':ReactAndroid'
//
project(':ReactAndroid').projectDir = new File(
        rootProject.projectDir, '../node_modules/react-native/ReactAndroid')
//

在我的主要项目的build.gradle中,我指出:

代码语言:javascript
复制
plugins {
    id "de.undercouch.download" version "4.0.2"
}

以上allprojects {}部分。

在依赖关系类路径部分中使用此方法,而不是上面的内容:

代码语言:javascript
复制
//noinspection GradleDependency
classpath 'de.undercouch:gradle-download-task:4.0.0'

但我认为它不是在调用之后生成的:

代码语言:javascript
复制
npm install

在删除了"/nbproject"目录之后,我不得不再次调用这个命令。

关于第2点:请按照链接:

GIT:响应android平台的本地社区

他们说它是可选的,不再使用。请参阅ReadMe:

反应本地社区: ReadMe

此外,请确保您使用的是最新版本的ReactNative:

package.json:

代码语言:javascript
复制
{
  "name": "NativebaseKitchenSink",
  "version": "2.12.0",
  "private": true,
  "devDependencies": {
    "babel-eslint": "7.2.3",
    "eslint": "4.4.1",
    "eslint-plugin-flowtype": "2.35.0",
    "eslint-plugin-import": "2.7.0",
    "eslint-plugin-jsx-a11y": "6.0.2",
    "eslint-plugin-prettier": "2.1.2",
    "eslint-plugin-react": "7.1.0",
    "eslint-plugin-react-native": "3.0.1",
    "flow-bin": "0.78.0",
    "flow-typed": "2.5.1",
    "husky": "0.14.3",
    "jest": "24.1.0",
    "metro-react-native-babel-preset": "0.52.0",
    "prettier": "1.5.3",
    "react-test-renderer": "16.6.3"
  },
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "postinstall": "jetify",
    "and_bundle": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res"
  },
  "jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
      "node_modules/(?!(react-native|lottie-react-native|expo|react-native-maps|react-native-svg|react-native-branch|native-base-shoutem-theme|react-native-easy-grid|react-native-drawer|react-native-vector-icons|react-native-keyboard-aware-scroll-view|react-native-swiper|react-navigation|native-base|@expo|react-native-scrollable-tab-view|react-native-simple-modal|react-native-iphone-x-helper)/)"
    ]
  },
  "dependencies": {
    "color": "1.0.3",
    "expo": "^35.0.0",
    "expo-cli": "^3.4.1",
    "lodash": "4.17.10",
    "moment": "2.13.0",
    "native-base": "2.12.1",
    "prop-types": "^15.6.2",
    "react": "16.9.0",
    "react-base": "^0.2.0",
    "react-native-new": "0.61.5",
    "react-native": "0.59.10",
    "react-native-gesture-handler": "^1.0.15",
    "react-native-vector-icons": "^6.3.0",
    "react-navigation": "3.3.0",
    "scheduler": "^0.12.0",
    "styled-components": "^3.4.5"
  }
}

关于第3点:

来自此模块的ReadMe文件:

反应-自然-单模 这个库包含核心的Unimodule基础设施以及其他Unimodules通常依赖的Unimodules和接口的集合。在使用基金会的库(如expo-cameraexpo-media-library和其他库)之前,您需要安装这些库。 注意:react-native-unimodules 与React Native0.60.x还不兼容. 安装 最简单的方法是使用expo-cli使用expo init --template bare-minimum初始化一个“裸”项目。 如果您有一个现有的应用程序,您可以执行以下步骤。此项目要求您在iOS上使用CocoaPods来设置它,请参阅这个要旨本指南的相关部分。 安装软件包 bash npm安装反应-本机-单模

因此,使用react本机: 0.59.10而不是最新的。

票数 0
EN

Stack Overflow用户

发布于 2020-01-12 07:17:26

插件。这个块通常属于顶部,但也可能发生在build.gradle的底部。在Android中,使用apply plugin: "de.undercouch.download"apply from: "..."相当常见。对于Gradle插件,repositoriesclasspath总是需要在buildscript块中定义。通常情况下,它至少是2个build.gradle,并且在GitHub上有一些例子。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59700923

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档