Android Studio导入项目遇到的一些问题

    初学Android,现在用的是Android Studio 3.1,gradle版本是4.4。在导入看的书配套的源代码的时候,因为书上用的ide版本是2.3,gradle版本也不对,build时报了这样的警告:

    Configuration 'compile' is obsolete and has been replaced with 'implementation'.
It will be removed at the end of 2018
    The specified Android SDK Build Tools version (24.0.2) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.0.Android SDK Build Tools 27.0.3 will be used.
    To suppress this warning, remove "buildToolsVersion '24.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
    Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation'.
It will be removed at the end of 2018
    Configuration 'testApi' is obsolete and has been replaced with 'testImplementation'.

It will be removed at the end of 2018

    百度了一下,需要修改build.gradle Project文件,按百度的方法修改完后,仍然有警告。后来,我直接把之前不报警告的项目的build.gradle Project和build.gradle Module的内容拷贝替换过去了,这次没有警告了。

    两个的区别在这(上方有警告,下方正常):

    build.gradle Project:

allprojects {
    repositories {
        jcenter()
    }
}

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

    build.gradle Module:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"

    defaultConfig {
        applicationId "com.example.recyclerviewtest"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:recyclerview-v7:24.2.1'
}
apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.a41442.hellpworld"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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


你可能感兴趣的:(学习笔记)