LoginSignup
5
1

More than 5 years have passed since last update.

Android Studioでライブラリを取り込む3つの方法

Posted at

3種類があります。

A. libs配下にjarを配置

jarのファイル名はandroid-support-v4.jarとする。
${module}/libsフォルダを作成する
moduleは適宜変更してください。
jarファイルを${module}/libsフォルダに配置する
${module}/build.gradleにjarのパスを指定するため以下のように追記


dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile files('libs/android-support-v4.jar')
}
B. ライブラリのprojectフォルダを読み込む

facebook sdkなどを組み込むときに用いる。
今回はGit Submoduleを利用して、ライブラリを取り込む。
取り込むライブラリはJohnPersano/SuperToastsを使わせてもらいました。
ライブラリプロジェクトが手元にある場合は、dependenciesの追加からでOKです。

C. 外部のリポジトリからローカルに取り込む

Maven Centralなどにjarやaarが公開されている場合に用いることが出来る。

${module}/build.gradleにリポジトリを指定する記述を追記する。


dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile files('libs/android-support-v4.jar')
    compile project(':SuperToasts:supertoasts')
    compile 'com.github.sakebook:DialogHelper:0.1.1@aar'
}
5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1