欢迎使用CSDN-markdown编辑器

集成android-apt,报警告解决方法

Android Studio2.3版本,集成dagger,butterknife,使用以前的依赖方式android-apt,如下

这里写图片描述

会报警告

Warning:Using incompatible plugins for the annotation processing: android-apt.This may result in an unexpected behavior.

然后编译运行也会有警告和报类找不到异常
Information:Gradle tasks [:app:assembleDebug]
Warning:Using incompatible plugins for the annotation processing: android-apt. This may result in an unexpected behavior.
D:\Android\ASWork\trunk\Hanfuhui\app\src\main\java\com\hanfuhui\entries\Album.java
Error:(6, 52) 错误: 找不到符号
符号: 类 BR
位置: 程序包 com.android.databinding.library.baseAdapters
D:\Android\ASWork\trunk\Hanfuhui\app\src\main\java\com\hanfuhui\albums\AlbumActivity.java
Error:(8, 32) 错误: 程序包com.hanfuhui.databinding不存在
Error:(19, 13) 错误: 找不到符号
符号: 类 ActivityAlbumBinding
位置: 类 AlbumActivity
D:\Android\ASWork\trunk\Hanfuhui\app\src\main\java\com\hanfuhui\handlers\AlbumHandler.java
Error:(9, 20) 错误: 找不到符号
符号: 类 BR
位置: 程序包 com.hanfuhui
D:\Android\ASWork\trunk\Hanfuhui\app\src\main\java\com\hanfuhui\albums\AlbumFragment.java
Error:(19, 20) 错误: 找不到符号
符号: 类 BR
位置: 程序包 com.hanfuhui
Error:(26, 32) 错误: 程序包com.hanfuhui.databinding不存在
Error:(64, 13) 错误: 找不到符号
符号: 类 ItemSingleLineTopBinding
位置: 类 AlbumFragment

解决方法:
直接删除classpath’com.neenbedankt.gradle.plugins:android-apt:1.8’和applyplugin:’android-apt’,然后将apt替换为annotationProcessor

buildscript {
repositories {
jcenter()

}

dependencies {
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}

}

apply plugin: ‘android-apt’

修改引用为:
修改前
apt “com.google.dagger:dagger-compiler:2.6”
修改后
annotationProcessor “com.google.dagger:dagger-compiler:2.6”

重新同步build,警告没了。但在运行编译时会报其它警告,如下

Information:Gradle tasks [:app:assembleDebug]
D:\Android\ASWork\trunk\Hanfuhui\app\src\main\java\com\hanfuhui\utils\FrescoUtils.java
Error:(141, 24) 警告: Application namespace for attribute app:banner will be ignored.
Error:(154, 24) 警告: Application namespace for attribute app:avatar will be ignored.
Error:(198, 24) 警告: Application namespace for attribute app:fresco will be ignored.
Warning:warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.alipay.android.phone.mrpc.core.c) that doesn’t come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any “-target” type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is not an inner class.

建议直接Github上依赖最新版本.

android-apt报警告是该作者在官网发表声明证实了后续将不会继续维护android-apt,

Google官方 插件提供了名为annotationProcessor的功能来完全代替android-apt

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值