Every time I try to fork an Android library and use it through JitPack, I get errors, give up and choose some other means to customize and use the library. This time I wanted to get to the bottom of this and created a basic app that isolates the problem. Could you download the repo below and tell me what the I'm doing wrong?
In this repo is a very basic Android application: https://github.com/gazialankus/JitpackNotWorking. I simply created a new Android application in Android Studio, and followed the instructions in https://jitpack.io/ to add the https://github.com/ArthurHub/Android-Image-Cropper github repo as a dependency. I added the JitPack Maven repository in the root build.gradle and added the library dependency in the app build.gradle like this:
compile 'com.github.ArthurHub:android-image-cropper:2.4.5'
Gradle syncs fine, but android-image-cropper-2.4.5 does not show up under external libraries in project view. So, the app won't build with this error:
Error:(6, 38) error: package com.theartofdev.edmodo.cropper does not exist
As I noted in the comments in the app build.gradle, using the library without JitPack like this works just fine:
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.5'
I thought maybe JitPack could not build this repo. However, the JitPack log for this repository says "ok".
Gradle and Java versions: In Android Studio menu File > Project Structure > Project, the Gradle version is 3.3 and the Android Plugin Version is 2.3.3. In the same dialog, SDK Location tab shows that embedded JDK is being used from C:\Program Files\Android\Android Studio\jre.
> "C:\Program Files\Android\Android Studio\jre\bin\java.exe" -version
openjdk version "1.8.0_112-release"
OpenJDK Runtime Environment (build 1.8.0_112-release-b06)
OpenJDK 64-Bit Server VM (build 25.112-b06, mixed mode)
There are no pending updates in Android Studio.
Could you please download and build this repo that isolates the problem and tell me what I'm doing wrong? Again, the repository that demonstrates the problem is here: https://github.com/gazialankus/JitpackNotWorking
Thank you.
Edit: Tried with a fork of mine and tried to make the library more JitPack-friendly, still the same issue. Please see the commits in the repo.
SOLVED: Please see https://github.com/gazialankus/JitpackNotWorking/blob/master/README.md for more details.
I think the problem is the group and version.
In the build log you can see that in the Gradle call there is contained -Pgroup=com.github.ArthurHub
and -Pversion=2.4.5
. But also in the log you see Found artifact: com.theartofdev.edmodo:android-image-cropper:2.4.5-SNAPSHOT
where it actually should be Found artifact: com.github.ArthurHub:android-image-cropper:2.4.5
.
You also see in the list of files in the bottom of the log that only the POM is produced, no jar or aar. That's also why the Gradle sync is successful in AS, as the dependencies pom is found and valid, there is just no artifact for that dependency.
If you look at the build.gradle of the project you are referring, you can see that they do not use group
and version
for configution the publication, so what JitPack has set is not used and thus cannot be found.
That project simply is not JitPack compatible as long as JitPack does not get more intelligent and instead of just setting some project variables adds some init script that reconfigures publications or something like that.
Maybe you should use a composite build instead. With a composite build you would declare a binary dependency like com.theartofdev.edmodo:android-image-cropper:2.4.5
, but then substitue this dependency by the worktree of the project and a sub-build is automatically done to get the artifact for the dependency. That's the pure Gradle way to replace a dependency with a custom build one.
来源:https://stackoverflow.com/questions/44841415/jitpack-wont-use-a-github-repo-included-sample-repo-that-demonstrates-the-iss