Roshan
Roshan

Reputation: 893

Convert java library to Android Library in Android Studio

Is there a standard way to convert a java library in Android Studio to an android library?

Upvotes: 3

Views: 1307

Answers (1)

Roshan
Roshan

Reputation: 893

Steps :

  1. In build.gradle replace the plugin line as apply plugin: 'java-library' to apply plugin: 'com.android.library' and add the following :
    android {
        compileSdkVersion 27

         defaultConfig {
            minSdkVersion 21
            targetSdkVersion 27
            versionCode 1
            versionName "1.0"

             testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

         }

         buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }

     }  
  1. Add Android manifest file
  2. Add resources files if needed

Open in Android Studio and the module should load as an Android Library.

Upvotes: 3

Related Questions