【问题标题】:Getting apt error while upgrading to gradle 3.0 version in android studio 3.0在 android studio 3.0 中升级到 gradle 3.0 版本时出现 apt 错误
【发布时间】:2017-12-13 11:21:25
【问题描述】:

我想更新我的项目以在 android studio 3.0 中运行。更新时,apt 出现错误。我改变了我完整的build.gradle 意味着所有编译到实现。这是我的build.gradle 文件。

这是我的错误:

错误:android-apt 插件与 Android Gradle 插件不兼容。请改用“annotationProcessor”配置。

这是我的build.gradle

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


android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "com.sample"
        minSdkVersion 19
        targetSdkVersion 26
        multiDexEnabled true
}
lintOptions {
    checkReleaseBuilds false
    abortOnError false
}
configurations{
    all*.exclude module: 'servlet-api'
}
dexOptions {
    javaMaxHeapSize "4g"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'

   }
   configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-annotations:26.0.2'
    }
}

}

dependencies {
implementation project(':androidHorizontalListView')
implementation project(':library')
implementation project(':simpl3r')



implementation  'com.google.code.gson:gson:2.2.4'
implementation  files('libs/acra-4.5.0.jar')
implementation  files('libs/bugsense-3.6.jar')
implementation  files('libs/espresso-1.1-bundled.jar')
implementation  files('libs/sample-2.4.1.jar')
implementation  files('libs/signpost-commonshttp4-1.2.1.1.jar')
implementation  files('libs/signpost-core-1.2.1.1.jar')
implementation  files('libs/twitter4j-core-4.0.2.jar')
implementation  files('libs/universal-image-loader-1.9.2-SNAPSHOT-with-sources.jar')
implementation  files('libs/volley.jar')
implementation  files('libs/YouTubeAndroidPlayerApi.jar')
implementation  files('libs/gcm.jar')
implementation  files('libs/mint-5.2.1.jar')
implementation project(':swipelibrary')


implementation  files('libs/glide-3.7.0.jar')
implementation  files('libs/glide-3.7.0-javadoc.jar')
implementation  'org.jsoup:jsoup:1.8.3'
implementation  'org.mozilla:rhino:1.7.7'
implementation  'info.guardianproject.netcipher:netcipher:1.2'
implementation  'com.nineoldandroids:library:2.4.0'
implementation  'com.thefinestartist:utils:0.9.1'
apt 'com.thefinestartist:compilers:0.9.1'
implementation  'com.android.support:recyclerview-v7:26.0.2'
implementation  'in.srain.cube:grid-view-with-header-footer:1.0.12'
implementation  'joda-time:joda-time:2.9.2'
implementation  'com.writingminds:FFmpegAndroid:0.3.2'

//implemented retrofit.
testImplementation 'junit:junit:4.12'


implementation  'com.android.support:appcompat-v7:26.0.2'
implementation  'com.squareup.retrofit:retrofit:1.9.0'

implementation  'com.google.android.gms:play-services-analytics:10.2.1'
implementation  'com.facebook.android:facebook-android-sdk:4.26.0'

implementation  'com.android.support:design:26.0.2'
implementation  'com.flurry.android:analytics:6.3.1'
implementation project(':sample-chat')


implementation  'com.quickblox:quickblox-android-sdk-core:3.1.0'
implementation  "com.google.android.gms:play-services-gcm:10.2.1"


implementation project(':sample-core')

}

【问题讨论】:

标签: android gradle apt


【解决方案1】:

你通过this answer开启注解处理,然后你可以删除该行

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

替换

apt 'com.thefinestartist:compilers:0.9.1'

annotationProcessor 'com.thefinestartist:compilers:0.9.1'

【讨论】:

  • 如果我这样改变我会得到这个错误............错误:java.util.concurrent.ExecutionException:com.android.tools.aapt2.Aapt2Exception:AAPT2错误:查看日志了解详情
  • 你检查日志了吗?尝试打开 Android Studio 右下角的 Gradle 控制台并阅读红色文本。您可能必须跟踪堆栈跟踪到出现的第一个错误。 StackOverflow 上还有其他问题可以解决此问题,例如:stackoverflow.com/questions/46988102/…
【解决方案2】:

1) 从项目的build.gradle 文件中删除以下行:

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

2) 替换:apt 'com.thefinestartist:compilers:0.9.1'

annotationProcessor 'com.thefinestartist:compilers:0.9.1'

3) 转到您的 gradle.properties 编写以下代码并同步您的项目: android.enableAapt2=false

用于解决 com.android.tools.aapt2.Aapt2Exception: AAPT2 错误

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多