android studio配置AndroidAnnotations
2015-07-06 20:25
561 查看
现在很多人都使用Android studio开发工具代替eclipse了,当然的 在eclipse使用的好的一些开发框架也会对应的在android studio上面使用。
参考文档:http://blog.csdn.net/u011850815/article/details/42213835
http://blog.csdn.net/hanhailong726188/article/details/40585057
本文就是讲如何在android studio下配置并使用AndroidAnnotations。
闲话不多说,你新建一个项目后,在你的app/目录下有一个build.gradle(称这个为局部gradle).
在此文件中添加下面一些配置:
apply plugin:'android-apt'
def AAVersion='3.0.1'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
apt "org.androidannotations:androidannotations:$AAVersion"
}
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName "com.example.org.myapplication(你项目的包名)"
}
}
在gradle/目录下同样存在一个build.gradle文件(此成为全局gradle),在此文件中添加以下内容:
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
然后把你manifest文件中的activity名后面加上一个_ 注意这个时候android studio会报错。你只需编译一下
点击Refactor下面那个向下的箭头就可以编译成功。
最后你就可以在android studio下面使用AndroidAnnotations框架进行开发咯。具体的AndroidAnnotations使用方法百度一下有很多资料、这里就不详细说明咯。
备注:由于gradle版本越来越高。gradle2.2.1的版本中编译的时候会遇到Could not find property 'processResources' on com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated这个错误,这种错误是由于gradle的版本引起的,在新版本的gradle中的写法为:androidManifestFile variant.outputs[0].processResources.manifestFile
参考文档:http://blog.csdn.net/u011850815/article/details/42213835
http://blog.csdn.net/hanhailong726188/article/details/40585057
本文就是讲如何在android studio下配置并使用AndroidAnnotations。
闲话不多说,你新建一个项目后,在你的app/目录下有一个build.gradle(称这个为局部gradle).
在此文件中添加下面一些配置:
apply plugin:'android-apt'
def AAVersion='3.0.1'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
apt "org.androidannotations:androidannotations:$AAVersion"
}
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName "com.example.org.myapplication(你项目的包名)"
}
}
在gradle/目录下同样存在一个build.gradle文件(此成为全局gradle),在此文件中添加以下内容:
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
然后把你manifest文件中的activity名后面加上一个_ 注意这个时候android studio会报错。你只需编译一下
点击Refactor下面那个向下的箭头就可以编译成功。
最后你就可以在android studio下面使用AndroidAnnotations框架进行开发咯。具体的AndroidAnnotations使用方法百度一下有很多资料、这里就不详细说明咯。
备注:由于gradle版本越来越高。gradle2.2.1的版本中编译的时候会遇到Could not find property 'processResources' on com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated这个错误,这种错误是由于gradle的版本引起的,在新版本的gradle中的写法为:androidManifestFile variant.outputs[0].processResources.manifestFile
androidManifestFile variant.processResources.manifestFile(老版本写法)
androidManifestFile variant.outputs[0].processResources.manifestFile(新版本写法)import org.androidannotations.annotations.EActivity; @EActivity(R.layout.activity_main) public class MainActivity extends Activity { }
相关文章推荐
- android 沉浸式状态栏(像ios那样的状态栏与应用统一颜色样式)
- 解决Android5.0 ListView快速滚动后,接近顶部时滚动方向反向的bug
- Android内核开发:从源码树中删除出厂的app应用
- Android入门(13)——GridView使用汇总
- 文章标题
- Android TelephonyManager类
- 文章标题
- Android中手机号、车牌号正则表达式
- android:layout_gravity和android:gravity的区别
- Android apk的启动过程
- Android全局异常处理(捕获异常,不弹出程序崩溃)
- 如何Android中自定义Navigationbar
- Android studio 多渠道打包
- Android Notification详解——响应notification事件
- Android 5.0 之 Material Desigin初步窥探及Android Studio项目搭建[一]
- android TextView字体切换
- Android 反编译 -smali语法
- Android Intents和Intent过滤器(二)
- Android Intents和Intent过滤器(一)
- Android Telephony纲要