无法通过CompileOptions.compilerArgs指定-processorpath或--processor-path [英] Cannot specify -processorpath or --processor-path via `CompileOptions.compilerArgs`

查看:281
本文介绍了无法通过CompileOptions.compilerArgs指定-processorpath或--processor-path的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的应用程序与通过以下警告编译的Firebase消息传递服务链接起来:

INFO:API'variant.getJavaCompile()'已过时,并已替换为'variant.getJavaCompileProvider()'.它将在2019年底删除.有关更多信息,请参见 https://d.android.com/r/tools/task-configuration-avoidance .要确定正在调用variant.getJavaCompile()的内容,请在命令行上使用-Pandroid.debug.obsoleteApi = true来显示更多信息.受影响的模块:app

INFO: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'. It will be removed at the end of 2019. For more information, see https://d.android.com/r/tools/task-configuration-avoidance. To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information. Affected Modules: app

当我运行时,出现以下错误:

*Cannot specify -processorpath or --processor-path via `CompileOptions.compilerArgs`. Use the                `CompileOptions.annotationProcessorPath` property instead.*


**My app gradle content is:**

apply plugin: 'com.android.application'
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'


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

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'androidx.appcompat:appcompat:1.0.0'
    testImplementation 'junit:junit:4.12'

    // RecyclerView
    implementation 'androidx.recyclerview:recyclerview:1.0.0'

    // Schematic dependencies for ContentProvider
    apt 'net.simonvt.schematic:schematic-compiler:0.6.3'
    implementation 'net.simonvt.schematic:schematic:0.6.3'

    // Preferences Dependencies
    implementation 'androidx.preference:preference:1.0.0'

    implementation 'com.google.firebase:firebase-messaging:20.1.3'

}

我的项目gradle内容为:

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

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2'
        classpath 'com.android.tools.build:gradle:3.5.3'


        classpath 'com.google.gms:google-services:4.3.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

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

推荐答案

我通过以下设置解决了我的问题:

I solved my problem with following setps below:

1-通过删除下面的 来删除android-apt插件:

1- Remove android-apt plugin by deleting the line below:

apply plugin: 'android-apt'

2-将 apt 更改为实施

因此 apt'net.simonvt.schematic:schematic-compiler:0.6.3'

So apt 'net.simonvt.schematic:schematic-compiler:0.6.3'

成为 实现'net.simonvt.schematic:schematic-compiler:0.6.3'

become implementation 'net.simonvt.schematic:schematic-compiler:0.6.3'

然后,执行上述2个步骤后,应用程序将崩溃:

Then the app crashes after implementing the 2 steps above:

原因:java.lang.ClassNotFoundException:找不到类"android.example.com.myProject.provider.Generated ... Provider"

3-我通过在应用gradle文件中添加以下代码来解决此错误:

3- I fixed this error with adding this code in app gradle file:

android {
.........
..........
defaultConfig {
        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
            }
        }
}

.....
....
}

这篇关于无法通过CompileOptions.compilerArgs指定-processorpath或--processor-path的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆