Cannot run program CreateProcess error=206, 文件名或扩展名太长

1.在build.grade(Project: xxx)中添加依赖和库
//dependencies中添加:
classpath "gradle.plugin.com.github.viswaramamoorthy:gradle-util-plugins:0.1.0-RELEASE"
//repositories中添加:
maven {url "https://plugins.gradle.org/m2/"}

build.grade(Project: xxx)完整代码:

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

buildscript {
    // Define versions in a single place
    ext {
        // Sdk and tools
        compileSdkVersion = 29
        minSdkVersion = 21
        targetSdkVersion = 29

        // App dependencies
        appCompatVersion = '1.1.0'
        constraintLayoutVersion = '2.0.0-beta4'
        coreTestingVersion = '2.1.0'
        coroutinesVersion = '1.3.3'
        espressoVersion = '3.2.0'
        fragmentVersion = '1.2.1'
        glideVersion = '4.11.0'
        gradleVersion = '3.5.3'
        gsonVersion = '2.8.6'
        junitVersion = '4.13'
        kotlinVersion = '1.3.61'
        ktlintVersion = '0.33.0'
        ktxVersion = '1.2.0'
        lifecycleVersion = '2.2.0'
        materialVersion = '1.2.0-alpha04'
        navigationVersion = '2.2.1'
        recyclerViewVersion = '1.2.0-alpha01'
        roomVersion = '2.2.3'
        runnerVersion = '1.0.1'
        truthVersion = '1.0.1'
        testExtJunit = '1.1.1'
        uiAutomatorVersion = '2.2.0'
        viewPagerVersion = '1.0.0'
        workVersion = '2.3.1'
    }

    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath "com.android.tools.build:gradle:$gradleVersion"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"
        classpath "gradle.plugin.com.github.viswaramamoorthy:gradle-util-plugins:0.1.0-RELEASE"
    }
}

plugins {
    id "com.diffplug.gradle.spotless" version "3.24.0"
}

allprojects {
    repositories {
        mavenCentral()
        google()
        jcenter()
        maven { url "https://plugins.gradle.org/m2/" }
    }
}

spotless {
    kotlin {
        target "**/*.kt"
        ktlint(ktlintVersion).userData(['max_line_length' : '100'])
    }
}
2.在build.grade(Module: app)中添加插件
apply plugin: "com.github.ManifestClasspath"

build.grade(Module: app)文件完整代码:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'androidx.navigation.safeargs.kotlin'
apply plugin: "com.github.ManifestClasspath"

android {
    compileSdkVersion rootProject.compileSdkVersion
    dataBinding {
        enabled = true
    }
    defaultConfig {
        applicationId "com.example.gca"
        minSdkVersion rootProject.minSdkVersion
        targetSdkVersion rootProject.targetSdkVersion
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        versionCode 1
        versionName "0.1.6"
        vectorDrawables.useSupportLibrary true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    // work-runtime-ktx 2.1.0 and above now requires Java 8
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

dependencies {
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
    kapt "androidx.room:room-compiler:$rootProject.roomVersion"
    kapt "com.github.bumptech.glide:compiler:$rootProject.glideVersion"
    implementation "androidx.appcompat:appcompat:$rootProject.appCompatVersion"
    implementation "androidx.constraintlayout:constraintlayout:$rootProject.constraintLayoutVersion"
    implementation "androidx.core:core-ktx:$rootProject.ktxVersion"
    implementation "androidx.fragment:fragment-ktx:$rootProject.fragmentVersion"
    implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.lifecycleVersion"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$rootProject.lifecycleVersion"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.lifecycleVersion"
    implementation "androidx.navigation:navigation-fragment-ktx:$rootProject.navigationVersion"
    implementation "androidx.navigation:navigation-ui-ktx:$rootProject.navigationVersion"
    implementation "androidx.recyclerview:recyclerview:$rootProject.recyclerViewVersion"
    implementation "androidx.room:room-runtime:$rootProject.roomVersion"
    implementation "androidx.room:room-ktx:$rootProject.roomVersion"
    implementation "androidx.viewpager2:viewpager2:$rootProject.viewPagerVersion"
    implementation "androidx.work:work-runtime-ktx:$rootProject.workVersion"
    implementation "com.github.bumptech.glide:glide:$rootProject.glideVersion"
    implementation "com.google.android.material:material:$rootProject.materialVersion"
    implementation "com.google.code.gson:gson:$rootProject.gsonVersion"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$rootProject.kotlinVersion"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutinesVersion"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutinesVersion"

    // Testing dependencies
    androidTestImplementation "androidx.arch.core:core-testing:$rootProject.coreTestingVersion"
    androidTestImplementation "androidx.test.espresso:espresso-contrib:$rootProject.espressoVersion"
    androidTestImplementation "androidx.test.espresso:espresso-core:$rootProject.espressoVersion"
    androidTestImplementation "androidx.test.espresso:espresso-intents:$rootProject.espressoVersion"
    androidTestImplementation "androidx.test.ext:junit:$rootProject.testExtJunit"
    androidTestImplementation "androidx.test.uiautomator:uiautomator:$rootProject.uiAutomatorVersion"
    androidTestImplementation "androidx.work:work-testing:$rootProject.workVersion"
    androidTestImplementation "com.google.truth:truth:$rootProject.truthVersion"
    testImplementation "junit:junit:$rootProject.junitVersion"
}

参考:https://blog.csdn.net/weixin_42260270/article/details/103030182

如果还是碰到就菜单build下rebuild project

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值