android studio -build

import org.aspectj.bridge.IMessage
import org.aspectj.bridge.MessageHandler
import org.aspectj.tools.ajc.Main

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.aspectj:aspectjtools:1.8.1'
    }
}

apply plugin: 'com.android.application'

repositories {
    jcenter()
}

dependencies {
    compile project(':library')
    testCompile 'junit:junit:4.12'
    compile 'org.aspectj:aspectjrt:1.8.1'
    compile files('libs/alipaySDK-20150610.jar')
    compile files('libs/android-support-v7-recyclerview.jar')
    compile files('libs/greendao-2.2.0.jar')
    compile files('libs/jpush-android-2.1.3.jar')
    compile files('libs/ksylive3.0.jar')
    compile files('libs/libksyplayer.jar')
    compile files('libs/libksystat.jar')
    compile files('libs/socketio.jar')
    compile files('libs/umeng-analytics-v6.0.1.jar')
    compile files('libs/weibosdkcore_release.jar')
    compile files('libs/zhibohttpcommon.jar')
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.android.activity"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 210
        versionName "4.0"

        multiDexEnabled true

        ndk {
            //设置支持的SO库架构
            abiFilters 'armeabi' , 'armeabi-v7a', 'arm64-v8a'
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }

    // 加快编译速度
    dexOptions {
        incremental true
    }

    lintOptions {
        abortOnError true
    }
}

final def log = project.logger
final def variants = project.android.applicationVariants

variants.all { variant ->
    if (!variant.buildType.isDebuggable()) {
        log.debug("Skipping non-debuggable build type '${variant.buildType.name}'.")
        return;
    }

    JavaCompile javaCompile = variant.javaCompile
    javaCompile.doLast {
        String[] args = ["-showWeaveInfo",
                         "-1.5",
                         "-inpath", javaCompile.destinationDir.toString(),
                         "-aspectpath", javaCompile.classpath.asPath,
                         "-d", javaCompile.destinationDir.toString(),
                         "-classpath", javaCompile.classpath.asPath,
                         "-bootclasspath", project.android.bootClasspath.join(File.pathSeparator)]
        log.debug "ajc args: " + Arrays.toString(args)

        MessageHandler handler = new MessageHandler(true);
        new Main().run(args, handler);
        for (IMessage message : handler.getMessages(null, true)) {
            switch (message.getKind()) {
                case IMessage.ABORT:
                case IMessage.ERROR:
                case IMessage.FAIL:
                    log.error message.message, message.thrown
                    break;
                case IMessage.WARNING:
                    log.warn message.message, message.thrown
                    break;
                case IMessage.INFO:
                    log.info message.message, message.thrown
                    break;
                case IMessage.DEBUG:
                    log.debug message.message, message.thrown
                    break;
            }
        }
    }
}

Guess you like

Origin blog.csdn.net/shaohuazuo/article/details/52024010