简体   繁体   中英

Android Studio 3rd Party Library Integration

I've got to integrate a 3rd party library in to My Android Studio project and that works great without any issue.

It asks to add following configuration to the project ' s build.gradle (sample configuration as follows)

allprojects {
    repositories {
        jcenter()
         maven {
            url "http://link/location"
         }
    }
}

And then to add dependencies to the app.gradle as follows

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.android.support:support-v4:24.1.1'
    compile 'com.android.support:cardview-v7:24.1.1'
    compile 'xxx.xx:xxx:1.11.0:@aar'
}

But my requirement here is to create a library module (with in the project) that wraps this 3rd party library integration with in that.

Idea is to distrubute my library that contains few public methods (that use this 3rd party library methods in that) to others to integrate with in their apps.

As I mentioned earlier to use this 3rd party library I need to use their own Maven Repository and asks to place setting in Projects build.gradle. But as I want to warp all within My Library Module I just tested adding repository bit in to Library Module's build.gradle. But this provides compile errors.

 repositories {
    jcenter()
     maven {
        url "http://link/location"
     }
 } 

My Question is can I achieve what I am trying to do? If so what I am missing here. Thanks

EDITS

Briefly what I am trying to do.

This 3rd party library is not available in standard jcenter or mavenCentral repositories. Instead it resides on their own Maven Repository Server. That's why when need to integrate it asks to specify server location in root level (project) build.gradle as follows. Then I can add dependencies...

allprojects {
    repositories {
        jcenter()
         maven {
            url "http://link/location"
         }
    }
}

But as I want to wrap up this integration within Library Module tried to add above repository location in to gradle.build with in My Library Module.

So I can Access those classes but Main Application that compile MY Library project saying can't resolve libraries in 3rd party Library location. Actually Main Application should NOT want to know as long as My Library Module knows it...

Actually Main Application should NOT want to know as long as My Library Module knows it

If the third-party module is open source, fork it, put your wrapper code in the fork, and ship the fork by your own means.

If the third-party module is not open source, discuss with the vendor what your options are for distributing this code by some other means (eg, your own internal repository, alongside your own library).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM