Android Studio 关联项目软链接

1、需要关联的项目创建快捷方式,复制到AS 的app 目录下
2、在项目的app目录下替换build.gradle文件。
Android Studio 关联项目软链接_第1张图片
3、快捷访问项目名必须和build.gradle文件中的
def folder = ‘Gallery2’ 一致
4、build.gradle文件

// app config
apply plugin: 'com.android.application'

android {
    def compileSdkVersionInt = 23
    compileSdkVersion compileSdkVersionInt
    buildToolsVersion "23.0.2"

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 23
        versionCode getCurrentDate() as int
        versionName "1.0.3." + getCurrentDate()
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    if (compileSdkVersionInt >= 23) {
        useLibrary 'org.apache.http.legacy'
    }

    sourceSets {
        main {
            def folder = 'Gallery2'
            def src = [folder + '/src', folder + '/src_pd', folder + '/gallerycommon/src']
            def resFolder = [folder + '/res']
            def assetsFolder = [folder + '/assets']
            def libsFolder = [folder + '/libs']

            manifest.srcFile file(folder + '/AndroidManifest.xml')
            java.srcDirs = src
            resources.srcDirs = src
            aidl.srcDirs = src
            renderscript.srcDirs = src
            res.srcDirs = resFolder
            assets.srcDirs = assetsFolder
            jniLibs.srcDirs = libsFolder
        }

        // Move the build types to build-types/
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src//... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

dependencies {
    provided files(getLayoutLibPath())
//    provided files(getRenderscriptLibPath())
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

def getCurrentDate() {
    def now = new Date().format('yyyyMMddHH');
    return now;
}

// must called after "android" definition
def getLayoutLibPath() {
    def rootDir;
    rootDir = "${android.getSdkDirectory().getAbsolutePath()}" + "/platforms/" + android.compileSdkVersion + "/data/layoutlib.jar"
    Console.println(rootDir)
    return rootDir
}

// must called after "android" definition
def getRenderscriptLibPath() {
    def rootDir;
    rootDir = "${android.getSdkDirectory().getAbsolutePath()}" + "/build-tools/" + android.buildToolsVersion + "/renderscript/lib/renderscript-v8.jar"
    Console.println(rootDir)
    return rootDir
}

你可能感兴趣的:(Android,Studio)