gradle 引入三方 lib

以 ksoap2-android 为例

获取 url group version

https://oss.sonatype.org/content/repositories/ksoap2-android-releases/
com.google.code.ksoap2-android
3.6.2

设置 project gradle:

buildscript {
    ...
    //1 设置版本号
    ext.ksoap_version = '3.6.2'
    repositories {
        ...
        //2 引入仓库
        maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
    }
    dependencies {
        ...
        //3 引入 lib
        classpath "com.google.code.ksoap2-android:ksoap2-android:$ksoap_version"
    }
}

allprojects {
    repositories {
        ...
        //4 引入仓库
        maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
    }
}

设置 app gradle

dependencies {
    ...
    // 引入 lib
    compile "com.google.code.ksoap2-android:ksoap2-android:$ksoap_version"
}

你可能感兴趣的:(gradle 引入三方 lib)