Compile error after upgrade Gradle version to 3.0.0

前端 未结 1 1606
天命终不由人
天命终不由人 2021-01-28 08:17

Here is the error log.

More than one file was found with OS independent path \'android/databinding/DataBindingComponent.java\'

1条回答
  •  长情又很酷
    2021-01-28 09:03

    It seems that your databindings are creating some issues

    Use as below if you are using the newer version

    implementation 'com.android.databinding:library:1.3.1'
    implementation 'com.android.databinding:adapters:1.3.1'
    

    or for older

     compile 'com.android.databinding:library:1.3.1'
        compile 'com.android.databinding:adapters:1.3.1'
    

    Also, make sure you added the new repo in root gradle.build

    repositories {
        maven {
            url 'https://maven.google.com'
        }
    }
    

    You may also use with newer Gradle wrapper:

    repositories {
            maven {
                google()
            }
        }
    

    If you have used data binding in repo, then make sure you have added:

    android {
        ....
        dataBinding {
            enabled = true
        }
    }
    

    This is the best way to do it.

    In your root level gradle.build use below

    buildscript {
        repositories {
            mavenCentral()
            jcenter()
            google()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.3.3'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            mavenCentral()
            jcenter()
            google()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    and in your gradle-wrapper.properties file change the wrapper version as below

    distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
    

    Also in your app level build.gradle make sure you are using 26 version as below

    android {
        compileSdkVersion 26
        buildToolsVersion "26.0.2"
        defaultConfig {
            applicationId "com.xxxx"
            minSdkVersion 16
            targetSdkVersion 26
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    

    0 讨论(0)
提交回复
热议问题