An overview of the

In the development process, there are a lot of module is not dependent on a project, that is all project is common, there are a lot of this module, for a small utility class, I was under the project to build a new utils package, larger is conducted through the library reference, before thinking about get a remote warehouse to rely on myself, I directly access through Gradle. After studying, there are roughly Maven Center and JCenter among the mainstream warehouses, and I have also registered my account. When I was about to access, I found the JitPack warehouse, and then I found that the access process is user-friendly, and I can connect to my own Github. It was then chosen as access, but the pain was just beginning.

The body of the

I read a lot of articles on the Internet, all kinds of 5 minutes, 10 minutes into the JitPack, I was excited to see the ground, oh my god, so easy, I also try, and then started.

One

Create a new Project and create a Library within the Project

Two

Add build.gradle that depends on project

    dependencies {
   classpath 'com. Android. Tools. Build: gradle: 3.0.1'
   classpath 'com. Making. Dcendents: android - maven - gradle - plugin: 2.0'
    }

Copy the code

The library of the build. Gradle

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.wustor'
Copy the code

Three

Upload it to your Github and release it as v0.0.1

Four

Go to the JitPack website, log in using your Github account, find the project you just posted on the left, and click on it

0m0.708s
FAILURE: Build failed with an exception.
* Where:
Build file '/home/jitpack/build/build.gradle' line: 6
* What went wrong:
A problem occurred evaluating root project 'build'.
> Could not find method google() for arguments [] on repository container.
Copy the code

We know that Google () is Google’s own Maven repository, which is based on Gradle3.0, indicating that the JitPack does not support Gradle3.0 yet

Five

Gradle version 2.3.3, gradleWrapper, and release the second version v0.0.2. It doesn’t work

* Where:
Build file '/home/jitpack/build/app/build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
   > Minimum supported Gradle version is 3.3. Current version is 3.1. If using the gradle wrapper, try editing the distributionUrl in /home/jitpack/build/gradle/wrapper/gradle-wrapper.properties to gradle-3.3-all.zip
Copy the code

This mistake made me speechless, I had already uploaded 3.3, but still told me that I didn’t upload it, are you kidding me? I re-released several versions, but it still didn’t work

Six

If it wasn’t for this way, there are many advantages over JCenter, I might just give up. There is no official adaptation of Gradle version, but it is understandable that gradle3.0 is just released, but those 5-10 minute blogs are really successful. Then I looked at their Demo and found that their Gradle version was low, so I changed to their version, that is:

    classpath 'com. Android. Tools. Build: gradle: 2.2.3'
    classpath 'com. Making. Dcendents: android - maven - gradle - plugin: 1.4.1'
Copy the code

Then I re-uploaded it to Github for a third release, V0.0.3, which worked

compile 'com. Making. Wustor: JitPackDemo: v0.0.3'
Copy the code

Seven

If we want to use the open source project locally, it’s easy to add the Maven dependency for JitPack in the project root directory

allprojects {
		repositories {
			maven { url 'https://jitpack.io'}}}Copy the code

And then reference it in the app directory

dependencies {
		compile 'com. Making. Wustor: JitPackDemo: v0.0.3'
	}
Copy the code

Since the JitPack is compiled in the cloud, there is virtually no difference between it and the local version, so as long as the JitPack website shows a successful build, it is definitely referable locally. I won’t cover it here, and it is not the focus of this article

conclusion

In fact, it may take less than half an hour to write this blog, but in the process of integration, it really took a long time. The blog introduction on the Internet, at least I have read, is 100% of the integration under the environment of 2.2.3 Gradle plugin, and the official also provides the corresponding plugin version. Even in this environment it was not successful, and the Jenkins integration on top of Android Studio 3.0 had all sorts of puzzling problems. However, it is possible that something is wrong with your environment. Wait a while and try gradle 3.0.

The code download