原因:更新Android studio到3.0后原来项目出现问题。
分析:尤其是采用butterknife工具的,采用新的Android Studio都会出现这样的问题,我根据提示最后猜测原因可能是Android studio更新,然后gradle更新了,这样的话可能使原来的android-apt工具跟不上节奏了,所以让采用annotationProcessor工具。
解决:把project下的build.gradle当中的依赖
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath'com.android.tools.build:gradle:3.0.0-alpha7'
classpath'com.neenbedankt.gradle.plugins:android-apt:1.8'
//classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {url"https://jitpack.io"}
}
}
task clean(type: Delete) {
deleterootProject.buildDir
}
修改成如下:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath'com.android.tools.build:gradle:3.0.0-alpha7'
//classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
//classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {url"https://jitpack.io"}
}
}
task clean(type: Delete) {
deleterootProject.buildDir
}
然后再修改Module.app里的build.grade里的配置
然后再把module下的build.gradle:
dependencies {compile'com.github.bumptech.glide:glide:3.7.0'
//butterknife
compile'com.jakewharton:butterknife:8.4.0'
annotationProcessor'com.jakewharton:butterknife-compiler:8.4.0'
//retrofit2
compile'com.squareup.retrofit2:retrofit:2.1.0'
compile'com.squareup.retrofit2:converter-gson:2.1.0'
compile'com.squareup.retrofit2:adapter-rxjava:2.0.1'
compile'com.squareup.okhttp3:logging-interceptor:3.3.0'
//materialicon
compile'net.steamcrafted:materialiconlib:1.1.1'
//dagger2
compile'com.google.dagger:dagger:2.0'
annotationProcessor'com.google.dagger:dagger-compiler:2.0'
再把apply plugin:
‘com.neenbedankt.android-apt ’这个引用给删除。
重新Build的一下
网友评论