First we create an Android project from Android Studio call MyLibrary.
Then remove the applicationId attribute from the build.gradle file and change the plugin from
apply plugin: 'com.android.application'To
apply plugin: 'com.android.library'
That's all the changes we need to make with the library project.
Go back to our main project: MyApplication.
change the settings.gradle file to include our library project in the build.
Then we can configure our build.gradle file in MyApplication to add the dependency of MyLibrary project. In the dependencies section, add a line
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.1' compile project(':mylib') }
Job done.
References:
http://stackoverflow.com/a/16999835
No comments:
Post a Comment