我刚安装了新的Android Studio和我正在寻找一种方式来导入支持库为Android。
I just installed the new Android Studio and I'm looking for a way to import the support library for Android.
如果是的选择吗?在Eclipse的只是点击两下。我用Google搜索,但一无所获。当然,这是太新了。
Where is the option for that? In Eclipse that are just two clicks. I googled for it but found nothing. Surely it is too new.
虽然Android的工作室是基于IntelliJ IDEA的,同时它依赖于摇篮建立你的apk。截至0.2.3,这两个没有很好地从GUI配置的长期玩。 其结果是,除了使用GUI来作为@skyfishjy提到设置的依赖关系,它也将需要以手动编辑build.gradle文件
Although android studio is based on IntelliJ IDEA, at the same time it relies on gradle to build your apk. As of 0.2.3, these two doesn't play nicely in term of configuring from GUI. As a result, in addition to use the GUI to setup dependencies as @skyfishjy mentioned, it will also require you to edit the build.gradle file manually.
假设你有一个测试项目>测试结构。 您正在寻找位于TestProject的/测试/ build.gradle的build.gradle文件
Assuming you have a Test Project > Test structure. The build.gradle file you're looking for is located at TestProject/Test/build.gradle
查找依赖关系部分,并确保您有
Look for the dependencies section, and make sure you have
编译com.android.support:support-v4:13.0 +
compile 'com.android.support:support-v4:13.0.+'
下面是一个例子。
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
您也可以从Maven仓库中添加第三方库
You can also add 3rd party libraries from the maven repository
编译组:com.google code.gson',名称:GSON版本:2.2.4
compile group: 'com.google.code.gson', name: 'gson', version: '2.2.4'
在上面的代码将增加GSON 2.2.4你。
The above snippet will add gson 2.2.4 for you.
在我的实验,似乎增加了摇篮也会设置正确的IntelliJ依赖你。
In my experiment, it seems that adding the gradle will also setup correct IntelliJ dependencies for you.