Showing posts with label Eclipse to Android studio project migration. Show all posts
Showing posts with label Eclipse to Android studio project migration. Show all posts

Saturday, July 25, 2015

Migrating to Android Studio from Eclipse

 Migrating to Android Studio from Eclipse

Android Studio is the official IDE for Android application development, based on IntelliJ IDEA. On top of the capabilities you expect from IntelliJ, Android Studio offers:
  • Flexible Gradle-based build system
  • Build variants and multiple apk file generation
  • Code templates to help you build common app features
  • Rich layout editor with support for drag and drop theme editing
  • lint tools to catch performance, usability, version compatibility, and other problems
  • ProGuard and app-signing capabilities
  • Built-in support for Google Cloud Platform, making it easy to integrate Google Cloud Messaging and App Engine
  •  
Property name
Property value
Project name
SRM_QRScanner
Package name
in.ac.srmuniv.qrscanner
Activity name
SRM_ScannerActivity
Layout xml name
scanner

Creating a   project from  Android Studio 1.2.2
1.Create a new project File->New ->New Project

2.Select minimum SDK tells you how much your application is going to be backward compatible. app support library will be added to your project  so that new features added in latest versions of Android will be made usable in backward versions too.


3.Select Blank Activity and click next
4.Name the Activity java source file and layout XML file

5.Project is created with automatic Gradle build .Rendering problem is sorted out by selecting an AppTheme.
6 Select App Theme according to your App requirement.Here we have selected Holo Light Theme in which Holo.Light .DarkActionBar  theme style is selected your selection can be seen in styles.xml
7.Now your application is ready for development.With this default run through of the wizard we have created an app with one screen (Activity) with "Hello world" label in left corner.If you run the application you are already provided with one default emulator the application will launch in the emulator with the same screen you see in the layout editor.
Creating  project/library from existing Eclipse  project in to Android Studio.
8.Select File->New->Import Project to import project developed in eclipse IDE
9.Select the eclipse project/ from eclipse workspace
10 Click Next.In general the project will be stored in Android Studio Projects folder but you can also change the location.

 11.Leave with the default selections and click Finish.
 12.The Project will be Re build from Gradle build system
13.Import summary will show you any issues such as target platform not found if the target platform (SDK version) is not available in your system it will ask you to download.

 14.Here build.gradle file in app folder needs to be modified to available SDK versions we have downloaded in our system.I our case we have API level 22 but not 21.Hence change to 22 as Shown in Fig 18.

15.These steps are required only  if the imported project is an Library project.Rename the app folder to another name by refactoring in our case we have renamed it as library.
16.Here we have named it as library.Running the gradle will change entry in settings.gradle file as shown below.
17.The app folder getting changed to library.Also see the change in settings.gradle file

18.Here we show you the changed SDK version in build.gradle file.The defaultConfig entry will not contain applicationID.if it is library project

Importing library project/module to Android Studio project
19.Select New->Import Module to import our library project.

20.Select the library project which has been already build.

21.You can see when the library  project android is selected. it automatically selects the module folder.Since we have renamed the folder to library  from app  there no conflict with our  SRM_QRScanner project app folder.
22.Here library module is added to the SRM_QRScanner project.

23.Select File-> Project Structure menu from File
24.Select app =>select tab Dependencies=>Select include -> click '+' button =>Select Module dependency.You will get the library module select it.
25.On selection of library module entry is updated in build.gradle.
26.Add the following lines in appropriate places in AndroidManifest.xml file to eradicate the error for resolving mismatching theme of imported library app.Then finally Sync Gradle to build .