Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 724
Roshan Avatar asked May 09 '26 13:05

Roshan


1 Answers

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.

like image 71
Roshan Avatar answered May 12 '26 04:05

Roshan