an example of migrating older android projects to android studio 3

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.

working with android – again

It’s been some time since I last fired up Android Studio and tinkered about with Android. It was with Android 5 and I was working on a calculator application and testing it on my Samsung Galaxy S4. This time I’m taking some pre-written example applications published by Deitel & Deitel (Android 6 for Programmers, Third Edition) and stepping them up to usability in Android Studio 3.0.1 and Android 7.1.1 running on a Moto G5S Plus Android handset I picked up earlier this year as a spare unlocked device. It was on sale at B&H Photo at the time.

I’ve getting back into Android programming as quickly as possible because the tools have advanced tremendously since the last time I put them down. It’s also in part due to my cooling feelings towards all things Apple. Compared to Apple development it’s just so easy to put an Android handset into developer mode and then hook it into a computer and side-load applications you’ve written. With a handset the test-debug loop is a lot tighter and faster than with an emulator. Even when your development platform is a MacBook Pro.

No wild promises. I’m just tinkering and thinking. And having a little nerdish fun.