捆绑.aar文件

时间:2015-06-04 08:46:17

标签: maven android-studio gradle artifacts

我有一个SDK项目在gradle中引用很多依赖项。我必须要求SDK用户在他们的项目中使用SDK时添加这些依赖项。问题是,每次我添加一些新的依赖项或用新的依赖项替换当前的依赖项时,我都必须要求用户进行更改,这不是一个好习惯。我的看法。有没有办法捆绑.aar中的所有依赖项。我使用以下代码生成工件文件。

uploadArchives{
    repositories.mavenDeployer {
        def deployPath = file(getProperty('aar.deployPath'))
        repository(url: "file://${deployPath.absolutePath}")
        pom.project {
            groupId 'myPackageName'
            artifactId 'wingoku-io'
            version "0.0.6"
        }
    }

这些是我的依赖项:

dependencies {
    compile 'com.github.nkzawa:socket.io-client:0.5.0'
    compile 'com.android.support:cardview-v7:21.+'
    compile 'de.greenrobot:eventbus:2.4.0'
}

修改

我在uploadArchives方法中添加了以下方法。工件文件的大小已经增加,但是当我在app项目中使用.aar文件时,它无法找到文件。

uploadArchives{
        repositories.mavenDeployer {
            def deployPath = file(getProperty('aar.deployPath'))
            repository(url: "file://${deployPath.absolutePath}")
            pom.project {
                groupId 'myPackageName'
                artifactId 'wingoku-io'
                version "0.0.6"
            }

            **configurations.all {
                transitive = true
            }**
        }

更新

我尝试了以下代码,因为@aar产生错误(无法在jcenter()上找到xx.xx.xx.aar)。这仍然失败,d

 compile ('com.github.nkzawa:socket.io-client:0.5.0'){
        transitive=true
    }
    compile ('com.android.support:cardview-v7:21.+@aar'){
        transitive=true
    }
    compile ('de.greenrobot:eventbus:2.4.0'){
        transitive=true
    }

Dalvik对所有课程发出警告:

dalvikvm:课程链接' Lio / wingoku / sdk / Fetch $ 6;'失败

它最终抛出异常 ClassDefNotFound

1 个答案:

答案 0 :(得分:0)

关于你的编辑

configurations.all {
    transitive = true
}

我不确定它有什么影响。

我认为你应该这样写:

dependencies {
    compile 'com.github.nkzawa:socket.io-client:0.5.0'{
        transitive=true
    }
    compile 'com.android.support:cardview-v7:21.+@aar'{
        transitive=true
    }
    compile 'de.greenrobot:eventbus:2.4.0'{
        transitive=true
    }
}

它只是说

  • cardview可以包含在此库中。
  • eventbus和socket.io-client是jar lib,包含在aar
相关问题