編輯:關於Android編程
好東西,最近比較忙,沒時間翻譯了,抱歉 菜鳥的成長史
The android-apt plugin assists in working with annotation processors in combination with Android Studio. It has two purposes:
Allow to configure a compile time only annotation processor as a dependency, not including the artifact in the final APK or librarySet up the source paths so that code that is generated from the annotation processor is correctly picked up by Android Studio.This plugin requires the android or android-library plugin (version 0.7.x or up) to be configured on your project.
Add the following to your build script to use the plugin:
buildscript { repositories { mavenCentral() }
dependencies {
// replace with the current version of the Android plugin
classpath 'com.android.tools.build:gradle:0.7.3'
// the latest version of the android-apt plugin
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2' }
}
apply plugin: 'android'apply plugin: 'android-apt'
Some annotation processor may require to pass custom arguments, you can use apt.argumentsfor that purpose. For instance Android Annotation library needs the following configuration:
apt { arguments { resourcePackageName android.defaultConfig.packageName androidManifestFile variant.processResources.manifestFile }}
Make sure to configure packageName in the android defaultConfig block for this purpose. The arguments are processed for each variant when the compiler is configured. From this closure you can reference android, project and variant for the current variant.
Annotation processors generally have a API and a processor that generates code that is used by the API. Depending on the project the processor and the API might be split up in separate dependencies. For example,Dagger uses two artifacts called dagger-compiler and dagger. The compiler artifact is only used during compilation, while the main dagger artifact is required at runtime.
To aid in configuring this dependency, the plugin adds a Gradle configuration named apt that can be used like this:
dependencies { apt 'com.squareup.dagger:dagger-compiler:1.1.0' compile 'com.squareup.dagger:dagger:1.1.0'}
For annotation processors that include the API and processor in one artifact, there's no special setup. You just add the artifact to the compile configuration like usual and everything will work like normal. Additionally, if code that is generated by the processor is to be referenced in your own code, Android Studio will now correctly reference that code and resolve references to it.
This plugin is based on a script that I've been using for some time which is the result of this post on Google+ and this post on StackOverflow.com. Variations of the SO post and my gists have been floating around for a while on the interwebs. That, and the fact that including scripts is a bit inconvenient pushed me to create this plugin.
This plugin is created by Hugo Visser and released in the public domain. Feel free to use and adapt as you like. To get in touch, hit me up onTwitter orGoogle Plus. @
Andrioid 編譯系統是你用於build,test,runapp的工具箱。編譯系統的運行,可以通過Android Studio的菜單或者是獨立的命令行。通過編譯系統的
第一步、打開風雲直播,點擊首頁右下角“我”。第二步、進入我的界面,點擊右上角“設置”按鍵,進入設置界面,將彈
隨著移動互聯網的快速發展,它已經和我們的生活息息相關了,在公交地鐵裡面都能看到很多人的人低頭看著自己的手機屏幕,從此“低頭族”一詞就產生了,作為一名移動行業的開發人員,我
“點九”是andriod平台的應用軟件開發裡的一種特殊的圖片形式,文件擴展名為:.9.png 智能手機中有自動橫屏的功能,同一幅界面會在隨著手機(或平