Show navigation Hide navigation

Importing Legacy Apps into Android Studio

In this document

You should also read

Importing some pre-Android-1.0 projects into Android 1.0 or newer can trigger a series of errors. This document shows you how to resolve them, using a version of the Sunshine app used in the Android Fundamentals Udacity Course as an example.

CAVEAT: As with all documentation of this kind, the details are likely to vary for each application and each update of Android Studio.

Prerequisites

Steps for Importing Sunshine into Android Studio 1.1.0

  1. Download Sunshine ZIP from GitHub: https://github.com/udacity/sunshine/tree/6.10-update-map-intent. (If you are having any problems with Android Studio or the app, use the following version, or your own app, to follow along with the example.https://github.com/udacity/sunshine/tree/3.13-add-share-action-provider)
  2. Unzip the application to extract the code folder.
  3. Start Android Studio. (This works best if you close all projects, then restart.)
  4. Click Import project (Eclipse ADT, Gradle, etc.).
  5. In the popup, find and select the Sunshine-6-10-updated-map-intent folder and click OK.
  6. If prompted, choose a destination folder for your project. If prompted to choose a build system, choose Gradle. (These prompts vary, depending on your project and Android Studio version.) If you need more guidance, see this Lynda tutorial.
  7. Wait for the import to complete. If you see no errors, you are now ready to work with your app.

    If you get a Gradle error:

  8. If you get a Gradle error, you have some extra work to do.(Because the Import didn(t finish, at this point, you may only see the Gradle Scripts directory in your Project view.)
  9. You may see the link Install missing platform(s) and sync project, or a link to install missing build tools. Click whatever link and proceed.
  10. The next time through, your build will fail with:
  11. Click the Fix plugin version and re-import project link in the error message. This will rebuild the app and present you with new of errors.
  12. Click the Gradle Settings link in the error message.
  13. Check the Use auto-import and click OK.
  14. Expand the project hierarchy and find the build.gradle file.The file you are looking for is not the one showing at the top level, but the one inside Sunshine > app > build.gradle, as shown below.
  15. Double-click the build.gradle file.
  16. Make the following changes to the file:
    • Set compileSdkVersion 21
    • Set targetSdkVersion 21
    • Replace runProguard with minifyEnabled

    Your file should look like this:

  17. Save (Ctrl-S).
  18. For the following two messages (Steps 18/19), what you see might vary. You might see either message or both messages in sequence. Click the appropriate links to continue until the Language Level Changed dialog opens.

  19. In the code view bar, click the Try again link.
  20. If you see these warnings, click the Sync now link.
  21. In the Language Level Changed dialog, click Yes. And if you get the Gradle Running dialog, Yes again.
  22. After the project reloads, run the app on your device. (If it crashes the first time, try again, and it will run.)