In the last post I spoke of getting back into some semblance of Android application development. Part of the effort was the migration of Deitel and Deitel example applications from “Android 6 for Programmers, Third Edition.” What follows are the specific steps needed to move these example applications into Android Studio 3.0.1. In the process I’m going to begin to move the applications from Android 6 to Android 7.1.1. In this post example I’m going to migrate the WelcomeInternationalized app.
First, open the project and load it into Android Studio. Android Studio will attempt to load the project using the project’s default Android SDK location. This will fail, but this is normal, and Android Studio will automatically correct it for you.
After changing the Android SDK location, Android Studio finishes opening the project and attempts to build it. This creates the first error.
This is caused by one of two Gradle build files.
Go to the file navigator on the left and expand Gradle Scripts. Open the top, or project, build.gradle file. Highlight the first line in the dependencies block (line 8 in the example above). That’s what’s causing the project build failure.
With the line highlighted (the cursor placed on the line) a “lightbulb” will appear to the left of the line with a dropdown arrow. Click that arrow for the dialog above. The first entry on the dropdown is to change the version to 3.0.1. Click that, and then resync the project by clicking the “Try Again” link. Note that you can also simply type in 3.0.1.
You’re still not done. Now the build process complains of the Gradle wrapper. Click the hyperlinked line in the error to fix this second error.
At this point the project has rebuilt with just one warning. Let’s get rid of that warning.
Open the second build.gradle file, the one labeled (Module: app) and comment out the buildToolsVersion line (line 5 in our example). As the warning says, this is no longer needed. Then rebuild the project again by clicking “Sync Now” in the upper right. This final tweak will result in a clean build with no errors or warnings.
So far I’ve done a bit more with the Dietel and Dietel example applications than just move them over. The examples, written for Android 6, are solid examples and interesting in what Android 6 capabilities they expose to the student. They’re worth “upgrading” and moving along into Android 7.x and even Android 8. But to get to that point you need to be able to work with any of them in Android Studio 3.
It should be noted that the original examples were written in an environment running Java JDK 7, Android Studio 1.4, and Android SDK 23. My environment is running Java JDK 8 u152, Android Studio 3.0.1, and Android SDK 25/7.1.1/Nougat.
You must be logged in to post a comment.