Lavan
Lavan

Reputation: 317

Android Studio convert java module to android module

In my Android project i have a few modules. Some of them is android module and some java module. Now i want to convert java module to android module. Is Android studio has standard way for this?

Upvotes: 8

Views: 2284

Answers (1)

Ashwini Atale
Ashwini Atale

Reputation: 89

A Java module uses apply plugin: 'java' in its build.gradle, whereas an Android module uses apply plugin: 'com.android.library'.

Change this in your Java module, along with compileSdkVersion, buildToolsVersion, defaultConfig, and buildTypes.

With all these changes your build.gradle file will look like this:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.0'

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:design:25.1.0'
    compile 'com.android.support:support-v4:25.1.0'

}

Upvotes: 6

Related Questions