If you want to update your old Android Studio project with latest SDK and Gradle, here is the proper method to do it ...


How to upgrade Android Studio project?


Step 1) If you come back to work with Android Studio after a while, you should delete present Android Studio software first. Here is how to do that.

 

Step 2) Download the latest version of Android Studio from it's official website - https://developer.android.com/studio

 

Step 3) Open your old Android Studio project, and it will recommend to update project. Let's start. Alternatively you can get it in Tools > AGP Upgrade Assistant


AGP Upgrade Assistant

 

Step 4) Choose latest Gradle, and click on "Run selected steps". If you are provided with any instruction, follow it. 

 

Run AGP Upgrade Assistant

 

Step 5) Go to FIle > Project Structure > Gradle, and see Gradle Version. For example, Android Studio set the new version 8.0 and you should keep it in that way. Click on Apply > Ok


upgrade Android Studio project Gradle

 

Step 6) Now upgrade SDK. Go to  FIle > Project Structure > Modules > Properties. Choose latest version. Build Tools version should be the same. Click on Apply > Ok

 

upgrade to latest SDK

 

Step 7) Go to  FIle > Project Structure > Modules Default Config. Choose latest version and Minimum SDK. Also update version code and version name. Otherwise Google PlayStore will not allow you to upload a new version of your .aab file. Click on Apply > Ok

 

Choose Minimum SDK in Android Studio

 

Step 8) You will get some suggestions too. Update too. Click on Apply > Ok



 Step 9) Now do the following steps:  


  • File > Save All
  • File > Sync Project with Gradle Files
  • Build > Clean Project
  • Build > Rebuild Project


you may finally test by creating an .apk file. Go to Build > Build Bundle(s) / APK(s) > Build APK(s).  If it has any problems, you will be informed. Solve problems one by one.

You are Done!

 

 

Note: If you download old Android Studio project files from Google Drive, you may notice some files are automatically renamed. For example, in Project > Gradle > Wrapper folder you will find the file gradle-wrapper.properties renamed to gradle-wrapper.properties.txt 

 

Also look in Project folder for

  • gradle.properties
  • local.properties

Just remove extra .txt from every file. There will be only one dot (.) in file names.