banner



How Do I Download A Library From Github

Publishing Android libraries to GitHub Packages

Github has recently introduced the GitHub Packages, a package management service where developers and organisations can publish packages either publicly for the open up source customs or privately for apply within an organisation.

It is bachelor free for public repositories and with a pay-as-y'all-go pricing model for private repositories. More than information can be establish at the beneath link:

Part one — Publish Android library to GitHub Packages

Step ane : Generate a Personal Access Token for GitHub

  • Inside you GitHub business relationship:
  • Settings -> Developer Settings -> Personal Access Tokens -> Generate new token
  • Make sure you lot select the following scopes (" write:packages", " read:packages") and Generate a token

  • Later Generating make sure to copy your new personal admission token. Y'all cannot come across information technology again! The only option is to regenerate a key or create a new key.

Step ii: Store your GitHub — Personal Access Token details

  • Create a github.backdrop file inside your root Android project
  • In case of a public repository make sure yous add together this file to .gitignore to keep the token individual
  • Add properties gpr.usr=GITHUB_USERID and gpr.primal=PERSONAL_ACCESS_TOKEN
  • Replace GITHUB_USERID with personal / organisation Github User ID and PERSONAL_ACCESS_TOKEN with the token generated in #Step 1

Alternatively you tin also add the GPR_USER and GPR_API_KEY values to your environment variables on yous local machine or build server to avoid creating a github backdrop file

Footstep three : Update build.gradle within the library module

  • Add together the following code to build.gradle within the library module

Pace four : Publish the Android Library onto GitHub Packages

Make sure to build and run the tasks to generate the library files inside build/outputs/aar/ before proceeding to publish the library.

  • Execute the Publish gradle job which is inside your library module
          $ gradle publish        
  • Once the task is successful you should be able to see the Package under the Packages tab of the GitHub Account

  • In case of a failure run the task with –stacktrace, –info or –debug to check the logs for detailed information about the causes.

NOTE: The library file (aar) will not include the transitive dependencies (i.e. dependencies used by the library).

For Maven repos, Gradle will download the dependencies using the pom file which will contain the dependencies listing.

In this sample code/project, the pom file generated does not include the nested dependencies list. You'll have to modify the build.gradle to generate a pom file with dependencies included while building and before publishing the library. A sample piece of code can exist found below:

Part ii — Using an Android library from GitHub Packages within an Android Application

Currently the GitHub Packages requires usa to Authenticate to download an Android Library (Public or Private) hosted on the GitHub Package. This might change for futurity releases.

Steps 1 and 2 are similar to Part 1 and can be skipped if already washed while publishing a library

Step 1 : Generate a Personal Access Token for GitHub

  • Inside you lot GitHub account:
  • Settings -> Developer Settings -> Personal Access Tokens -> Generate new token
  • Make sure you select the following scopes (" read:packages") and Generate a token
  • After Generating make sure to copy your new personal access token. Yous cannot encounter information technology once again! The simply option is to generate a new primal.

Step 2: Store your GitHub — Personal Admission Token details

  • Create a github.properties file inside your root Android projection
  • In case of a public repository make sure you add this file to .gitignore for keep the token private
  • Add properties gpr.usr=GITHUB_USERID and gpr.key=PERSONAL_ACCESS_TOKEN
  • Replace GITHUB_USERID with personal / organisation Github User ID and PERSONAL_ACCESS_TOKEN with the token generated in #Step 1

Alternatively you can besides add the GPR_USER and GPR_API_KEY values to your environment variables on you local car or build server to avoid creating a github properties file

Step 3 : Update build.gradle inside the awarding module

  • Add the following code to build.gradle within the app module that will exist using the library published on GitHub Packages
  • within dependencies of the build.gradle of app module, use the following code
  • Thats information technology! Sync your Android gradle project and the library from Github Packages should be synced with your Android Projection

How Do I Download A Library From Github,

Source: https://proandroiddev.com/publishing-android-libraries-to-the-github-package-registry-part-1-7997be54ea5a

Posted by: williamstheastris.blogspot.com

0 Response to "How Do I Download A Library From Github"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel