当前位置: 首页 > 知识库问答 >
问题:

Android上由于lint类路径错误导致Gradle构建失败

严高峻
2023-03-14

我有一个Android应用程序,当我运行以下命令时,它的构建失败:./gradlew clean build-pbuild=dev--stacktrace

以下是我收到的错误:

> Task :app:lint FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':app:lint'.
> No value has been specified for property 'lintClassPath'.
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

apply plugin: 'io.fabric'

apply plugin: "androidx.navigation.safeargs"

// For Epoxy
kapt {
    correctErrorTypes = true
}

android {
    kotlinOptions {
        jvmTarget = '1.6'
    }
    compileSdkVersion 28
    defaultConfig {
        applicationId "..."
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 8
        versionName "0.4"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        debug {
            if (project.hasProperty('ApiKey')) {
                buildConfigField('String', 'API_KEY', ApiKey)
            } else {
                buildConfigField('String', 'API_KEY', "\"mock-key\"")
            }
        }
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            if (project.hasProperty('ApiKey')) {
                buildConfigField('String', 'API_KEY', ApiKey)
            } else {
                buildConfigField('String', 'API_KEY', "\"mock-key\"")
            }
        }

    }

    def build_param = "${build}"

    if (build_param != "dev") {
        //exclude production build
        android.variantFilter { variant ->
            if (variant.buildType.name == 'dev') {
                variant.setIgnore(true)
            }
        }
    } else {
        //exclude all except production build
        android.variantFilter { variant ->
            if (variant.buildType.name != 'dev') {
                variant.setIgnore(true)
            }
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    androidExtensions {
        experimental = true
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

    // Android
    def lifecycle_version = "2.0.0"
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha02'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
    implementation 'com.google.android.material:material:1.0.0'
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
    implementation 'androidx.core:core-ktx:1.0.1'
    implementation 'androidx.preference:preference:1.0.0'
    implementation 'androidx.legacy:legacy-preference-v14:1.0.0'

    def room_version = "2.1.0-alpha04"
    implementation "androidx.room:room-runtime:$room_version"
    implementation "androidx.room:room-rxjava2:$room_version"
    kapt "androidx.room:room-compiler:$room_version"

    def nav_version = "1.0.0-rc02"
    implementation "android.arch.navigation:navigation-fragment-ktx:$nav_version"
    implementation "android.arch.navigation:navigation-ui-ktx:$nav_version"

    // Networking
    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
    implementation 'com.squareup.okhttp3:okhttp:3.13.1'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.13.1'
    implementation 'com.squareup.retrofit2:converter-moshi:2.4.0'
    implementation 'com.squareup.moshi:moshi-adapters:1.8.0'
    // DI
    def koin_version = "1.0.2"
    implementation "org.koin:koin-android:$koin_version"
    implementation "org.koin:koin-androidx-scope:$koin_version"
    implementation "org.koin:koin-androidx-viewmodel:$koin_version"
    // Rx
    implementation 'io.reactivex.rxjava2:rxjava:2.2.7'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
    implementation 'com.jakewharton.rxbinding2:rxbinding:2.2.0'
    implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.0'
    // Image Loading
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    kapt 'com.github.bumptech.glide:compiler:4.8.0'
    // Tests
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:2.24.5'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    // UI
    implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:9.0.1'
    implementation 'com.airbnb.android:epoxy:3.2.0'
    kapt 'com.airbnb.android:epoxy-processor:3.2.0'
    implementation 'com.github.VladimirWrites:Lemniscate:1.4.4'
    // Firebase
    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
}

apply plugin: 'com.google.gms.google-services'

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

buildscript {
    ext.kotlin_version = '1.3.21'
    repositories {
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.2.0'
        classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-rc02"
        classpath 'io.fabric.tools:gradle:1.27.0'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
        }
        maven {
            url 'https://jitpack.io'
        }
        google()
    }
}

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

共有1个答案

董宜然
2023-03-14

在我的示例中,触发此错误的原因是未设置android_home环境变量

 类似资料:
  • 我用android Studio 0.4.0创建了一个简单的android项目。我使用Gradle 1.9和Gradle Android插件0.7。昨天,我在gradle构建脚本中添加了Jake Wharton的Butternife库: 当我从Android Studio运行应用程序时,构建运行良好,并在我的设备上正确执行。但是当我尝试(从命令行)时,构建失败了。以下是我的林特报告中的一部分: 也

  • 我使用Gradle 4.10.2(但使用最新版本让它工作会很好)。这是我的gradle文件: 当我执行时,它会失败并出现很多错误。这些错误都是由于没有找到lombok自动生成的getter、setter等。如何解决这些错误?我看过其他关于这个问题的帖子,他们都建议将lombok依赖项添加为 使现代化 以下是我得到的几个错误: 日志应该来自注释。并且来自于在CarDto上注释的@Builder(Bu

  • 问题内容: 我收到此错误: 我正在使用Tomcat 6作为Web服务器。我有两个HTTPS Web应用程序安装在不同端口上但在同一台机器上的不同Tomcat上。说App1(port 8443)和 App2(port 443)。App1连接到App2。当App1连接到App2我得到以上错误。我知道这是一个非常常见的错误,因此在不同的论坛和站点上遇到了许多解决方案。我在server.xml两个Tomc

  • 我正在按照http://spring.io/guides/gs/consource-web-service/#scratch中提供的分步说明学习如何使用Gradle和Spring-WS使用SOAP web服务。我已经创建了上面URL中指定的文件夹结构(即:c:/src/main/java/hello)并将build.gradle、weatherclient.java、weatherconfigur

  • 编辑:这个问题的第一个版本给人的印象是我的问题与Maven有关。我修改了措辞,以便更多地关注JDK。 我得到时,试图使用Java联系任何支持SSL的服务。对其他相关问题的回答并没有阻止我的错误。 null 众所周知的解决这个问题的方法似乎不起作用。我如何才能停止错误,修复我的JDK,并最终再次使用支持SSL的服务?

  • 我已经更新了firebase-auth依赖版本,但gradle构建总是失败。它在中运行良好 项目级别分级文件