天天看點

android項目 -- 架構搭建(三)

android項目 – 架構搭建(三)(build.gradle : app 構造檔案)

  1. 基本上同model的build.gradle檔案。
  2. 參考海宏配置:
apply plugin: 'com.android.application'

android {
    compileSdkVersion rootProject.ext.android.compileSdkVersion
    buildToolsVersion = '28.0.3'

    defaultConfig {
        applicationId rootProject.ext.android.applicationId
        minSdkVersion rootProject.ext.android.minSdkVersion
        targetSdkVersion rootProject.ext.android.targetSdkVersion
        versionCode rootProject.ext.android.versionCode
        versionName rootProject.ext.android.versionName

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        dataBinding {
            enabled true
        }
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    //release版本輸出包名自動追加版本号和版本名稱
    applicationVariants.all {
        variant ->
            variant.outputs.all {
                //隻處理生産版本
                if (buildType.name == 'release') {
                    def createTime = new Date().format("YYYY-MM-dd", TimeZone.getTimeZone("GMT+08:00"))
                    // app包名稱
                    outputFileName = "macro" + defaultConfig.versionName + "_" + defaultConfig.versionCode + "_" + createTime + "_" + buildType.name + ".apk"
                    指定release輸出到指定檔案夾
//                    variant.getPackageApplication().outputDirectory = new File(" /Users/colin/Desktop/gasmart_app_version" + "/${createTime}")
                }
            }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //support
    implementation rootProject.ext.support["design"]
    //下拉重新整理,上拉加載
    implementation 'com.lcodecorex:tkrefreshlayout:1.0.7'
    //底部tabBar
    implementation('me.majiajie:pager-bottom-tab-strip:2.2.5') {
        exclude group: 'com.android.support'
    }
    //mqtt
    implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.4'
    implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
    //tab頂部
    implementation 'com.android.support:support-v4:23.1.1'
    implementation 'com.flyco.tablayout:FlycoTabLayout_Lib:[email protected]'
    implementation rootProject.ext.dependencies.MVVMHabit
    //懸浮按鈕
    implementation 'com.getbase:floatingactionbutton:1.10.1'
    //    implementation 'org.jetbrains:annotations-java5:15.0'
    implementation 'cn.bingoogolapple:bga-photopicker:[email protected]'
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support:support-v4:27.0.2'
    implementation 'com.android.support:recyclerview-v7:27.0.2'
    implementation 'cn.bingoogolapple:bga-baseadapter:[email protected]'
    implementation 'pub.devrel:easypermissions:1.0.1'
    implementation 'com.aliyun.dpa:oss-android-sdk:+'
    implementation 'com.github.bumptech.glide:glide:4.5.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.2'
    debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.2'
    debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
    implementation files('lib/AMap_Location_V4.5.0_20190121.jar')
    implementation files('src/libs/gprintersdkv22.jar')
    implementation files('src/libs/jcc-bate-0.7.3.jar')
    implementation files('src/libs/ksoap2-android-assembly-2.5.2-jar-with-dependencies.jar')
    implementation files('src/libs/xUtils-2.6.14.jar')
    implementation 'org.projectlombok:lombok:1.18.10'
    annotationProcessor 'org.projectlombok:lombok:1.18.10'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.qianwen:update-app:3.5.2'
    implementation 'com.qianwen:okhttp-utils:3.8.0'
    implementation 'com.lzy.net:okgo:3.0.4'
    implementation 'com.idescout.sql:sqlscout-server:4.1'
    implementation 'com.github.2tu.fit:fit:1.1.0'
    annotationProcessor 'com.github.2tu.fit:fit-compiler:1.1.0'
    implementation('com.github.gzu-liyujiang.AndroidPicker:WheelPicker:1.5.6') {
        exclude group: 'com.android.support'
    }
    implementation 'top.zibin:Luban:1.1.8'
    implementation 'org.java-websocket:Java-WebSocket:1.4.0'
    implementation files('src/libs/slf4j-android-1.7.30.jar')
    implementation 'com.blankj:utilcode:1.29.0'
    implementation files('src/libs/RemotePrinter_V3.3.jar')
    // 測試架構
    testImplementation 'junit:junit:4.12'
    // Required for instrumented tests
    androidTestImplementation 'com.android.support:support-annotations:24.0.0'
    androidTestImplementation 'com.android.support.test:runner:0.5'

    // objectbox
    debugImplementation "io.objectbox:objectbox-android-objectbrowser:$objectboxVersion"
    releaseImplementation "io.objectbox:objectbox-android:$objectboxVersion"
}
apply plugin: 'io.objectbox'


           

繼續閱讀