androidgradlegit-submodulesgradle-kotlin-dsljitpack

Could not resolve git repository as dependency in android gradle


I am trying to add a git repository (https://github.com/FHNW-IP5-IP6/ComposeForms) as a dependency into my project with Gradle and tried the below-listed variants (1.-3.) from Is it possible to declare git repository as dependency in android gradle? but every time when I sync the project I get an Error saying: "Could not resolve com.github.FHNW-IP5-IP6:ComposeForms:master-SNAPSHOT".

I tried the following:

  1. Jitpack (https://jitpack.io/#FHNW-IP5-IP6/ComposeForms/master-SNAPSHOT)

    allprojects {
      repositories {
        ...
        maven("https://jitpack.io") // also tried uri https://www.jitpack.io
      }
    }
    

    and in app build.gradle

    kotlin {
      sourceSets {
        named("main") {
          dependencies {
            ...
            implementation("com.github.FHNW-IP5-IP6:ComposeForms:master-SNAPSHOT")
          }
        }
      }
    }
    
  2. Git Submodule (named as compose-forms)

    include(":compose-forms") inside settings.gradle

    kotlin {
      sourceSets {
        named("main") {
          dependencies {
            ...
            implementation(project(":compose-forms"))
          }
        }
      }
    }
    
  3. New feature in gradle

    Inside settings.gradle

    sourceControl {
      gitRepository(uri("https://github.com/FHNW-IP5-IP6/ComposeForms.git")) {
        producesModule("compose-forms")
      }
    }
    

    and in app build.gradle

    kotlin {
      sourceSets {
        named("main") {
          dependencies {
            ...
            implementation("compose-forms") {
              version {
                branch = "master"
              }
            }
          }
        }
      }
    }
    

I'm running out of options and really need the git repository as a dependency. I would prefer not to have any git submodules inside my project so I prefer numbers 1 and 3 to work. Thanks in Advance for any hint :)


Solution

  • Open Android Studio as Administrator then add maven { url 'https://jitpack.io' } to both, build.gradle(project) and settings.gradle(project) and the respective implementation [...] to build.gradle(:app). This worked for me as every other solution proposed failed.