Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
14
Help us understand the problem. What is going on with this article?
@takke

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

More than 5 years have passed since last update.

既存のプロジェクトをさくっと取り込みたいような場合に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
Help us understand the problem. What is going on with this article?
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
takke
Android用TwitterクライアントのTwitPaneなどを開発しています。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
14
Help us understand the problem. What is going on with this article?