Original: 80111111Android Studio upgrade from 2.3 to 3.1 considerations
Build.gradle under the project root directory
Add Google () to the repositories of 1.buildscript and allprojects
Change the Gradle version to the corresponding version in Classpath in 2.dependencies, such as 3.1.2
buildscript { repositories { google() jcenter() } dependencies { classpath ‘com.android.tools.build:gradle:3.1.2‘ }}allprojects { repositories { google() jcenter() }}
- Build.gradle under the module directory
1. Delete Buildtoolsversion. Android Studio3.0 no need to specify Buildtoolsversion, each version of the Android Gradle plugin has a default version of the build tool, do not delete will only report a warning, but this sentence specifies the build version of the statement will be ignored
Compile in 2.dependencies is replaced with implementation, Testcompile is replaced with Testimplementation, Androidtestcompile is replaced by 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.properties file under the Gradle/wrapper folder in the project root directory
Modify the address of the Distributionurl
distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip
Note: Most tutorials do not mention this file, if you do not change the address here, compile error
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).
Note: Specific modifications can be used to create a new blank project as a reference in a newly installed Android studio
Android Studio upgrade from 2.3 to 3.1 considerations