HOW MANY WIVES DID JOSEPH SMITH HAVE

write my research paper WRITE MY RESEARCH PAPERS Write My Research Papers This could be especially sensible when the project is massive and the deadline is tight – there is an extra measure of…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Create android dependency package for your library

Once I was given a task to convert our android library project to a package and while I was trying to achieve it I got so many hurdles for this simple task. Why it became a pain for me because when I was searching for my queries on Google or Stackoverflow no one is providing answers upto the mark or may be I was not understanding it properly from their answers or docs available. So I decided to provide all possible information to create a dependency package for gradle along with the issues I faced and there solutions.

Let’s start

Creating a dependency package is literally a few steps process.

Step 1. Create a library project

To create a library project you need to add apply plugin:‘com.android.library’ at the top of the app’s gradle file. Basic difference in gradle file of an and a library is that in android app gradle first line will be apply plugin: ‘com.android.application’ whereas in library it is apply plugin:‘com.android.library’ respectively.

Step 2. Create github.properties file which contains Github PAT and username:

This is again a simple step just create a github.properties in your projects root i.e yourLibraryProject/github.properties

In this file just save your Github username and PAT(Personal access token) which is required for Github package registry (GPR) purpose. Also make sure you paste it in two separate line like mentioned below.

Click on top right Profile icon>> settings>> Go to developer settings>Personal Access token> generate new token

Step 3. Create a publish.gradle:

This gradle file tells your library source code to create a package by authenticating it with Github and generating build files with relevant details which in the end will be used by app integrating this library. Like package name and version, what kind of libraries to be include and exclude.

publish.gradle

Once this publish.gradle is created call it in your app’s build.gradle file by adding a line apply from: file(‘publish.gradle’) below apply plugin: ‘com.android.library’ like mentioned below:

Step 4. ./gralew clean build publish to publish a package

You are nearly all set to create a package on github linked with your gihub repository. All you have to do is use ./gradlew commands in the same sequence mentioned below:

./gradlew clean

Wait for the operation to finish, after successful clean command type

./gradlew build

This will build your project and will generate library executable files in app/build folder. It will also generate /repo folder in app/build/ path. This repo folder consist of all necessary files required to use a package like a pom.xml file or executable .jar or .aar files.

Now the final step to generate a package is

./gradlew publish

Release your branch by giving a tagname to this release. I have given tag 1.0.0 for this project. After you released a branch which generated package on github just provide githubusername/reponame and hit lookup. It will fetch all the releases and will run tasks to create executable files like .aar or .jar.

Step 6. How to use?

Your package is ready to use in any android project you just have to make two changes in the target app (app which is going to consume your library, please refer screenshot attached.

Hurray, you just have published an android libray which can be imported by adding dependency in app gradle file by calling implementation ‘com.github.username:reponame:tagname’

Add a comment

Related posts:

My Southwest Classic F5J 2021 Experience

For years I had followed the Southwest Classic RC Soaring contest that was conducted in the Phoenix Arizona area in the February timeframe and had longed to leave cold and snowy Indiana for the warm…

The Daily Dose of Dirt

The Moon continues its transit of protective Cancer until 5:56pm (EST.) It then moves into proud Leo! And, OH MY STARS, the Universe is vibrating a motley-vibe of energy today! Sign-posts are…

Sack

I recently came across an interesting usage of the German word Sache, which I had always understood simply to mean “thing,” as in an object. Given that German has a direct cognate with “thing” in the…