https://github.com/jitpack/android-example
Example Android library that builds on jitpack.io
https://github.com/jitpack/android-example
android android-library gradle jitpack kotlin
Last synced: 10 months ago
JSON representation
Example Android library that builds on jitpack.io
- Host: GitHub
- URL: https://github.com/jitpack/android-example
- Owner: jitpack
- Created: 2015-02-11T15:43:02.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2025-02-19T13:36:54.000Z (about 1 year ago)
- Last Synced: 2025-04-08T13:09:53.157Z (12 months ago)
- Topics: android, android-library, gradle, jitpack, kotlin
- Language: Kotlin
- Homepage:
- Size: 252 KB
- Stars: 214
- Watchers: 6
- Forks: 201
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# android-example
[](https://jitpack.io/#jitpack/android-example)
Example Android library project that works with jitpack.io.
See this [Tutorial](https://medium.com/@ome450901/publish-an-android-library-by-jitpack-a0342684cbd0) on how to publish an Android Library with JitPack.
For more details check out the [documentation](https://docs.jitpack.io/android/)
https://jitpack.io/#jitpack/android-example
Add it to your settings.gradle with:
```gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
```
and:
```gradle
dependencies {
implementation 'com.github.jitpack:android-example:{latest version}'
}
```
## Multiple build variants
If your library uses multiple flavours then see this example:
https://github.com/jitpack-io/android-jitpack-library-example
## Adding the maven plugin
To enable installing into local maven repository and JitPack you need to add the [maven-publish](https://developer.android.com/studio/build/maven-publish-plugin) plugin:
Then add the publishing section to your library build.gradle:
```gradle
publishing {
publications {
release(MavenPublication) {
groupId = 'com.my-company'
artifactId = 'my-library'
version = '1.0'
afterEvaluate {
from components.release
}
}
}
}
```
After these changes you should be able to run:
./gradlew publishToMavenLocal
from the root of your project.
If `publishToMavenLocal` works and you have added a GitHub release it should work on jitpack.io
## Adding a sample app
If you add a sample app to the same repo then your app needs to have a dependency on the library. To do this in your app/build.gradle add:
```gradle
dependencies {
compile project(':library')
}
```