[英]How to set up compile library in android studio. LOMBOK
Help me to set up comile dependencies in Android Studio in build.gradle. 帮助我在build.gradle中的Android Studio中设置comile依赖项。 I mean that they not include into final APK.
我的意思是他们不包括最终的APK。
this build.gradle works fine but i don't need 这个build.gradle工作正常,但我不需要
lombok
龙目岛
library in apk in runtime; apk在运行时的库;
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 16
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
} }
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'org.projectlombok:lombok:1.12.2' }
And may be its possible to setup in global build.gradle file for all projects? 也许可以在所有项目的全局build.gradle文件中进行设置?
With Android Studio 1.1.0, I couldn't find a consolidated set of instructions for adding Lombok that worked for me. 使用Android Studio 1.1.0,我找不到一组合并的说明,用于添加适用于我的Lombok。 That includes Lombok's own setup page: http://projectlombok.org/setup/android.html
这包括Lombok自己的设置页面: http : //projectlombok.org/setup/android.html
Here's everything I had to do to get it working (on OS X): 以下是我必须做的所有工作(在OS X上):
Browse repositories...
Browse repositories...
Install plugin
Install plugin
provided 'org.projectlombok:lombok:1.16.2'
provided 'org.projectlombok:lombok:1.16.2'
subprojects
approach in build.gradle in the project root (from Олександр Самсонов's answer) works also, but it appears that requires moving the configuration from app/build.gradle (you aren't allowed to further extend the configuration in the subprojects). subprojects
方法(来自ОлександрСамсонов的答案)也可以,但似乎需要从app / build.gradle移动配置(不允许进一步扩展子项目中的配置) )。 I didn't want to move the entire android configuration, so I kept it in the app/build.gradle instead. lombok.config
file in the root of the project containing two lines: lombok.anyConstructor.suppressConstructorProperties = true
lombok.addGeneratedAnnotation = false
lombok.config
文件: lombok.anyConstructor.suppressConstructorProperties = true
lombok.addGeneratedAnnotation = false
The ability to do this was just added to the v0.8 Android-Gradle plugin, which you can use if you're running Android Studio 0.4.3 (which is available on the canary update channel). 执行此操作的能力刚刚添加到v0.8 Android-Gradle插件中,如果您运行的是Android Studio 0.4.3(可在金丝雀更新频道上使用),则可以使用该插件。
It's mentioned in the release notes and a thread on the adt-dev mailing list 它在发行说明和adt-dev邮件列表中的一个帖子中提到过
You specify it like this: 你这样指定:
dependencies {
provided 'org.projectlombok:lombok:1.12.2'
}
I've filed bug https://code.google.com/p/android/issues/detail?id=65216 to request the ability to edit this through the Dependencies panel in the
Project Structure dialog;
我已经提交了错误https://code.google.com/p/android/issues/detail?id=65216 ,请求通过“ 项目结构”对话框中的“
依赖关系”面板进行编辑。 for the moment you have to edit your
build.gradle file by hand to use this.
目前你必须手动编辑build.gradle文件才能使用它。
As for whether you can put it in the top-level build.gradle file to have it apply to all modules, I'm not certain.
至于你是否可以将它放在顶级build.gradle文件中以使其适用于所有模块,我不确定。 I tried putting it in the
allprojects
block, but Gradle told me that the default dependency handler didn't know what to do with it. 我尝试将它放在
allprojects
块中,但是Gradle告诉我默认的依赖处理程序不知道如何处理它。 So I'm guessing no, but if I get other information, I'll update this answer. 所以我猜不是,但如果我得到其他信息,我会更新这个答案。
For Android Studio 对于Android Studio
I resolve this issue by changing gradle-wrapper.properties
file in gradle folder. 我通过更改
gradle-wrapper.properties
文件夹中的gradle-wrapper.properties文件来解决此问题。 Now it looks like this: 现在它看起来像这样:
#Sat Jan 25 02:59:06 EET 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
and in main build.gradle
file i can wrote this for lombok 在main
build.gradle
文件中,我可以为build.gradle
写这个
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
subprojects {
apply plugin: 'android'
buildscript {
repositories {
mavenCentral()
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 16
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
provided 'org.projectlombok:lombok:1.12.2'
}
}
Now in sub projects i don't need write many params for plugins or repositories and provided method works pretty fine. 现在在子项目中,我不需要为插件或存储库编写许多参数,并且提供的方法非常好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.