android studio 2.2.3 升級到3.1.2 原有專案編譯問題

smilestone322發表於2019-02-13

編譯不過,需要修改一下幾個檔案:紅色部分是需要修改的。

1)build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
 

 

2) app/build.gradle

apply plugin: 'com.android.application'
/*def getTime() {
    return new Date().format("yyyyMMdd", TimeZone.getTimeZone("UTC"))
}*/

android {
    compileSdkVersion 27
 //   buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "com.orbbec.obdepth"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 3
        versionName "1.1.7"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
 //           shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }


    /*applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def outputFile = output.outputFile
            def fileName
            if (outputFile != null && outputFile.name.endsWith('.apk')) {
                if (variant.buildType.name.equals('release')) {
                    fileName = "obDepth_${defaultConfig.versionName}_${getTime()}.apk"
                } else if (variant.buildType.name.equals('debug')) {
                    fileName = "obDepth_${defaultConfig.versionName}_${getTime()}.apk"
                }
                output.outputFile = new File(outputFile.parent, fileName)
            }

        }
    }*/

    sourceSets{
        main{
            jniLibs.srcDirs =['libs']
        }
    }
}
/*
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:23.2.1'
    testImplementation 'junit:junit:4.12'
}
*/

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

}

android {
    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
    }
}

 

3)gradle\wrapper\gradle-wrapper.properties

#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip

相關文章