首页 文章

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

提问于
浏览
5

我有一些问题试图生成我的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:反应 - 本机 Map *

1.我做了什么来解决这个问题:在我的_1314527中添加 google() >> 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
}

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

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

它没有任何日志崩溃 .

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

android {
 (...)
    lintOptions {

        checkReleaseBuilds false
        abortOnError false
    }
}

在我的 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'
}

我've spent hours trying to find out a solution on the net, but nothing worked for me. Either i'我的 run-android 工作和应用程序没有崩溃但无法构建任何apk,或者我可以构建它但它立即崩溃当我运行它(apk或运行android)...

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

3 回答

  • 9

    你有没有尝试过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()
        }
    }
    
  • 0

    我们面临着完全相同的问题,并找到了解决问题的两种方法 .

    第一个:将Gradle评级降至版本2.2.3

    更好的一个:对我来说问题是由react-native-map创建的,要解决它你需要编辑app / build.gradle

    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:+"
    
  • -1

    以下代码对我有用 .

    // Top-level build file where you can add configuration options common to all sub- 
      projects/modules.
    
     buildscript {
    repositories {
        google()
        jcenter()
    
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
    
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    }
    
    allprojects {
    repositories {
        google()
        jcenter()
    }
    }
    
    task clean(type: Delete) {
    delete rootProject.buildDir
    }
    

相关问题