Loading...
Home
  • Tech Blogs
  • Videos
  • Conferences
    • Droidcon News
    • Upcoming Conferences
    • Become a Partner
    • Past Events
    • Keep Me Informed
    • Diversity Scholarships
  • Community
    • droidcon Team
    • How to Hold a Droidcon
  • Android Careers
Sign In

Global CSS

 

Creating a Private Maven Repository for Android Libraries on GitLab

 

 
Ibrahim Süren
Golang & Android Dev.
Published: November 20, 2020
Tweet
Share
 

https://unsplash.com/photos/ZV_64LdGoao

 

Creating open-source Android libraries benefits for both library owner and the other developers. A code written by a developer can save other developers from building the same thing, and also the other developers can contribute the same code. Thus, a library that will be useful for many people is can be created with the contribution of a few people.

However, you may not want to open some of your personal or corporate libraries to the outside world. In this case, you can create your own packages using one of GitHub, GitLab, AWS, GCP etc. services.

 

Reusability and Versioning

When you have multiple projects that use shared components, implementing a single main code for these projects instead of using the same code in all projects will benefit you in many ways. It is important to make bug fix or code change in a single library and create a new version, both in terms of spending less time and ensuring consistent build quality.

 

Maven Publish Plugin

As described in the official documentation, Android Gradle plugin 3.6.0 and higher include support for the Maven Publish Gradle plugin, which allows you to publish build artifacts to an Apache Maven repository.

First, we add the maven-publish plugin to the project level build.gradlefile.

 

 

In order to publish our plugin, we need to create a Gradle file that can be use in our library configuration. Create a file called gradle-mvn-push.gradle in the root of the project, which will apply the Gradle-Mavenplugin and specify the location of the GitLab package when using the gradle publish command:

 

 

In the publications section, we used our build types as publication name like release, debug. If you have additional flavor types in your project you can create other publications for each flavor name combined with build types.(e.g. paidRelease, paidDebug)

In the repositories section, we describe our repository locations to publish. In the example, we used GitLab Package Registry address. You can also use the other services.

 

Image for post

The private token used in credentials is our personal GitLab Access Token. You can create it from here with api, read_registry and write_registryscopes.

Finally, we apply the gradle-mvn-push.gradle file that we created in the libraries gradle file (i.e. mylibrary/build.gradle):

 

 

With these steps, we are ready to create our first package. First, we need to build our library to create AAR (Android Archive) files. Locate to your library module directory and run gradle build command.

 

Image for post

 

If you look at library/build/outputs/aar you will see the built aar files for each build variant. Finally, we run gradle publish command.

 

Image for post

 

Thus, we have published our first package. If we can see the package we published in the GitLab Package Registry, then there is no problem.

 

Image for post

 

Installing Published Libraries

At this step, we don’t need to do anything other than implementing any gradle library into the project. We just specify the gitlab credentials while adding the maven repository to the project level gradle file.

 

 

Finally, we need to implement the package into module level gradle file and sync gradle.

 

References

  • https://guides.codepath.com/android/Building-your-own-Android-library
  • https://ryanharter.com/blog/2015/06/hosting-a-private-maven-repo-on-amazon-s3/
  • https://gist.github.com/adrianbk/c4982e5ebacc6b6ed902/

 

 

 

Tags: Android, Maven, Gitlab, Android App Development, AndroidDev

 

View original article at: 


 

Originally published: November 05, 2020

Android News
Evolution of Android Update SystemEvolution of Android Update System
Evolution of Android Update SystemEvolution of Android Update System

By Ivan Kuten

So, how can you update Android on mobile devices? While developing software for Smart TVs and Android-based set-top boxes, we’ve narrowed it down to four ways, discarding some very exotic options:

By ProAndroidDev -
Android News
Happy Railway
Happy Railway

By Hadi Lashkari Ghouchani

This post is on the tail of Railway Oriented Programming in Kotlin by Antony Harfield. So you need to read it first and continue here. As it’s obvious I really liked it and tried it out. It needs every process have a result like

By ProAndroidDev -
Android News
Unit Tests and Concurrency
Unit Tests and Concurrency

By Stojan Anastasov

Once Retrofit added RxJava support, RxJava became my go-to concurrency framework for writing Android apps. One of the great things about RxJava is the excellent testing support. It includes TestObserver, TestScheduler, RxJavaPlugins so you can switch your schedulers in tests.

By ProAndroidDev -
Android News
When Compat libraries will not save you
When Compat libraries will not save you

By Danny Preussler

And why you should avoid using the “NewApi” suppression! The idea of “Compat” libraries was probably one of the key aspects of Android dominating the mobile space. Other than with iOS, Android users often could not update their operating system after a new version launch, simply as their phones won’t allow them to, the Android problem of fragmentation.

 

By ProAndroidDev -
droidcon News

Tech Showcases,

Developer Resources &

Partners

/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/home-details/EmployerBrandingHeader
EmployerBrandingHeader
https://jobs.droidcon.com/
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/jobs-droidcon/jobs.droidcon.com
jobs.droidcon.com

Latest Android Jobs

http://www.kotlinweekly.net/
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/kotlin-weekly/Kotlin Weekly
Kotlin Weekly

Your weekly dose of Kotlin

https://proandroiddev.com/
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/pad/ProAndroidDev
ProAndroidDev

Android Tech Blogs, Case Studies and Step-by-Step Coding

/detail?content-id=/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Zalando/Zalando
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Zalando/Zalando
Zalando

Meet one of Berlin's top employers

/detail?content-id=/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Academy for App Success/Academy for App Success
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Academy for App Success/Academy for App Success
Academy for App Success

Google Play resources tailored for the global droidcon community

Follow us

Team droidcon

Get in touch with us

Write us an Email

 

 

Quicklinks

> Code of Conduct

> Terms and Conditions

> How to hold a conference

> FAQs

> Imprint

Droidcon is a registered trademark of Mobile Seasons GmbH Copyright © 2020. All rights reserved.

powered by Breakpoint One