Ren*_*los 5 android gradle android-studio android-apt realm-java
我是Android开发的新手,并获得了一个遗留项目.所以我安装了最新版本的Android Studio并打开它.
当我尝试构建它时,我收到此错误:
Error:android-apt plugin is incompatible with the Android Gradle plugin. Please use 'annotationProcessor' configuration instead.
Run Code Online (Sandbox Code Playgroud)
我正在尝试这些线程中显示的解决方案,但它没有用.
我的grandle构建脚本上没有任何android-apt参考.
许多编译包显示为过时.但是,当我按照Android的工作室建议更新参考时,我得到错误,说找不到包.
正如我所说的,我是Android Studio World的新手,所以我对这些东西都有些失落.
这是我的build.gradle(模块:app):
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'
}
Run Code Online (Sandbox Code Playgroud)
这是我的build.gradle(Project: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
}
Run Code Online (Sandbox Code Playgroud)
不再支持第三方android-apt插件.您应该切换到内置的注释处理器支持,该支持已经过改进,可以懒惰地处理解析依赖关系.
使用Android插件3.0.0时,必须使用annotationProcessor依赖关系配置将注释处理器添加到处理器类路径,如下所示:
Run Code Online (Sandbox Code Playgroud)dependencies { ... annotationProcessor 'com.google.dagger:dagger-compiler:<version-number>' }
请阅读https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html上的 Android Gradle Plugin 3.0.0完整迁移指南.
不再需要Retrolambda.新的Android Gradle插件支持Java 8语言功能.在这里阅读更多.
假设您遵循迁移指南,则错误是由旧Realm插件引起的.
Realm插件管理幕后的所有Realm依赖项.这也意味着它的旧版本不支持新工具.
annotationProcessor如更改日志中所示,Realm 2.2.0中首先支持配置:
增强功能
- 添加了对
annotationProcessorAndroid Gradle Plugin 2.2.0或更高版本提供的配置的支持.Realm插件将其注释处理器添加到annotationProcessor配置而不是apt配置(如果可用com.neenbedankt.android-apt且不使用插件).在Kotlin项目中,kapt使用的是代替annotationProcessor配置(#3026).
实际上你有两个选择:
| 归档时间: |
|
| 查看次数: |
7403 次 |
| 最近记录: |