You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Replace GITHUB_USERID with personal / organisation Github User ID and PERSONAL_ACCESS_TOKEN with the token generated in#Step 1
Alternatively you can also add theGPR_USER andGPR_API_KEY values to your environment variables on you local machine or build server to avoid creating a github properties file
Step 3 : Update build.gradle inside the library module
Add the following code tobuild.gradle inside the library module
def getVersionName= {->return"1.0.2"// Replace with version Name}
def getArtificatId= {->return"sampleAndroidLib"// Replace with library name ID}
publishing { publications { bar(MavenPublication) { groupId'com.enefce.libraries'// Replace with group ID artifactId getArtificatId() version getVersionName() artifact("$buildDir/outputs/aar/${getArtificatId()}-release.aar") } } repositories { maven { name="GitHubPackages"/** Configure path of your package repository on Github * Replace GITHUB_USERID with your/organisation Github userID and REPOSITORY with the repository name on GitHub*/ url= uri("https://maven.pkg.github.com/GITHUB_USERID/REPOSITORY") credentials {/**Create github.properties in root project folder file with gpr.usr=GITHUB_USER_ID & gpr.key=PERSONAL_ACCESS_TOKEN**/ username= githubProperties['gpr.usr']?:System.getenv("GPR_USER") password= githubProperties['gpr.key']?:System.getenv("GPR_API_KEY") } } }}
Make sure to build and run the tasks to generate the library files insidebuild/outputs/aar/ before proceeding to publish the library.
Execute thePublish gradle task which is inside your library module
$gradle publish
Once the task is successful you should be able to see the Package under thePackages 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.
Using a library from the GitHub Package Registry
Currently the GitHub Package Registry requires us to Authenticate to download an Android Library (Public or Private) hosted on the GitHub Package Registry. This might change for future releases
Steps 1 and 2 can be skipped if already followed while publishing a library
Step 1 : Generate a Personal Access Token for GitHub
Inside you 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. You won’t be able to see it again!
Step 2: Store your GitHub - Personal Access Token details
Create agithub.properties file within your root Android project
In case of a public repository make sure you add this file to .gitignore for keep the token private
Replace GITHUB_USERID with personal / organisation Github User ID and PERSONAL_ACCESS_TOKEN with the token generated in#Step 1
Alternatively you can also add theGPR_USER andGPR_API_KEY values to your environment variables on you local machine or build server to avoid creating a github properties file
Step 3 : Update build.gradle inside the application module
Add the following code tobuild.gradle inside the application module that will be using the library published on GitHub Packages Repository
repositories { maven { name="GitHubPackages"/* Configure path to the library hosted on GitHub Package Registry * Replace UserID with package owner userID and REPOSITORY with the repository name * e.g. "https://maven.pkg.github.com/enefce/AndroidLibraryForGitHubPackagesDemo"*/ url= uri("https://maven.pkg.github.com/UserID/REPOSITORY") credentials { username= githubProperties['gpr.usr']?:System.getenv("GPR_USER") password= githubProperties['gpr.key']?:System.getenv("GPR_API_KEY") } } }
inside dependencies of the build.gradle of app module, use the following code