0

I have an SDK project that is referencing quit alot of dependencies in gradle. I have to ask the SDK users to add those dependencies when they use the SDK in their projects. The problem is, every time I add some new dependency or replace current dependency with a new one, I'll have to ask the users to make changes as well, which is not a good practice in my opinion. Is there a way to bundle all the dependencies in the .aar. I am generating the artifact file with the following code.

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"
        }
    }

These are my dependencies:

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'
}

EDIT:

I have added the following method in uploadArchives method. The size of the artifact file has increased but when I use the .aar file in app project, it can't find the files.

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
            }**
        }

UPDATE:

I tried the following code because @aar was generating errors (couldn't find xx.xx.xx.aar on jcenter()). This still fails, the 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 throws following warnings for all classes:

dalvikvm﹕ Link of class 'Lio/wingoku/sdk/Fetch$6;' failed

It eventually throws exception ClassDefNotFound

Umer Farooq
  • 7,356
  • 7
  • 42
  • 67

1 Answers1

0

Regarding your edit

configurations.all {
    transitive = true
}

I'm not sure it as any effect.

I think you should write something like this:

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

It just say that

  • cardview is aar to include in this library.
  • eventbus and socket.io-client are jar lib to include in aar
ben75
  • 29,217
  • 10
  • 88
  • 134