本文来自:https://developer.android.com/studio/releases/,大概就是做个翻译
比如compileSdkVersion把26改成28,把gradle从4.1改为4.4等,则:
一般需要调整下面几个文件的设置:(下面为项目的相对路径)
(1) \gradle\wrapper\gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
这个就是Gradle脚本的版本选择。注意这句最后的gradle-4.4-all.zip,要与com.android.tools.build:gradle:X.X.X
对应,具体看https://developer.android.com/studio/releases/gradle-plugin,列出了各个对应关系。命名规则也不难记,后面改成gradle-4.1-all.zip就是4.1版本。
(2) build.gradle:
classpath 'com.android.tools.build:gradle:3.1.3'
这个就是Android Plugin for Gradle。所以不用多说必须与gradle对应。
(3) app\build.gradle:
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
这个就是v7包版本。不用多说,compileSdkVersion去到28,一般就是以28开头了。具体的命名规则,还是算了,只要记得去maven仓库直接搜这个包,看看有哪些版本,填上适合的就行。
另外看提示,这个文件的compile或许需要改成api或implementation。
(4)SDK Platform Tools:sdk manager那里的sdk tools里面看
现在我写的时候最新是28.0.1,一般这个开头的28就是跟着你的sdk版本走。如果你sdk选了26,这个更新到28,那么很可能会提示你sdk与版本不对应。但是SDK Platform Tools版本高于sdk的话,一般还是没问题的,马上编译一次就不会再提示,但下次启动还是会提示,嫌烦人的话还是同步改下sdk版本吧。
(5)SDK Build Tools :在build.gradle文件里面用buildToolsVersion "28.0.2"
指定。一般不用管,不写这个自动采用对应版本,很舒服。命名规则也是那套,开头的28跟着sdk版本走。
(6)SDK Tools:sdk manager那里的sdk tools里面看
用来调试或其他什么的辅助工具。这个版本号目前还是26.1.1,迟点估计也会跟着sdk版本走。更新到最高就行,虽然26.1.1看起来对不上28,但实际上没有问题的。
(7)不记得命名规则或具体版本的依赖包,都直接去maven中央仓库直接搜这个包看看有哪些版本,实际就是maven那套东西。
附带sdk packages各个的说明:
SDK Tools
Contains tools for debugging and testing, plus other utilities that are required to develop an app. If you've just installed the SDK starter package, then you already have the latest version of this package. Make sure you keep this up to date.
SDK Platform-tools
Contains platform-dependent tools for developing and debugging your application. These tools support the latest features of the Android platform and are typically updated only when a new platform becomes available. These tools are always backward compatible with older platforms, but you must be sure that you have the latest version of these tools when you install a new SDK platform.
Documentation
An offline copy of the latest documentation for the Android platform APIs.
SDK Platform
There's one SDK Platform available for each version of Android. It includes an android.jar file with a fully compliant Android library. In order to build an Android app, you must specify an SDK platform as your build target.
System Images
Each platform version offers one or more different system images (such as for ARM and x86). The Android emulator requires a system image to operate. You should always test your app on the latest version of Android and using the emulator with the latest system image is a good way to do so.
Sources for Android SDK
A copy of the Android platform source code that's useful for stepping through the code while debugging your app.
Samples for SDK
A collection of sample apps that demonstrate a variety of the platform APIs. These are a great resource to browse Android app code. The API Demos app in particular provides a huge number of small demos you should explore.
Google APIs
An SDK add-on that provides both a platform you can use to develop an app using special Google APIs and a system image for the emulator so you can test your app using the Google APIs.
Android Support
A static library you can include in your app sources in order to use powerful APIs that aren't available in the standard platform. For example, the support library contains versions of the Fragment class that's compatible with Android 1.6 and higher (the class was originally introduced in Android 3.0) and the ViewPager APIs that allow you to easily build a side-swipeable UI.
Google Play Billing
Provides the static libraries and samples that allow you to integrate billing services in your app with Google Play.
Google Play Licensing
Provides the static libraries and samples that allow you to perform license verification for your app when distributing with Google Play.