在 android studio 裏要加入一個 3rd party 的 library 其實不是很麻煩, 祇是現在沒有 UI, 所以需要一些手動作業。看來 google 很看好 android studio,所以 UI 應該很快就會支援了。在此之前,姑且請依照以下方法來新增 library。

android studio 核心是 IntelliJ,但在編譯 apk 時,他用的是 gradle。intelliJ 是一個素有名氣的 IDE,裏面可以 refactor 的玩意多著,很值得用用看,它有 UI 可以添加 library dependency。但問題是 gradle,gradle 呢是一個跟 maven 有點類似的 build management 系統,不過 gradle 的語法比 maven 的 xml 要簡潔明瞭得多,也值得繼續研究。目前 android studio 還沒有 UI 可以編輯 gradle,一切都要使用純文字檔,還好也不太難就是了。

所以呢,要從 maven repository 新增 library 需要以下的步驟:

  • 首先來到 http://search.maven.org/,用 search 找到你要的 library

    今天就先以 gson 為例

  • 打開主要專案的 build.gradle

    舉個例子,最上層是 ExampleProject,這個是 container 可以包含各個相關的子專案,它下面又有一個 Example 這個才是主專案,build.gradle 就在 Example 這目錄裏。

  • 將以下幾行加入

    repositories {
    mavenCentral()
    } dependencies {
    compile 'com.android.support:support-v4:13.0.+'
    compile group: 'com.google.code.gson', name: 'gson', version: '2.2.4'
    compile files ('libs/android-async-http-1.4.3.jar')
    }

    其中 compile group: 'com.google.code.gson', name: 'gson', version: '2.2.4' 當然就是來自 maven repository 的 gson 函式庫資訊了。

  • 等 android studio 抓一下檔案,很快就會發現到 External libraries 裏多了一行


這些作完,應該就大功告成了。

Android studio: 自 maven 增加一個函式庫的更多相关文章

  1. C++ 檔案、資料夾、路徑處理函式庫:boost::filesystem

    原帖:https://tokyo.zxproxy.com/browse.php?u=uG7kXsFlW1ZmaxKEvCzu8HrCJ0bXIAddA1s5dtIUZ%2FYzM1u9JI7jjKLT ...

  2. 【转】如何使用Android Studio把自己的Android library分发到jCenter和Maven Central

    转自:http://www.devtf.cn/?p=760&utm_source=tuicool 如何使用Android Studio把自己的Android library分发到jCenter ...

  3. 拥抱 Android Studio 之四:Maven 仓库使用与私有仓库搭建

    使用.创造和分享 笔者曾经不思量力的思考过『是什么推动了互联网技术的快速发展?』这种伟大的命题.结论是,除了摩尔定律之外,技术经验的快速积累和广泛分享,也是重要的原因. 有人戏称,『写 Java,首先 ...

  4. 如何通过Android Studio发布library到jCenter和Maven Central

    http://www.jianshu.com/p/3c63ae866e52# 在Android Studio里,如果你想引入任何library到自己的项目中,只需要很简单的在module的build. ...

  5. How to distribute your own Android library through jCenter and Maven Central from Android Studio

    In Android Studio, if you wish to include any library to your application. You could just simply add ...

  6. Android studio Maven仓库使用

    原文:How to distribute your own Android library through jCenter and Maven Central from Android Studio ...

  7. Android Studio 3.0 新特性

    最新Android Studio版本是Android Studio 3.0,本文提供了所有新功能和更改的摘要. 所有这些功能都可以在最新的金丝雀版本中发布,但beta测试版本可能尚未提供. 核心IDE ...

  8. Android Studio3.0 新特性 ~ New Features in Android Studio Preview (译文)

    原文地址:https://developer.android.google.cn/studio/preview/features/index.html 最新Android Studio版本是Andro ...

  9. Android Studio 3.4 修改 .android 和.gradle缺省目录-windows7x64专业版环境。

    说明:缺省会在用户目录建立.android和.gradle目录.会挤满C盘.可以改变缺省目录. 改变.gradle目录路径示例,修改到D:\android目录,步骤: 1.建立d:\android目录 ...

随机推荐

  1. [LeetCode]题解(python):020-Valid Parentheses

    题目来源: https://leetcode.com/problems/valid-parentheses/ 题意分析: 这道题输入一段只包括括号的字符串,判断这个字符串是否已经配对.配对的规则是,每 ...

  2. python中的map,filter,zip函数

    map() Return an iterator that applies function to every item of iterable, yielding the results 例如: a ...

  3. fork 函数的一点学习

    昨天某位少年问了我一个问题,#include<stdio.h> int main() { fork(); fork(); fork(); printf("hello " ...

  4. 为了肾六(dp)

    为了肾六 时间限制:4000 ms  |  内存限制:210535 KB 难度:2   描述 最近肾六很流行,goshawk看身边的朋友都用上了apple.自己还用着W年前的Samsung.于是决定去 ...

  5. ThinkPHP - 缓存使用

    用法: 需要使用不同的缓存方式的时候 需要重新初始化,如果不初始化直接调用的话,则会按照系统配置自动初始化.初始化的返回值,可以直接操作缓存: $cache = cache(array('type'= ...

  6. Spark源码阅读@ListenerBus 的实现

  7. C#_会员管理系统:开发一(用户登录)

    首先创建数据库: [Vip] 创建三张表: 分别是: [VipInformation](会员信息) [Log](日志) [VipAccount](账户权限) 详细语句: --创建数据库[Vip] cr ...

  8. c++ ,protected 和 private修饰的构造函数

    c++ protected 和 private修饰的构造函数: 1.在类的外部创建对象时,不能调用protected或private修饰的构造函数. 2.当子类中的构造函数调用父类的private构造 ...

  9. CentOS 6.4安装(超级详细图解教程)

    链接地址:http://www.osyunwei.com/archives/5855.html CentOS 6.4安装(超级详细图解教程) 附:CentOS 6.4下载地址 32位:http://m ...

  10. 流行的Python项目汇总

    年有哪些流行的Python项目呢?下面,我们一起来看下. 一.测试和调试 python_koans :Python Koans 算 “Ruby Koans” 的一部分,作为交互式教程,可以学习 TDD ...