Android Studio從2.3升級到3.1註意事項
阿新 • • 發佈:2018-06-13
刪除 -c 默認 clas 空白 repo wrap 如果 not
原文:https://blog.csdn.net/lithiumyoung/article/details/80111111
Android Studio從2.3升級到3.1註意事項
-
項目根目錄下的build.gradle
1.buildscript和allprojects的repositories中添加google()
2.dependencies中的classpath中將gradle版本修改為對應版本,如3.1.2buildscript { repositories { google() jcenter() } dependencies { classpath ‘com.android.tools.build:gradle:3.1.2‘ } } allprojects { repositories { google() jcenter() } }
- module目錄下的build.gradle
-
1.刪除buildToolsVersion。Android Studio3.0之後不需要再指定buildToolsVersion,每個版本的Android Gradle插件都有默認版本的構建工具,不刪除只會報警告,但是這句指定構建版本的語句會被忽略
2.dependencies中 compile 替換為 implementation ,testCompile 替換為 testImplementation ,androidTestCompile 替換為 androidTestImplementationdependencies { implementation fileTree(dir: ‘libs‘, include: [‘*.jar‘]) implementation ‘com.android.support:appcompat-v7:27.1.1‘ 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‘ }
-
項目根目錄下的gradle/wrapper文件夾下的gradle-wrapper.properties文件
修改 distributionUrl 的地址distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip
-
註意:多數教程中都沒有提及這個文件,如果不改此處的地址,編譯報錯
Gradle DSL method not found: ‘google()‘ Possible causes: The project ‘app‘ may be using a version of the Android Gradle plug-in that does not contain the method (e.g. ‘testCompile‘ was added in 1.1.0).
註意:具體修改內容可用新安裝的Android Studio新建一個空白工程作為參照
Android Studio從2.3升級到3.1註意事項