Gradle忽略传递依赖(并且我不使用仅工件表示法)

时间:2016-09-01 04:23:06

标签: android maven gradle android-gradle

我有一个简单的Android项目。它的build.gradle看起来像这样:

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取决于其他一些库,如pom文件中所示:

<?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>

可以在网址https://mymavenrepo.com/repo/fsD4SRhSQewcguNLyevk/com/croconaut/cpt/1.0/cpt-1.0.pom验证pom文件的内容。但是,当我编译和编译时,它无法正常工作。运行应用程序(崩溃)或手动列出其依赖项时:

gradlew.bat应用:依赖

...
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

任何想法尝试什么?

1 个答案:

答案 0 :(得分:1)

这是一个缓存相关的问题,令人难以置信。如果尝试使用gradle和artifact版本/依赖项,则需要擦除$ HOME / .gradle / caches,在--debug日志中有一个小小的一行:

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