添加支持库到Android Studio项目 [英] Add support library to Android Studio project

查看:713
本文介绍了添加支持库到Android Studio项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚安装了新的Andr​​oid 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.

这篇关于添加支持库到Android Studio项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆