web-dev-qa-db-fra.com

Le projet réactif natif a échoué: impossible de trouver com.Android.tools.lint: lint-gradle: 26.1.0

J'ai quelques problèmes à essayer de générer une nouvelle version de mon apk . (Cependant, l'application s'exécute normalement en débogage avec react-native run-Android)

Tout d'abord j'avais ce message de sortie: 

Tâche: react-native-maps: compileReleaseJavaWithJavac Remarque: Certaines entrées les fichiers utilisent ou remplacent une API obsolète. Remarque: Recompiler avec -Xlint: obsolète pour plus de détails. Remarque: Certains fichiers d'entrée utilisent des opérations non contrôlées ou non sécurisées. Remarque: Recompiler avec -Xlint: décoché pour détails.

ECHEC: La construction a échoué avec une exception.

> Ce qui s'est mal passé: impossible de résoudre tous les fichiers pour la configuration ': react-native-maps: lintClassPath'.

Impossible de trouver com.Android.tools.lint: lint-gradle: 26.1.0. Recherche dans les lieux suivants: file:/C: /Users/kev_w/AppData/Local/Android/Sdk/extras/m2repository/com/Android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.pom file:/C: /Users/kev_w/AppData/Local/Android/Sdk/extras/m2repository/com/Android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.jar file:/C: /Users/kev_w/AppData/Local/Android/Sdk/extras/google/m2repository/com/Android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.pom file:/C: /Users/kev_w/AppData/Local/Android/Sdk/extras/google/m2repository/com/Android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.jar file:/C: /Users/kev_w/AppData/Local/Android/Sdk/extras/Android/m2repository/com/Android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.pom file:/C: /Users/kev_w/AppData/Local/Android/Sdk/extras/Android/m2repository/com/Android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.jar fichier:/C: /Users/kev_w/.m2/repository/com/Android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.pom fichier:/C: /Users/kev_w/.m2/repository/com/Android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.jar https://jcenter.bintray.com/com/Android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.pomhttps://jcenter.bintray.com/com/Android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.jar fichier:/C: /Users/kev_w/Desktop/Ulabs/appreactnative/testApp/node_modules/react-native/Android/com/Android/tool/lint/lint-gradle/26.1.0/lint-gradle-26.1.0. pom fichier:/C: /Users/kev_w/Desktop/Ulabs/appreactnative/testApp/node_modules/react-native/Android/com/Android/tool/lint/lint-gradle/26.1.0/lint-gradle-26.1.0. pot Requis par: projet: react-native-maps *

1.Que j'ai fait pour résoudre ce problème: Ajout de google() dans mon Android/build.gradle >> allprojects {...}:

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

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        google()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/Android"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Après avoir ajouté ceci, la construction est réussie, mais mon apk se bloque instantanément lorsque je l'ouvre ...

Comme je l’ai dit au début, avant d’ajouter google(), mon projet s’exécutait normalement dans le débogage avec react-native run-Android. Mais à présent, ni le projet apk ni le projet de débogage ne fonctionnent.

Il se bloque sans aucun journal.

Ensuite, j'ai essayé de lancer apk build en supprimant google() et en ajoutant lintOptions dans mon Android/app/build.gradle:

Android {
 (...)
    lintOptions {

        checkReleaseBuilds false
        abortOnError false
    }
}

dans mon Android/app/build.gradle, pour éviter l'erreur de peluchage> IT DID ne fonctionne pas.

Voici tout mon Android/app/build.gradle:

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 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.testapp"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        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"
        }
    }

    Android {
        lintOptions {
            abortOnError false
            checkReleaseBuilds false
        }
    }

    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-Android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // 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-linear-gradient')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.Android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile project(':react-native-linear-gradient')
    compile project(':react-native-device-info')
    /*implementation project('react-native-maps')*/
    implementation(project(':react-native-maps')){
        exclude group: 'com.google.Android.gms', module: 'play-services-base'
        exclude group: 'com.google.Android.gms', module: 'play-services-maps'
    }
    implementation 'com.google.Android.gms:play-services-base:11.0.4'
    implementation 'com.google.Android.gms:play-services-maps:11.0.4'
}

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

J'ai passé des heures à essayer de trouver une solution sur le net, mais rien ne fonctionnait pour moi. Soit j'ai mon run-Android qui fonctionne et mon application ne plante pas, mais je ne peux pas créer d'apk, ou je peux le construire, mais il se bloque immédiatement lorsque je l'exécute (apk ou sous Android) ... 

Si quelqu'un pouvait sauver ma santé mentale s'il vous plait ^^ ...

6
Kevin Georget

Avez-vous essayé avec google () avant jcenter ()? Cela a fonctionné pour moi:

buildscript {
    repositories {
        google()
        jcenter()
        gradlePluginPortal()
    }
    dependencies {
        classpath 'com.Android.tools.build:gradle:3.1.1'
        // NOTE: Do not place your application dependencies here;
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

10
José Cousiño

Nous étions confrontés exactement au même problème et avons trouvé deux solutions.

Premièrement: rétrograder à la version 2.2.3

Mieux: pour moi le problème a été créé par react-native-map, pour le résoudre, vous devez éditer le fichier app/build.gradle depuis 

implementation 'com.google.Android.gms:play-services-base:11.0.4'
implementation 'com.google.Android.gms:play-services-maps:11.0.4'

à:

implementation "com.google.Android.gms:play-services-base:+"
implementation "com.google.Android.gms:play-services-maps:+"
0
MaximumLasagna