0

My goal is to use an aar in this repository.

In the project build.gradle:

buildscript {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://raw.github.com/saki4510t/libcommon/master/repository/' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

The app module's build gradle:

implementation("com.serenegiant:common:4.1.1") {
    exclude module: 'support-v4'
}

The above actually works in a project. However, in another project, I keep getting the following error:

Execution failed for task ':app:mergeDebugNativeLibs'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.serenegiant:common:4.1.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/serenegiant/common/4.1.1/common-4.1.1.pom
       - https://repo.maven.apache.org/maven2/com/serenegiant/common/4.1.1/common-4.1.1.pom
       - https://jitpack.io/com/serenegiant/common/4.1.1/common-4.1.1.pom
     Required by:
         project :app

I am really puzzled. I cannot tell what difference between these two project results in this. I may be missing something very simple. Could anyone offer a tip on this?

I have rebuilt the project many times and invalided caches and restarted Android Studio many times to no avail.

Update [2023-05-23]

Following a tip, I ran ./gradlew --info --refresh-dependencies but got the following for the working project:

> Could not resolve all files for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:7.4.2.
     Required by:
         project :
      > No matching variant of com.android.tools.build:gradle:7.4.2 was found. The consumer was configured to find a runtime of a lib
rary compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.5' but:
          - Variant 'apiElements' capability com.android.tools.build:gradle:7.4.2 declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
          - Variant 'javadocElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
          - Variant 'runtimeElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
          - Variant 'sourcesElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.5')

Update [2023-05-24]

Here is something making this even more mysterious: if I change "com.serenegiant:common:4.1.1" to "com.serenegiant:common:2.1.1", Android Studio warns me a newer version is available. This means it knows dependency well enough to tell which version is the latest, and yet cannot fetch it.

Hong
  • 17,643
  • 21
  • 81
  • 142
  • Did you see/try: [Gradle - get URL of dependency artifact](https://stackoverflow.com/a/67645939/295004) Also if you check jitpack.io I don't see that version of the package: `com.serenegiant:common:4.1.1` – Morrison Chang May 23 '23 at 17:50
  • @MorrisonChang Thank you for the tip. I ran "./gradlew --info --refresh-dependencies " in Terminal but got "Could not resolve com.android.tools.build:gradle:7.4.2." – Hong May 23 '23 at 18:48
  • Run in your Android Studio terminal window. I had issues with my OS terminal environment due to recent Java version issues (old Mac, but worked in AS). – Morrison Chang May 23 '23 at 18:50
  • @MorrisonChang That is exactly what I did - using Android Studio's terminal. Let me update the question by posting the results of running this. It would be great if you could take a look at it. – Hong May 23 '23 at 18:59
  • And you tried this on the working and non-working projects? (please label results) – Morrison Chang May 23 '23 at 19:07
  • I tried this for the working project. I have just edited the update with this clarification. I have also just made sure the working project still builds fine. – Hong May 23 '23 at 19:10
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/253786/discussion-between-morrison-chang-and-hong). – Morrison Chang May 23 '23 at 19:11

0 Answers0