React-native项目构建失败:找不到com.android.tools.lint,无法确定任务':app:lintVitalRelease'的依赖项

时间:2019-08-17 20:28:55

标签: android react-native build.gradle

我有一些麻烦试图生成我的应用程序的发行版。 应用在react-native run-android的模拟器中正常运行。 当我尝试在我的应用的android目录中运行“ gradlew assembleRelease”时,我得到了这些信息:

  

D:\REACTNATIVE\finalprj\android>gradlew assembleRelease

     

失败:构建失败,并出现异常。

     

出了什么问题

     

无法确定任务':app:lintVitalRelease'的依赖性。

     

无法解决配置':app:lintClassPath'的所有任务依赖项。

     

找不到com.android.tools.lint:lint-gradle:26.4.2。

 Searched in the following locations:
   - file:/C:/Users/Sam/.m2/repository/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.pom
   - file:/C:/Users/Sam/.m2/repository/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.jar
   - https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.pom
   - https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.jar
   - file:/D:/REACTNATIVE/finalprj/node_modules/react-native/android/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.pom
   - file:/D:/REACTNATIVE/finalprj/node_modules/react-native/android/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.jar
   - file:/D:/REACTNATIVE/finalprj/node_modules/jsc-android/dist/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.pom
   - file:/D:/REACTNATIVE/finalprj/node_modules/jsc-android/dist/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.jar
   - https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.pom
   - https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.4.2/lint-gradle-26.4.2.jar
 Required by:
     project :app

build.gradle:

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

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:3.4.2')
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        jcenter()
        google()
    }
}

请帮助我

任何评论和建议都将受到赞赏。

2 个答案:

答案 0 :(得分:0)

尝试创建release APK时必须签名。

您可以使用jarsigner从命令行对应用程序捆绑包进行签名。要对APK进行签名,您必须使用zipalignapksigner,如下所示:

  1. Androidstudio中,选择“视图”>“工具窗口”>“终端” 以 打开命令行并导航到目录 未签名的APK已定位。
  2. 使用zipalign对齐未签名的APK:
zipalign -v -p 4 my-app-unsigned.apk my-app-unsigned-aligned.apk
  1. 使用apksigner使用私钥对APK签名:
apksigner sign --ks my-release-key.jks --out my-app-release.apk my-app-unsigned-aligned.apk
  1. 验证您的APK已签名:
apksigner verify my-app-release.apk

配置Gradle以对您的应用进行签名

打开模块级build.gradle文件,并添加signingConfigs {}块,其中包含storeFilestorePasswordkeyAliaskeyPassword的条目,然后将该对象传递给您的构建类型中的signingConfig属性。例如:

android {
    ...
    defaultConfig { ... }
    signingConfigs {
        release {
            // You need to specify either an absolute path or include the
            // keystore file in the same directory as the build.gradle file.
            storeFile file("my-release-key.jks")
            storePassword "password"
            keyAlias "my-alias"
            keyPassword "password"
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            ...
        }
    }
}

答案 1 :(得分:0)

将此添加到 android {....} 内的 build.gradle 中。

android{
....
lintOptions {
    checkReleaseBuilds false
    abortOnError false
}
}