14
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AndroidStudioでmainのディレクトリ構成を使わない方法

Last updated at Posted at 2014-07-08

既存のプロジェクトをさくっと取り込みたいような場合にAndroidStudio/gradleの標準ディレクトリ構成(src/main/java)に変更するのがめんどくさかったり、無駄だったり、git/svnなどのVCSとの相性が悪かったりすることがあるので、build.gradle でなんとかならないか調べた。

今回は twitter-text-java を修正したかったので。

build.gradle
apply plugin: 'com.android.library'

android {
    compileSdkVersion 16
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "com.twitter.text"
        versionCode 1
        versionName "1.0"
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
        }
    }
}

上記のように sourceSets.main を記述しておくと、Eclipseのディレクトリ構成でそのまま使える。
外部モジュールはこう記述して逃げるというのもアリかなー。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?