【问题标题】:How to use Android Annotations and its annotation processor with jack?如何将 Android Annotations 及其注解处理器与 jack 一起使用?
【发布时间】:2017-03-04 07:11:03
【问题描述】:

有人知道如何将 Android Annotations 与 jack 编译器一起使用吗?

Here我的 app/build.gradle 和here我的项目 build.gradle

使用此配置,我在构建项目时收到此错误消息:

Error:Could not get unknown property 'classpath' for task ':app:transformJackWithJackForDebug' of type com.android.build.gradle.internal.pipeline.TransformTask.

【问题讨论】:

    标签: android gradle android-annotations annotation-processing jack


    【解决方案1】:

    您应该完全删除 android-apt 插件和 apt 块,因为它不适用于 Jack 注释处理。此外,您必须在 annotationProcessor 配置中声明处理器。最后还要给jack(which has no public API per-variant, yet)添加注解处理参数。

    这是你修改后的build.gradle

    repositories {
        jcenter()
        mavenCentral()
    }
    
    
    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 24
        buildToolsVersion "24.0.2"
        defaultConfig {
            applicationId "com.frlgrd.streamzone"
            minSdkVersion 21
            targetSdkVersion 24
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            jackOptions {
                enabled true
            }
        }
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    // Android Annotations
    def AAVersion = '4.0.0'
    
    dependencies {
    
        // Google
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support:appcompat-v7:24.2.1'
        compile 'com.android.support:design:24.2.1'
    
        // Android Annotations
        annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
        compile "org.androidannotations:androidannotations-api:$AAVersion"
    
        // RX
        compile 'com.tbruyelle.rxpermissions:rxpermissions:0.7.1@aar'
        compile 'io.reactivex:rxandroid:1.2.1'
        compile 'io.reactivex:rxjava:1.1.6'
    }
    
    // add annotation processing options to jack
    android.applicationVariants.all { variant ->
        variant.variantData.variantConfiguration.javaCompileOptions.annotationProcessorOptions
                .arguments = ['androidManifestFile': variant.outputs[0]?.processResources?.manifestFile?.absolutePath]
    }
    

    【讨论】:

    • 不适用于我(compileSdkVersion 25buildToolsVersion '25.0.2'targetSdkVersion 23AAVersion = '4.2.0'
    • @WonderCsabo 编译器告诉 SomeClass_ 类未找到,这意味着 AA 的注释处理器未处理,因此未找到生成的类。
    • 您能针对您的问题提出一个新问题吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-14
    • 1970-01-01
    • 1970-01-01
    • 2016-05-05
    • 1970-01-01
    • 1970-01-01
    • 2020-01-15
    相关资源
    最近更新 更多