Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio convert java module to android module

Tags:

java

android

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?

like image 969
Lavan Avatar asked Jan 24 '18 10:01

Lavan


1 Answers

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'

}
like image 81
Ashwini Atale Avatar answered Sep 17 '22 14:09

Ashwini Atale