安卓項目導入AS常常出現問題,作一個總結,grable版本儘可能不要過低也不要過高android
把其中的app
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.4.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }
classpath 'ccom.android.tools.build:gradle:3.4.1'改爲本身對應的AS的版本,在本身的其餘項目中能夠查看。gradle
sdk的路徑設置成本身的ui
把這個文件的google
#Sat Jun 15 20:27:12 CST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl的gradle的版本設置爲AS的內置版本,一樣能夠在建立過的項目中查找。spa
apply plugin: 'com.android.application' android { compileSdkVersion 29 buildToolsVersion "29.0.0" defaultConfig { applicationId "com.example.dell.link_game" minSdkVersion 22 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.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:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation "com.android.support:support-v4:28.0.0" implementation 'com.android.support:design:28.0.0' 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' }
修改compileSdkVersion 29和 buildToolsVersion "29.0.0",修改成本身對應的版本,分別爲sdk版本和buildTools的版本。code