Je suis un peu nouveau dans le domaine réactif, alors veuillez m'excuser pour des erreurs stupides.
En gros, j'ai essayé tout ce que je pouvais trouver avant de poster ici et je ne suis pas sûr si c'est quelque chose de mon côté (c'est-à-dire que je suis stupide) ou un bug dû à des mises à jour récentes quelque part.
Donc, mon problème est le message d'erreur mentionné ci-dessus que je reçois lorsque j'essaie de créer l'application (en utilisant "react-native run-Android" ou même avec "gradlew clean"). Je publie le message d'erreur complet ci-dessous, ainsi que mes fichiers app/build.gradle, build.gradle et settings.gradle.
J'ai laissé tous les fichiers tels qu'ils ont été créés par "react-native init" et "vient" d'ajouter les commandes que je devais ajouter en fonction des guides d'installation des bibliothèques respectives.
En raison des récents changements apportés au SDK Firebase, j’ai dû changer un peu quand il s’agissait de la version d'évaluation, etc. C'est pourquoi je me demande si ce problème a quelque chose à voir avec ça?!
Oh, et les numéros de version: "Dépendances": { "Babel-core": "^ 6.26.3", "Eslint": "^ 4.19.1", "Fbjs ":" ^ 0.8.16 ", " React ":" 16.3.1 ", " React-native ":" 0.55.4 ", " React-native-firebase ":" ^ 4.1.0 ", " Réagir-natif-navigation ":" ^ 1.1.458 ", " Réagir-natif-vecteur-icônes ":" ^ 4.6.0 ", " React-redux ":" ^ 5.0.7 ", " Redux ":" ^ 4.0.0 ", " Redux-logger ":" ^ 3.0.6 ", " Redux-thunk ":" ^ 2.2.0 "}
J'ai installé chaque paquet avec fil ("yarn add rea-native-vector-icons", etc.) et npm ("npm install", ainsi que "npm install react-native-vector-icons", etc.) pour créer sûr que ce n'est pas lié à aucun de ceux-ci. Entre temps, j'ai supprimé le dossier entier de node_modules bien sûr .. Ni "Reaction-native link" n'a aidé.
Cela ne concerne pas non plus uniquement le paquetage "réagit-natif-vecteur-icônes" mentionné: je l’ai complètement supprimé de mon projet et la même erreur s’affiche pour un autre paquetage.
J'apprécie toute aide et astuces!
Merci beaucoup d'avance!
Dustin
MESSAGE D'ERREUR:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:debugCompileClasspath'.
> More than one variant of project :react-native-vector-icons matches the consumer attributes:
- Configuration ':react-native-vector-icons:debugApiElements' variant Android-aidl:
- Found artifactType 'Android-aidl' but wasn't required.
- Required com.Android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.Android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.Android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'Java-api' and found compatible value 'Java-api'.
- Configuration ':react-native-vector-icons:debugApiElements' variant Android-classes:
- Found artifactType 'Android-classes' but wasn't required.
- Required com.Android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.Android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.Android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'Java-api' and found compatible value 'Java-api'.
- Configuration ':react-native-vector-icons:debugApiElements' variant Android-manifest:
- Found artifactType 'Android-manifest' but wasn't required.
- Required com.Android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.Android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.Android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'Java-api' and found compatible value 'Java-api'.
- Configuration ':react-native-vector-icons:debugApiElements' variant Android-renderscript:
- Found artifactType 'Android-renderscript' but wasn't required.
- Required com.Android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.Android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.Android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'Java-api' and found compatible value 'Java-api'.
- Configuration ':react-native-vector-icons:debugApiElements' variant jar:
- Found artifactType 'jar' but wasn't required.
- Required com.Android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.Android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.Android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'Java-api' and found compatible value 'Java-api'.
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-vector-icons/fonts.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 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.seroleashed.budgetmanager"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-Android.txt"), "proguard-rules.pro"
}
}
// 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
}
}
}
}
dependencies {
compile project(':react-native-vector-icons')
compile project(':react-native-navigation')
compile(project(':react-native-firebase')) {
transitive = false
}
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(':react-native-vector-icons')
implementation project(':react-native-navigation')
implementation "com.Android.support:appcompat-v7:27.0.1"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-firebase')
// RNFirebase required dependencies
implementation "com.google.Android.gms:play-services-base:15.0.0"
implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.firebase:firebase-auth:15.1.0"
implementation "com.google.firebase:firebase-database:15.0.0"
implementation "com.google.firebase:firebase-messaging:15.0.2"
}
// 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'
}
apply plugin: 'com.google.gms.google-services'
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.1.2'
classpath 'com.google.gms:google-services:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/Android"
}
google()
}
}
SETTINGS.GRADLE:
rootProject.name = 'BudgetManager'
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-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/Android/app')
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/Android')
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-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native
Déplacer google()
vers le haut peut parfois résoudre des problèmes de ce type. un exemple de correctif de votre code
buildscript {
google()
repositories {
jcenter()
}
dependencies {
classpath 'com.Android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenLocal()
jcenter()
maven {
url "$rootDir/../node_modules/react-native/Android"
}
}
}
Vous pouvez exécuter la commande suivante dans le dossier racine de votre projet.
1. You need to delete both ios,Android and node module folder. Run the following commands
2. > npm install //to get the node module folder
3. > react-native upgrade //to get Android and ios folder
4. > react-native link // for linking the libraries
5. > react-native run Android/ios
Pourquoi est-ce que je trouve toujours la réponse aux questions que j'ai peu de temps après, dans un forum ou sur Stackoverflow? xD
Je viens de trouver la solution dans ce post :
Apparemment, il y a un bogue dans la version "google-services" que j'utilisais .
classpath 'com.google.gms:google-services:3.3.0'
à
classpath 'com.google.gms:google-services:3.2.1'
dans mon fichier "build.gradle" fait l'affaire.
J'ai commencé comme @Prahbu mais j'ai changé au milieu et j'ai donc pensé poster ce que je faisais comme réponse différente:
voici ce que j'ai fait (dans le dossier racine du projet également):
1. You need to delete both ios,Android and node module folder. Afterwards, you can run the following commands
2. > npm install //to get the node module folder
3. > react-native-git-upgrade
Vous finirez par tomber sur cette erreur . Dans ce cas, supprimez votre .babelrc
(après avoir enregistré son contenu), vous pouvez par exemple le renommer en .babelrc2 et remplacer le .babelrc
généré par le vôtre lorsque vous aurez terminé.
Si react-native-git-upgrade n'a pas généré les dossiers ios et Android, exécutez
react-native eject
Et tout ce qui reste est, selon la réponse originale,
4. > react-native link // for linking the libraries
5. > react-native run Android/ios