出现此错误时如何解决gradle?

时间:2019-02-18 08:54:23

标签: java android-studio android-gradle

我开始了一个新项目,并放置了火基云:

apply plugin: 'com.android.application'
apply plugin: 'android-apt'

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

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    testImplementation 'junit:junit:4.12'

// RecyclerView
implementation 'com.android.support:recyclerview-v7:28.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 'com.android.support:preference-v7:28.0.0'

// Firebase dependency
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
}
// Apply the Google Services plugin. Make sure to add the google-services.json file in the app
// folder. You download it from the Firebase console
apply plugin: 'com.google.gms.google-services'

此错误消失了:

  

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

2 个答案:

答案 0 :(得分:1)

这可能是因为apt plugin which is already obsolete。因此,您需要删除以下内容:

apply plugin: 'android-apt'

然后更改以下内容:

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

具有:

annotationProcessor 'net.simonvt.schematic:schematic-compiler:0.6.3'

答案 1 :(得分:0)