前两天看了一下android的一个开源框架androidannotation,网上都说它可以帮助我们程序员减少很多的重复的工作;于是我就好奇的去尝试了下,没想到一搞就是两天,android studio的配置算是OK了,但是eclipse的配置还没有OK,编译出错,很郁闷
错误代码:
[2015-08-23 16:15:23 - Dex Loader] Unable to execute dex: Multiple dex files define Lorg/androidannotations/annotations/AfterExtras;
[2015-08-23 16:15:23 - androidAnnotation] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/androidannotations/annotations/AfterExtras;
[2015-08-23 16:23:17 - Dex Loader] Unable to execute dex: Multiple dex files define Lorg/androidannotations/annotations/AfterExtras;
[2015-08-23 16:23:17 - androidAnnotation] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/androidannotations/annotations/AfterExtras;
[2015-08-23 16:24:14 - Dex Loader] Unable to execute dex: Multiple dex files define Lorg/androidannotations/annotations/AfterExtras;
[2015-08-23 16:24:14 - androidAnnotation] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/androidannotations/annotations/AfterExtras;
[2015-08-23 16:32:41 - Dex Loader] Unable to execute dex: Multiple dex files define Lorg/androidannotations/annotations/AfterExtras;
[2015-08-23 16:32:41 - androidAnnotation] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/androidannotations/annotations/AfterExtras;
[2015-08-23 18:02:26 - Dex Loader] Unable to execute dex: Multiple dex files define Lorg/androidannotations/annotations/AfterExtras;
[2015-08-23 18:02:26 - androidAnnotation] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/androidannotations/annotations/AfterExtras;
[2015-08-23 18:03:58 - Dex Loader] Unable to execute dex: Multiple dex files define Lorg/androidannotations/annotations/AfterExtras;
[2015-08-23 18:03:58 - androidAnnotation] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/androidannotations/annotations/AfterExtras;
郁闷,如果哪位大神会的话请告诉我哪边出错了,灰常感谢!
好了,废话不多说,直接进入主题 打开android studio
新建一个project,
打开project的build.gradle文件
加入一句话
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4+'
上图:
少了这句话,我不能通过编译;
新建一个Module项目:
将.jar包粘贴进libs目录
选中当前module,右键,选择Open Module Settings -->Dependencies 点击 ‘+’ 选择File dependency
将刚才粘贴进libs目录的Jar包导入
确定
打开build.gradle
加入
apply plugin: 'android-apt'
加入
apt{
arguments{
androidManifestFile variant.outputs[0].processResources.manifestFile
}
}
当前denpendencies如上图;
修改
compile --> apt 结果如下:
修改AndroidManifest.xml文件的activity文件名后加 '_',build下
此时,编译仍会报错,可能是重复引入的包的问题,不太明白,
Error:Execution failed for task ':myapplication:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/zjh/zjh/Android/jdk1.8.0_51/bin/java'' finished with non-zero exit value 2
我将最上面一行注释掉,编译成功
hellowWorld运行成功
所有需要修改的地方都在下面两张图片了
project build.gradle
module:build.gradle
第一次发帖,请多多包含