React-native项目构建失败:找不到com.android.tools.lint:lint-gradle:26.1.0

Kev*_*get 6 android gradle react-native

我有一些问题试图生成我的apk的新版本.(但是应用程序在调试时正常运行react-native run-android)

首先,我有这个输出消息:

任务:react-native-maps:compileReleaseJavaWithJavac注意:某些输入文件使用或覆盖不推荐使用的API.注意:使用-Xlint重新编译:弃用以获取详细信息.注意:某些输入文件使用未经检查或不安全的操作.注意:使用-Xlint重新编译:取消选中以获取详细信息.

FAILURE:构建因异常而失败.

>出了什么问题:无法解析所有配置文件':react-native-maps:lintClassPath'.

找不到com.android.tools.lint:lint-gradle:26.1.0.在以下位置搜索: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文件:/ 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文件: /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文件:/ 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文件:/ C :/Users/kev_w/.m2/repository/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.pom文件:/ 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.pom https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.jar 文件:/ C:/ Users /kev_w/Desktop/Ulabs/appreactnative/testApp/node_modules/react-native/android/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.pom文件:/ C:/ Users/kev_w/Desktop/Ulabs/appreactnative/testApp/node_modules/react-native/android/com/android/tools/lint/lint-gradle/26.1.0/lint-gradle-26.1.0.jar必需:project:反应-本机地图*

1.我做了什么来解决这个问题:添加google()我的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
}
Run Code Online (Sandbox Code Playgroud)

添加此内容后,构建成功,但当我打开它时,我的apk立即崩溃...

正如我在开始时说的,在添加之前google(),我的项目在调试中正常运行react-native run-android.但是现在,apk和调试项目都不起作用.

它没有任何日志崩溃.

然后我试图运行apk build删除google()并添加lintOptions到我的android/app/build.gradle:

android {
 (...)
    lintOptions {

        checkReleaseBuilds false
        abortOnError false
    }
}
Run Code Online (Sandbox Code Playgroud)

在我android/app/build.gradle,,以避免lint-gradle错误> IT DID NOT WORK.

这是我的整体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'
}
Run Code Online (Sandbox Code Playgroud)

我花了好几个小时试图在网上找到解决方案,但没有任何方法可以帮助我.要么我的run-android工作和应用程序没有崩溃,但无法构建任何apk,或者我可以构建它但它立即崩溃当我运行它(apk或运行android)...

如果有人能保存我的心理健康,请^^ ...

Jos*_*iño 10

你有没有尝试过jcenter()之前的google()?它对我有用:

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()
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 奇怪的!!但这件事有效:D (2认同)
  • 当我在jcenter()之前将google()添加到allprojects中时,这对我有帮助。但是,当我尝试将google()首先放在buildscript中时,出现了一个错误。它会编译,所以我对100%理解这里发生的事情感到满意。 (2认同)