Android Studio從2.3升級到3.1注意事項

來源:互聯網
上載者:User

標籤:tor   jce   file   升級   pil   警示   services   http   報錯   

原文:80111111Android Studio從2.3升級到3.1注意事項
  • 項目根目錄下的build.gradle 
    1.buildscript和allprojects的repositories中添加google() 
    2.dependencies中的classpath中將gradle版本修改為對應版本,如3.1.2

    buildscript {    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 替換為 androidTestImplementation

    dependencies {    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注意事項

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.