LoginSignup
2
2

More than 5 years have passed since last update.

特定のproductFlavor/buildTypeでだけ使用するライブラリプロジェクトを作る

Posted at

1 前提

AndroidStudio 1.3
productFlavor、buildTypeの設定は完了していて、以下のflavorがあるものとする
develop
staging
producFlavorの設定の仕方は以下を参照。
AndroidStudio1.3でproductFlavor (外部参照jarまで差し替えるよ)
http://qiita.com/le_skamba/items/af290f53f6d5ac0a2603

2 最終目標

あるproductFlavor/buildTypeでだけ、使用するライブラリプロジェクトを作成し、参照する

3 手順

(1) ライブラリプロジェクトを作成

「File」-「New」-「New Module」で必要なライブラリプロジェクトタイプを選び、必要な情報を記入後、Finishをクリック。
当然importでも問題ない。

(2) build.gradle(app)のdependenciesに記述を追加。

staging flavorにおいて、作成したnewLibraryを参照する場合。

build.gradle(app)
dependencies {
    (省略)

    stagingCompile project(':newLibrary')
}

ProductFlavorsを使いこなすと、ガワが違うだけだったり、広告SDKだけ変えて・・・なんていう横展開アプリも楽に作れるようになりますね。

2
2
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
2
2