Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at


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

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

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のディレクトリ構成でそのまま使える。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
Help us understand the problem. What are the problem?