web-dev-qa-db-fra.com

React Natif Impossible de trouver une configuration de projet correspondante (version uniquement)

Ma version native de react fonctionne correctement lorsque vous exécutez react-native run-Android Ou cd Android && ./gradlew assembleDebug. Mais je vais obtenir le suivant pour tous les paquets natifs de réaction que j’ai installés lors de l’exécution de ./gradlew assembleRelease

> Could not resolve project :react-native-fbsdk.
     Required by:
         project :app
      > Unable to find a matching configuration of project :react-native-fbsdk:
          - Configuration 'debugApiElements':
              - Required com.Android.build.api.attributes.BuildTypeAttr 'releaseStaging' and found incompatible value 'debug'.
              - Required com.Android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Found com.Android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
              - Required org.gradle.api.attributes.Usage 'Java-runtime' and found incompatible value 'Java-api'.
          - Configuration 'debugRuntimeElements':
              - Required com.Android.build.api.attributes.BuildTypeAttr 'releaseStaging' and found incompatible value 'debug'.
              - Required com.Android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Found com.Android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
              - Required org.gradle.api.attributes.Usage 'Java-runtime' and found compatible value 'Java-runtime'.
          - Configuration 'releaseApiElements':
              - Required com.Android.build.api.attributes.BuildTypeAttr 'releaseStaging' and found incompatible value 'release'.
              - Required com.Android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Found com.Android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
              - Required org.gradle.api.attributes.Usage 'Java-runtime' and found incompatible value 'Java-api'.
          - Configuration 'releaseRuntimeElements':
              - Required com.Android.build.api.attributes.BuildTypeAttr 'releaseStaging' and found incompatible value 'release'.
              - Required com.Android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Found com.Android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
              - Required org.gradle.api.attributes.Usage 'Java-runtime' and found compatible value 'Java-runtime'.

Après avoir obtenu plus de détails en exécutant ./gradlew assembleRelease --info, J'ai constaté que ce message était imprimé pour tous mes paquets problématiques:

file or directory '/path/to/my/project/node_modules/react-native-fcm/Android/libs', not found

En regardant dans ce dossier, il n'y a pas de dossier "libs", et settings.gradle ne lui dit pas de pointer vers un dossier "libs".

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

Est-ce que quelque chose doit générer ce dossier? J'ai compile fileTree(dir: "libs", include: ["*.jar"]) dans mon application/build.gradle.

Pour référence, voici quelques fichiers importants:

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.Android.tools.build:gradle:3.0.0'
        classpath 'com.google.gms:google-services:3.1.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        configurations.all {
            resolutionStrategy {
                force 'com.facebook.Android:facebook-Android-sdk:4.28.0'
            }
        }
        maven {
            url "https://maven.google.com"
        }
        maven {
            url "https://jitpack.io"
        }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/Android"
        }
        google()
    }
}

app/build.gradle

apply plugin: "com.Android.application"

import com.Android.build.OutputFile

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.Android.bundle",
 *
 *   // the entry file for bundle generation
 *   entryFile: "index.Android.js",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.Android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in Android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in Android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["Android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-Push/Android/codepush.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

Android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        applicationId "com.gauge"
        minSdkVersion 16
        targetSdkVersion 26
        multiDexEnabled true
        versionCode 24
        versionName "1.2.9"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        debug {
            // Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.
            buildConfigField "String", "CODEPUSH_KEY", '""'
        }
        releaseStaging {
            minifyEnabled enableProguardInReleaseBuilds
            signingConfig signingConfigs.release
            buildConfigField "String", "CODEPUSH_KEY", '"1psOppiGxP0-cJpCePhMqgEjeO4l2533309f-9929-415c-8999-d7fda42c3857"'
        }
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-Android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
            buildConfigField "String", "CODEPUSH_KEY", '"0wPxPhihmtxxEdma3mU4zIGIFNdi2533309f-9929-415c-8999-d7fda42c3857"'
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.Android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.22.1'
    }
}

apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile project(':react-native-code-Push')
    compile (project(':react-native-code-Push')) {
        exclude(group: 'Android.Arch.core')
    }
    compile project(':react-native-config')
    compile project(':react-native-vector-icons')
    compile(project(':react-native-radar')) {
        exclude group: 'com.google.Android.gms'
        exclude module: 'support-v4'
    }
    compile project(':react-native-Push-notification')
    compile project(':react-native-photo-view')
    compile project(':react-native-linear-gradient')
    compile project(':react-native-image-picker')
    compile project(':react-native-fcm')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile(project(':react-native-fbsdk')){
        exclude(group: 'com.facebook.Android', module: 'facebook-Android-sdk')
    }
    compile "com.facebook.Android:facebook-Android-sdk:4.22.1"
    compile "com.Android.support:appcompat-v7:26.0.2"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile('com.crashlytics.sdk.Android:crashlytics:2.6.7@aar') {
      transitive = true
    }
    compile 'com.Android.support:multidex:1.0.2'
    compile "com.google.Android.gms:play-services-location:12.0.0"
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

paramètres.gradle

rootProject.name = 'MyProject'

include ':app'

include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/Android')
include ':react-native-radar'
project(':react-native-radar').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-radar/Android')
include ':react-native-Push-notification'
project(':react-native-Push-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-Push-notification/Android')
include ':react-native-photo-view'
project(':react-native-photo-view').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-photo-view/Android')
include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/Android')
include ':react-native-image-picker'
project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/Android')
include ':react-native-fcm'
project(':react-native-fcm').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fcm/Android')
include ':react-native-code-Push'
project(':react-native-code-Push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-Push/Android/app')
include ':react-native-intercom'
project(':react-native-intercom').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-intercom/Android')
include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/Android')
include ':react-native-fbsdk'
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/Android')
include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/Android')

Mise à jour: j'ai créé un projet propre avec init-react-native et ai exécuté la construction, ce qui a créé le même problème. Je suppose donc que c'est quelque chose de spécifique à mon environnement ou qu'il existe un problème temporaire avec les dépendances.

Mise à jour: Tout construit sur une machine Windows. Même problème.

Mise à jour: J'ai pu obtenir certaines versions de ce logiciel mais pas le projet principal. Cela pourrait être dû à ces avertissements:

Configuration 'compile' in project ':react-native-code-Push' is deprecated. Use 'implementation' instead.
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3.0.1.
Android SDK Build Tools 26.0.2 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
23
jaxoncreed

Mettez Gradle à niveau et ajoutez matchingFallbacks à votre type de construction non standard. Vos bibliothèques ne savent pas à quel type de construction correspondre.

Par exemple.

buildType {
      ...
      mySpecialRelease {
          ...
          matchingFallbacks = ['release', 'debug']
      }
}
25
ejohansson

dans mon cas, le problème résolu par les étapes suivantes:

1. npm i

2. react-native link

j'espère que cela aidera les personnes confrontées à ce problème.

8
Mahdieh Shavandi

Tout a bien fonctionné, tout à coup, j'ai commencé à avoir cette erreur sur Android -

Impossible de trouver une configuration de projet correspondante: react-native-fbsdk: aucune des configurations consommables n’a d’attributs.

Pour une raison quelconque, je ne suis pas sûr de ce qui s'est passé mais sous node_modules -> react-native-fbsdk -> Android. Il n'y avait aucun fichier dedans.

Fonctionnement npm install react-native-fbsdk résolu le problème pour moi.

3
SkyTreasure