web-dev-qa-db-ja.com

Android Studio 3.0エラー:Android-aptは互換性がありません

Android開発に不慣れで、レガシープロジェクトを取得したので、最新バージョンのAndroid Studioをインストールして開きました。

ビルドしようとすると、次のエラーが発生します。

Error:Android-apt plugin is incompatible with the Android Gradle plugin.  Please use 'annotationProcessor' configuration instead.

これらに示されている解決策を試しました thread ですが、機能しませんでした。

グランドルビルドスクリプトにAndroid-aptリファレンスがありません。

コンパイルパッケージの多くは古いものとして表示されます。しかし、Androidのスタジオの提案に従って参照を更新すると、パッケージが見つからなかったというエラーが表示されます。

私が言ったように、私はAndroid Studio Worldに慣れていないので、これらすべてのものに少し迷っています。

これは私のbuild.gradleです(モジュール:アプリ):

apply plugin: 'com.Android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'realm-Android'

Android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"


    defaultConfig {
        applicationId "xxxxxxxxxxxx"
        minSdkVersion 19
        targetSdkVersion 24
        versionCode 123
        versionName "1.2.3"
        manifestPlaceholders = [HOCKEYAPP_APP_ID: "xxxxxxxxxxxxxxxxxxxxx"]

        //For Test
        testInstrumentationRunner "Android.support.test.runner.AndroidJUnitRunner"

    }

    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('com.mikepenz:materialdrawer:4.6.4@aar') {
        transitive = true
    }

    //For Test
    androidTestCompile 'com.Android.support:support-annotations:24.2.1'
    //noinspection GradleCompatible
    androidTestCompile 'com.Android.support.test:runner:0.5'
    androidTestCompile 'com.Android.support.test:rules:0.5'
    androidTestCompile 'com.Android.support.test.espresso:espresso-core:2.2.2'

    compile 'com.Android.support:appcompat-v7:24.2.1'
    compile 'com.Android.support:design:24.2.1'
    compile 'com.Android.support:cardview-v7:24.2.1'
    compile 'com.Android.support:recyclerview-v7:24.2.1'
    compile 'com.Android.support:support-v4:24.2.1'
    compile 'com.Android.support:support-v13:24.2.1'
    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
    compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
    compile 'com.squareup.okhttp3:okhttp:3.1.2'

    compile 'com.jakewharton:butterknife:7.0.1'

    compile 'com.p_v:flexiblecalendar:1.1.4'
    compile 'br.com.zbra:Android-linq:1.0.1'

    compile 'com.google.Android.gms:play-services-maps:9.4.0'

    compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
    compile 'com.cardiomood.Android:android-widgets:0.1.1'
    compile 'com.github.thorbenprimke:realm-recyclerview:0.9.14'

    compile 'net.hockeyapp.Android:HockeySDK:4.0.0'
}

これは私のbuild.gradleです(プロジェクト:MyApp):

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.Android.tools.build:gradle:3.0.1'
        classpath 'me.tatarka:gradle-retrolambda:3.2.3'
        classpath "io.realm:realm-gradle-plugin:0.88.3"
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}

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

サードパーティのAndroid-aptプラグインはサポートされなくなりました。依存関係の解決を遅延処理するように改善された、組み込みの注釈プロセッササポートに切り替える必要があります。

Androidプラグイン3.0.0を使用する場合、以下に示すように、annotationProcessor依存関係構成を使用してプロセッサークラスパスにアノテーションプロセッサーを追加する必要があります。

dependencies {
    ...
    annotationProcessor 'com.google.dagger:dagger-compiler:<version-number>'
}

Android Gradle Plugin 3.0.0 at https://developer.Android.com/studio/build/gradle-plugin-3-0-0)への完全な移行ガイドをお読みください-migration.html


Retrolambdaはもう必要ありません。新しいAndroid GradleプラグインはJava 8つの言語機能をサポートします。 詳細はこちら


移行ガイドに従っていると仮定すると、エラーは古いRealmプラグインが原因で発生します。

Realmプラグインは、すべてのRealm依存関係をバックグラウンドで管理します。これは、古いバージョンが新しいツールをサポートしていないことも意味します。

annotationProcessor構成は、 changelog に見られるように、Realm2.2.0で最初にサポートされます。

機能強化

  • Android Gradle Plugin 2.2.0以降で提供されるannotationProcessor構成のサポートが追加されました。Realmプラグインは、使用可能な場合はannotationProcessor構成ではなく、apt構成にアノテーションプロセッサを追加し、com.neenbedankt.Android-aptプラグインは使用されません。Kotlinプロジェクトでは、kapt構成の代わりにannotationProcessorが使用されます(#3026)。

実際には、2つのオプションがあります。

  • レルムを少なくとも2.2.0に更新するか、
  • Android Gradle Plugin2.3.3に戻ります。
9
Eugen Pechanec