Miro Kropacek
Miro Kropacek

Reputation: 2886

Gradle ignores transitive dependencies (and I'm not using artifact only notation)

I have a simple Android project. Its build.gradle looks like this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"

    defaultConfig {
        applicationId "com.croconaut.wifonmini"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    maven {
        url 'https://mymavenrepo.com/repo/fsD4SRhSQewcguNLyevk'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'

    compile 'com.croconaut:cpt:1.0'
}

com.croconaut.cpt:1.0 depends on a few other libs, as can be seen in the pom file:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.croconaut</groupId>
  <artifactId>cpt</artifactId>
  <version>1.0</version>
  <packaging>aar</packaging>
  <licenses>
    <license>
      <name>CC BY-NC-ND 3.0</name>
      <url>http://creativecommons.org/licenses/by-nc-nd/3.0</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <dependencies>
    <dependency>
      <groupId>com.google.android.gms</groupId>
      <artifactId>play-services-gcm</artifactId>
      <version>9.4.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.commonsware.cwac</groupId>
      <artifactId>wakeful</artifactId>
      <version>1.1.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.commonsware.cwac</groupId>
      <artifactId>provider</artifactId>
      <version>0.4.3</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.google.firebase</groupId>
      <artifactId>firebase-core</artifactId>
      <version>9.4.0</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

Content of the pom file can be verified at url https://mymavenrepo.com/repo/fsD4SRhSQewcguNLyevk/com/croconaut/cpt/1.0/cpt-1.0.pom. But it just doesn't work, either when I compile & run the app (crash) or when I list its dependencies manually:

gradlew.bat app:dependencies

...
compile - Classpath for compiling the main sources.
+--- com.android.support:appcompat-v7:24.2.0
|    +--- com.android.support:support-vector-drawable:24.2.0
|    |    \--- com.android.support:support-compat:24.2.0
|    |         \--- com.android.support:support-annotations:24.2.0
|    +--- com.android.support:animated-vector-drawable:24.2.0
|    |    \--- com.android.support:support-vector-drawable:24.2.0 (*)
|    \--- com.android.support:support-v4:24.2.0
|         +--- com.android.support:support-compat:24.2.0 (*)
|         +--- com.android.support:support-core-utils:24.2.0
|         |    \--- com.android.support:support-compat:24.2.0 (*)
|         +--- com.android.support:support-media-compat:24.2.0
|         |    \--- com.android.support:support-compat:24.2.0 (*)
|         +--- com.android.support:support-core-ui:24.2.0
|         |    \--- com.android.support:support-compat:24.2.0 (*)
|         \--- com.android.support:support-fragment:24.2.0
|              +--- com.android.support:support-compat:24.2.0 (*)
|              +--- com.android.support:support-core-utils:24.2.0 (*)
|              +--- com.android.support:support-media-compat:24.2.0 (*)
|              \--- com.android.support:support-core-ui:24.2.0 (*)
+--- com.android.support:design:24.2.0
|    +--- com.android.support:appcompat-v7:24.2.0 (*)
|    +--- com.android.support:support-v4:24.2.0 (*)
|    \--- com.android.support:recyclerview-v7:24.2.0
|         +--- com.android.support:support-compat:24.2.0 (*)
|         +--- com.android.support:support-annotations:24.2.0
|         \--- com.android.support:support-core-ui:24.2.0 (*)
\--- com.croconaut:cpt:1.0

Any ideas what to try?

Upvotes: 0

Views: 135

Answers (1)

Miro Kropacek
Miro Kropacek

Reputation: 2886

It was a cache related problem, unbelievable. One needs to wipe $HOME/.gradle/caches if experimenting with gradle and artifact versions/dependencies, there was a tiny little line in --debug logs:

14:26:22.659 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Found artifact 'cpt.aar (com.croconaut:cpt:1.0)' in resolver cache: C:\Users\miro.kropacek\.gradle\caches\modules-2\files-2.1\com.croconaut\cpt\1.0\140908776a61feca2d3be95ace56e35905bf8893\cpt-1.0.aar

Upvotes: 1

Related Questions