web-dev-qa-db-ja.com

Android St​​udio 3.0 + DataBinding + Kotlinでプロジェクトをビルドできません

データバインディング、kotlin、daggerを使用した巨大なプロジェクトがあります。いくつかのstackoverflowのソリューションを使用して構築するために数日を費やし、個人的に尋ねることにしました。

この行を追加しても役に立たないため、サードパーティのライブラリの一部はデータバインディングを使用していると思います。

kapt 'com.Android.databinding:compiler:3.0.0'

Android Studioのコメント:

「androidProcessor」の依存関係は、kapt注釈プロセッサとして認識されません。これらのアーティファクトの構成名を「kapt」に変更してください:「com.Android.databinding:compiler:3.0.0」。

私が試したのに役に立たなかった:

   kapt {
    generateStubs = true
}

local.properties:kotlin.incremental=false

別のSOソリューション助けなかった

kapt ('com.Android.databinding:compiler:3.0.0'){
        force = true
    }

私のbuild.gradle

 apply plugin: 'com.Android.application'

apply plugin: 'kotlin-Android'
apply plugin: 'blockcanaryex'
apply plugin: 'kotlin-kapt'
apply plugin: 'newrelic'
apply plugin: 'kotlin-Android-extensions'

def props = new Properties()
file("newrelic.properties").withInputStream { props.load(it) }

Android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def stdout = new ByteArrayOutputStream()
            exec {
                commandLine "git", "symbolic-ref", "--short", "HEAD"
                standardOutput = stdout
            }
            def branch = stdout.toString().trim()
            branch = "branch.$branch"

            if (project.hasProperty("buildNumber")) {
                def buildNumber = project.property("buildNumber")
                output.outputFile = new File(output.outputFile.parent, output.outputFile.name.replace(".apk", "-" + branch + "-" + versionName + "." + versionCode + "." + buildNumber + ".apk"))
            } else {
                output.outputFile = new File(output.outputFile.parent, output.outputFile.name.replace(".apk", "-" + branch + "-" + versionName + "." + versionCode + ".apk"))
            }
        }
    }

    def version = "4.15"

    defaultConfig {
        buildConfigField "String", "TOKEN", "\"" + props.getProperty("token") + "\""
        applicationId "xxx"
        minSdkVersion 19
        targetSdkVersion 26
        versionName version

        versionCode 260

        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }



    signingConfigs {
        release {
            storeFile file("xxx")
            storePassword "xxx"
            keyAlias "xxx"
            keyPassword "xxx"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.txt'
            signingConfig signingConfigs.release
        }

        debug {
            versionNameSuffix ".debug"
        }
    }
    flavorDimensions "prod","stag"

    productFlavors {



        production {
            dimension "prod"
        }

        staging {
            dimension "stag"
            applicationId "app.id"
            versionName(version + ".staging")
        }

    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude '.readme'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    dataBinding {
        enabled = true
    }
}


repositories {
    jcenter()
    maven { url "https://jitpack.io" }
    maven { url 'https://bitbucket.org/gryphteam/maven/raw/release' }
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
}


def supportVersion = "26.1.0"
def playServicesVersion = "11.6.0"
def retrofitVersion = "2.3.0"

dependencies {


    implementation 'com.jakewharton:butterknife:6.1.0'
    implementation('de.keyboardsurfer.Android.widget:crouton:1.8.5@aar') {
        exclude group: 'com.google.Android', module: 'support-v4'
    }
    implementation 'com.google.dagger:dagger:2.10'
    kapt 'com.google.dagger:dagger-compiler:2.10'
    kapt 'com.Android.databinding:compiler:3.0.0'


    implementation 'de.greenrobot:eventbus:2.4.0'
    implementation 'com.mcxiaoke.volley:library:1.0.19'

    implementation 'com.google.code.gson:gson:2.8.0'
    implementation "com.google.Android.gms:play-services-places:$playServicesVersion"
    implementation "com.google.Android.gms:play-services-plus:$playServicesVersion"
    implementation "com.google.Android.gms:play-services-analytics:$playServicesVersion"
    implementation "com.google.Android.gms:play-services-auth:$playServicesVersion"
    implementation "com.google.Android.gms:play-services-gcm:$playServicesVersion"
    implementation "com.google.Android.gms:play-services-ads:$playServicesVersion"

    implementation "com.Android.support:appcompat-v7:$supportVersion"
    implementation "com.Android.support:support-v13:$supportVersion"
    implementation "com.Android.support:recyclerview-v7:$supportVersion"
    implementation "com.Android.support:design:$supportVersion"
    implementation "com.Android.support:support-annotations:$supportVersion"
    implementation 'com.Android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.Android.support:multidex:1.0.2'

    implementation 'commons-io:commons-io:2.4'
    implementation 'org.Apache.commons:commons-lang3:3.1'
    implementation files('libs/comscore.jar')
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'
    implementation 'com.github.deano2390:MaterialShowcaseView:1.0.5'
    implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    implementation 'com.google.ads.mediation:facebook:4.26.1.0'
    implementation 'com.facebook.Android:audience-network-sdk:4.26.1'
    implementation 'org.jboss.netty:netty:3.2.10.Final'

    //Testing
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:1.10.19'
    androidTestImplementation 'com.Android.support:multidex:1.0.2'
    androidTestImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.Android.support.test.espresso:espresso-web:3.0.1'
    androidTestImplementation('com.Android.support.test.espresso:espresso-core:2.2') {
        exclude group: 'com.Android.support', module: 'support-annotations:22.2.1'
    }
    androidTestImplementation('com.Android.support.test:runner:0.3') {
        exclude group: 'com.Android.support', module: 'support-annotations:22.2.1'
    }
    androidTestImplementation('com.Android.support.test:rules:0.3') {
        exclude group: 'com.Android.support', module: 'support-annotations:22.2.1'
    }
    androidTestImplementation('com.Android.support.test.espresso:espresso-intents:2.2') {
        exclude group: 'com.Android.support', module: 'support-annotations:22.2.1'
    }
    androidTestImplementation('com.Android.support.test.espresso:espresso-contrib:2.2') {
        exclude group: 'com.Android.support', module: 'app-compat'
        exclude group: 'com.Android.support', module: 'support-v4'
        exclude group: 'com.Android.support', module: 'support-annotations:22.2.1'
        exclude module: 'recyclerview-v7'

    }
    androidTestImplementation 'com.Android.support.test.uiautomator:uiautomator-v18:2.1.3'
    androidTestImplementation "com.Android.support:support-annotations:$supportVersion"
    implementation project(':eventsource_Android-release')
    implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
    debugImplementation 'com.letv.sarrsdesktop:BlockCanaryExJRT:0.9.5.3'
    releaseImplementation 'com.letv.sarrsdesktop:BlockCanaryExJRTNoOp:0.9.5.3'
    testImplementation 'com.letv.sarrsdesktop:BlockCanaryExJRTNoOp:0.9.5.3'


    implementation 'me.mvdw.recyclerviewmergeadapter:recyclerviewmergeadapter:2.0.0'
    debugImplementation 'com.squareup.leakcanary:leakcanary-Android:1.5.1'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-Android-no-op:1.5.1'
    testImplementation 'com.squareup.leakcanary:leakcanary-Android-no-op:1.5.1'

    implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
    implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
    implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
    implementation 'io.reactivex.rxjava2:rxjava:2.1.2'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'com.github.ReactiveX:RxKotlin:2.1.0'
    implementation 'com.gojuno.koptional:koptional-rxjava2-extensions:1.2.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.newrelic.agent.Android:android-agent:5.14.0'
    implementation 'org.jsoup:jsoup:1.10.3'
}
38

新しくて新鮮なkotlinプロジェクトで同様のbuild.gradle設定で試したところ、ビルドされました。残念ながら、すべてのライブラリと正確な設定を使用することはできませんでしたが、それは単に順序の問題かもしれません。これが私の

build.gradle

apply plugin: 'com.Android.application'
apply plugin: 'kotlin-Android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-Android-extensions'

kapt {
    generateStubs = true
}

Android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "Nice.fontaine.kottest"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "Android.support.test.runner.AndroidJUnitRunner"

        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.jakewharton:butterknife:6.1.0'
    annotationProcessor 'com.jakewharton:butterknife:6.1.0'
    implementation('de.keyboardsurfer.Android.widget:crouton:1.8.5@aar') {
        exclude group: 'com.google.Android', module: 'support-v4'
    }
    implementation 'com.google.dagger:dagger:2.10'
    kapt 'com.google.dagger:dagger-compiler:2.10'
    kapt 'com.Android.databinding:compiler:3.0.0'

    implementation 'de.greenrobot:eventbus:2.4.0'
    implementation 'com.mcxiaoke.volley:library:1.0.19'

    implementation 'com.google.code.gson:gson:2.8.0'
    implementation "com.google.Android.gms:play-services-places:11.6.0"
    implementation "com.google.Android.gms:play-services-plus:11.6.0"
    implementation "com.google.Android.gms:play-services-analytics:11.6.0"
    implementation "com.google.Android.gms:play-services-auth:11.6.0"
    implementation "com.google.Android.gms:play-services-gcm:11.6.0"
    implementation "com.google.Android.gms:play-services-ads:11.6.0"

    implementation "com.Android.support:appcompat-v7:26.1.0"
    implementation "com.Android.support:support-v13:26.1.0"
    implementation "com.Android.support:recyclerview-v7:26.1.0"
    implementation "com.Android.support:design:26.1.0"
    implementation "com.Android.support:support-annotations:26.1.0"
    implementation 'com.Android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.Android.support:multidex:1.0.2'

    implementation 'commons-io:commons-io:2.4'
    implementation 'org.Apache.commons:commons-lang3:3.1'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    implementation 'com.google.ads.mediation:facebook:4.26.1.0'
    implementation 'com.facebook.Android:audience-network-sdk:4.26.1'
    implementation 'org.jboss.netty:netty:3.2.10.Final'

    //Testing
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:1.10.19'
    androidTestImplementation 'com.Android.support:multidex:1.0.2'
    androidTestImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.Android.support.test.espresso:espresso-web:3.0.1'
    androidTestImplementation('com.Android.support.test.espresso:espresso-core:2.2') {
        exclude group: 'com.Android.support', module: 'support-annotations:22.2.1'
    }
    androidTestImplementation('com.Android.support.test:runner:0.3') {
        exclude group: 'com.Android.support', module: 'support-annotations:22.2.1'
    }
    androidTestImplementation('com.Android.support.test:rules:0.3') {
        exclude group: 'com.Android.support', module: 'support-annotations:22.2.1'
    }
    androidTestImplementation('com.Android.support.test.espresso:espresso-intents:2.2') {
        exclude group: 'com.Android.support', module: 'support-annotations:22.2.1'
    }
    androidTestImplementation('com.Android.support.test.espresso:espresso-contrib:2.2') {
        exclude group: 'com.Android.support', module: 'app-compat'
        exclude group: 'com.Android.support', module: 'support-v4'
        exclude group: 'com.Android.support', module: 'support-annotations:22.2.1'
        exclude module: 'recyclerview-v7'

    }
    androidTestImplementation 'com.Android.support.test.uiautomator:uiautomator-v18:2.1.3'
    androidTestImplementation "com.Android.support:support-annotations:26.1.0"
    implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
    debugImplementation 'com.letv.sarrsdesktop:BlockCanaryExJRT:0.9.5.3'
    releaseImplementation 'com.letv.sarrsdesktop:BlockCanaryExJRTNoOp:0.9.5.3'
    testImplementation 'com.letv.sarrsdesktop:BlockCanaryExJRTNoOp:0.9.5.3'

    implementation 'me.mvdw.recyclerviewmergeadapter:recyclerviewmergeadapter:2.0.0'
    debugImplementation 'com.squareup.leakcanary:leakcanary-Android:1.5.1'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-Android-no-op:1.5.1'
    testImplementation 'com.squareup.leakcanary:leakcanary-Android-no-op:1.5.1'

    implementation "com.squareup.retrofit2:retrofit:2.3.0"
    implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
    implementation "com.squareup.retrofit2:converter-gson:2.3.0"
    implementation "com.squareup.retrofit2:adapter-rxjava2:2.3.0"
    implementation 'io.reactivex.rxjava2:rxjava:2.1.2'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'com.gojuno.koptional:koptional-rxjava2-extensions:1.2.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.newrelic.agent.Android:android-agent:5.14.0'
    implementation 'org.jsoup:jsoup:1.10.3'
}

少なくともこのテストで次のことを確認できます。

kapt 'com.Android.databinding:compiler:3.0.0' 

私のために働いています。新しいプロジェクトでも試してみて、これが機能するかどうかを確認してから、他のライブラリを1つずつゆっくり適用してください。それが軌道に乗ることを願っています!

15