JetBrain's IntelliJ 14 Android development
If you are a developer of Android Apps you are probably very familiar with the many Integrated Developer Environment (IDE) tools that are currently available. Several of the more prominent of these tools include: Android Studio, Eclipse, Netbeans and IntelliJ IDEA. Any one of these tools would be an excellent choice for app development but the IntelliJ stands out because it is less complex and is more user-friendly which appeals to a broader cross section of developers like you. In this article we will take a look at how you can use the IntelliJ IDEA Java IDE tool to create awesome Android apps.
Creating a new project
Before you can start to create a new Android project, you need to make sure you that you have installed all of the necessary prerequisites on your development computer. The two main prerequisites are as follows:
- Java SDK from Oracle's website
- Android SDK from Google's website
After you have downloaded and installed the required Java SDK and Android SDK you can begin to configure your IntelliJ 14 project by selecting from the (4) Android project types that are included with the SDK:
- Gradle Android Module - creates an Android module with folder structure and initial code that includes Gradle support.
- Application Module - creates a standard Android module with folder structure and initial code.
- Empty Module - creates an empty module for an Android app.
- Library Module - creates a library module for use in other Android apps.
For this article we will choose the Application Module then click the Next button (bottom right of the screen) to go to the package settings window:
In this window you can customize your Application name field, Package name field and also check the "Hello World" box to create a hello world initial activity that you can customize in the Activity name field.
In the next window you can select additional project settings such as: Project SDK and Target device as well as More Settings such as: Module name, Content root, Module file location and Project format:
Once you have finished entering information in all of the fields then click on the Finish button and your project will be created and the IntelliJ IDE window will display the Android layout for the visual editor on the right side, the Java code editor in the center, the Android layout xml editor on the left and in the far left side of the window you will see the project structure and also the external references used in it:
How to use the User Interface Editor
IntelliJ 14 includes an awesome Android layout visual editor:
This visual editor allows you to directly drag & drop elements to the layout surface. On the right side of the window there are two sections:
- Component tree - shows you a tree with your layout hierarchy. You can select an element from the list and see a visual representation of that element on the Android layout screen.
- Properties - shows all the properties of the current selected element. You can change the properties and see those changes reflected in the Android layout screen in real time.
In the center of the window, right above the Android layout screen, there are a series of control buttons that you can use to modify how the layout looks:
[1] - The orientation control enables you to change how the current layout is rendered inside the IDE.
[2] - The device selector drop down enables you to render your layout to any virtual device in the list.
[3] - The render orientation control enables you to select night mode or UI mode.
[4] - The layout display control enables you to apply theme changes to the layout currently displayed.
[5] - The activity control enables you to change associated activity.
[6] - The language control will translate text into other languages.
[7] - The API level control enables you to change the API Level.
A very awesome feature provided by the orientation control (first button) provides you with the capability to see the current layout in all screen sizes at the same time, how cool is that:
Deploying your app
You are now at the point where you can launch your app on an emulator or a real device. IntelliJ enables you to do this very easily by completing one final step in your project creation which is, to select your target device. To do this you will need to open the Choose Device window that will enable you to select your device or emulator that will be used when you run or debug your app:
If you use the Genymotion emulator it will be detected as a physical device by the Android SDK and it will be displayed along with the other devices. Simply select it, click the OK button and the application will be launched:Version control: Plastic SCM
Now that you have created your awesome app you need to protect it by implementing a source control solution. It is mandatory that you take this step but fortunately, due to the Plastic SCM integration with IntelliJ 14, this is very easy. The only action you need to take is to select the IntelliJ option during the Plastic SCM installation. Once installed you will select IntelliJ 14 from the VCS menu, select the Enable Version Control Integration option, select Plastic SCM as your version control system associated with the project root, click on the OK button and you are done:
If your project is located outside a Plastic SCM workspace path, you will receive an error indicating that your project cannot be located. To correct this, simply go to the VCS menu and select the option Create a Plastic SCM workspace:
Plastic SCM will automatically fill in all of the fields for you with the required information. Now just click the OK button and the integration will go live.
Once your integration goes live you will observe that the color of all your files have changed to red indicating that they were not added to Plastic SCM:
To correct this you simply right click over your project name in the tree (IntelliJAndroidApp) and from the Plastic SCM sub menu select Add option, which will add all of your project files to Plastic SCM and their color will then change to green:
You can now check in your files to Plastic SCM by right clicking over your project name and from the Plastic SCM sub menu select the check in directory, which will open the Commit Changes window. Be sure to write a good commit message and then click the Checkin button to put your code in the Plastic SCM repository:
Wrapping up
As you have seen in this article, JetBrain's IntelliJ IDEA 14 is a powerful IDE for Android app development. Not only does IntelliJ IDEA help you write better code, be more productive and get started coding faster, it will support a broad range of environments from Spring to JavaFX to Java EE for the ultimate in flexibility. The tight integration with Plastic SCM for source code management enables you to store your code in a Plastic SCM repository quickly and easily in a matter of minutes. To learn more about IntelliJ 14 go to JetBrain's website and to learn more about Plastic SCM visit the Plastic SCM website.
0 comentarios: