简体   繁体   中英

Plugins section in Android main project build.gradle and missing modules

  1. I get the following error:

BUILD FAILED in 56s ERROR: Plugin [id: 'de.undercouch.download'] was not found in any of the following sources:

 - Gradle Core Plugins (plugin is not in 'org.gradle' namespace) - Plugin Repositories (plugin dependency must include a version number for this source)

I want to know about this plugins section.

I am looking in the following guide:

Plugins in Android Gradle

But it is in bits and pieces and I want to see complete example of build.gradle file.


  1. How to integrate the following in "/nbproject" :

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

all I can see is the following folder in the path:

/@react-native-community/cli

  1. Missing react-native-unimodules in /nbproject . At the end of this post is my settings.gradle: So what command I should use instead of:

npm install


//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'

See plugins . This block usually belongs to top, but also may occur at the bottom of the build.gradle . With Android DSL it rather common to use apply plugin: "de.undercouch.download" or apply from: "..." . For Gradle plugins the repositories and classpath always needs to defined in the buildscript block. Usually it's at least 2 build.gradle and there are examples on GitHub.

For point 1. I just happened to study build.gradle in path where I could see the entry for the missing plugins:

"/node_modules/react-native/ReactAndroid"

This declaration was there in my settings.gradle:

//
include ':ReactAndroid'
//
project(':ReactAndroid').projectDir = new File(
        rootProject.projectDir, '../node_modules/react-native/ReactAndroid')
//

In my main project's build.gradle I put:

plugins {
    id "de.undercouch.download" version "4.0.2"
}

above allprojects {} section.

Rather than above, use this in your dependencies class path section:

//noinspection GradleDependency
classpath 'de.undercouch:gradle-download-task:4.0.0'

But I think it was not generated after calling:

npm install

I had to call this command again after deleting my "/nbproject" directory.


For points 2 : Please follow the link:

GIT: React Native Community for android platform

They say it is optional and no longer used. See the ReadMe:

React Native Community: ReadMe

Also please make sure you are using latest version of ReactNative:

package.json:

{
  "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"
  }
}

For point 3:

From a ReadMe file for this module:

react-native-unimodules

This library contains the core Unimodule infrastructure and a collection of Unimodules and interfaces that are commonly depended on by other Unimodules. You will need to install this before using libraries from Foundation, like expo-camera , expo-media-library , and others.

Note: react-native-unimodules are not compatible with React Native 0.60.x yet.

Installation

The easiest way to do this is to initialize a "bare" project with expo-cli using expo init --template bare-minimum .

If you have an existing app, you can follow these steps instead. This project requires that you use CocoaPods on iOS , to set it up see this gist , or relevant parts of the this guide .

Install the package

bash npm install react-native-unimodules

Hence use react-native: 0.59.10 instead of the latest.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM