0

There is an android studio project that makes use of a library called com.github.nanchen2251:CompressHelper:1.0.6. The same was added in the build.gradle as an implementation in the dependencies section.

But unfortunately while trying to sync gradle the same dependency fails, gateway is returning bad request. But at the same time I was able to locate the master branch in git (https://github.com/nanchen2251/CompressHelper).

Is it possible to download the source code, convert it into a jar or an aar and include in the project directly??

Also, can any of you guys suggest a good or better alternative than the mentioned library?

Updated the dependency as per @ianovir comments but getting the following build failed report.

FAILURE: Build completed with 4 failures.

1: Task failed with an exception.

  • What went wrong: Execution failed for task ':app:checkDebugDuplicateClasses'.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'. Could not find compresshelper-1.0.6.jar (com.github.nanchen2251:compresshelper:1.0.6). Searched in the following locations: https://jitpack.io/com/github/nanchen2251/compresshelper/1.0.6/compresshelper-1.0.6.jar

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ==============================================================================

2: Task failed with an exception.

  • What went wrong: Execution failed for task ':app:desugarDebugFileDependencies'.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'. Could not find compresshelper-1.0.6.jar (com.github.nanchen2251:compresshelper:1.0.6). Searched in the following locations: https://jitpack.io/com/github/nanchen2251/compresshelper/1.0.6/compresshelper-1.0.6.jar

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ==============================================================================

3: Task failed with an exception.

  • What went wrong: Execution failed for task ':app:mergeDebugNativeLibs'.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'. Could not find compresshelper-1.0.6.jar (com.github.nanchen2251:compresshelper:1.0.6). Searched in the following locations: https://jitpack.io/com/github/nanchen2251/compresshelper/1.0.6/compresshelper-1.0.6.jar

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ==============================================================================

4: Task failed with an exception.

  • What went wrong: Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.

Could not resolve all files for configuration ':app:debugCompileClasspath'. Could not find compresshelper-1.0.6.jar (com.github.nanchen2251:compresshelper:1.0.6). Searched in the following locations: https://jitpack.io/com/github/nanchen2251/compresshelper/1.0.6/compresshelper-1.0.6.jar

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ==============================================================================

  • Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/6.5.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 6s 49 actionable tasks: 44 executed, 5 up-to-date

Midhun Kumar
  • 549
  • 5
  • 23
  • Just download the project a add is as module inside your project .. https://stackoverflow.com/questions/41764338/importing-module-in-android-studio – ADM Sep 17 '22 at 13:44

1 Answers1

0

I strongly advise against moving an open source dependency project locally.

The problem

Concerning the package in question, it looks like it has been deployed with a different capitalization in the name ("compresshelper" instead of "CompressHelper") for the version 1.0.6 .

So, to include it in your project please do the following:

  1. declare the repo in the project-level build.gradle file:
...
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
     }
}
  1. Add the dependency in the app/module level build.gradle file:
dependencies(
    ...
    implementation 'com.github.nanchen2251:compresshelper:1.0.6'
)

please mind the lowercase c and h. This should work.

The question

To answer your question: yes you can turn an existing project into a dependency for another one.

In short:

  1. Create a new library module, importing the dependency code
  2. In the same project, create your app module
  3. Make the app depend on the library module by changing the app-level build.gradle script:
dependencies {
    implementation project(':your_library_id')
}

If you want to maintain the two projects separated, you can build the .aar from the external library project and place it in the ./libs folder of the app one, importing it as dependency.

For more details, read Create an Android library.

ianovir
  • 31
  • 4
  • I tried updating the dependency with complete smallcase letters. Gradle sync is successful but while trying to build the project am getting the following error, Could not find compresshelper-1.0.6.jar (com.github.nanchen2251:compresshelper:1.0.6). Searched in the following locations: https://jitpack.io/com/github/nanchen2251/compresshelper/1.0.6/compresshelper-1.0.6.jar – Midhun Kumar Sep 18 '22 at 06:59
  • attaching the complete build failure report in the main section. – Midhun Kumar Sep 18 '22 at 07:05
  • Without seeing the gradle script it's difficult to say. Try to use the latest versions of gradle and compileSDK. – ianovir Sep 18 '22 at 11:14
  • I updated to the latest gradle version, toggled gradle offline mode and tried building the project. But getting the error - Could not HEAD 'https://mapbox.bintray.com/mapbox/com/github/nanchen2251/compresshelper/1.0.6/compresshelper-1.0.6.pom'. Received status code 502 from server: Bad Gateway – Midhun Kumar Sep 22 '22 at 05:23