The following is the second tutorial on IDE Android studio released at the Google I/O conference:
In the android studio tutorial (I), I briefly introduced the basic usage of Android studio, including installation, new project, project structure, and topic settings. Next I will talk about the second article, mainly including the following:
- Import a project from eclipse to Android Studio
- Differences between eclipse and Android Studio
- Real machine running and common shortcut keys
I need to reiterate that all my operations and versions are based on MAC systems, and my colleagues on windows are basically similar (as a technician, these should not be a problem ), let's start with a topic:
1. Import the project from eclipse to Android studio according to the official introduction, Android studio can be compatible with existing eclipse projects, but some operations are required:
- First, upgrade the ADT to the latest version. Currently, the version number is 22. (It is best to upgrade the components related to the ADT to avoid future errors)
- Select the project to be exported from eclipse, right-click Export, and select generate gradle build files (for example) under Android ):
After selection, it is not exported to other places. Instead, a build. gradle file is generated in the local project. You can also see that this file is recognized by Android studio, for example:
3. Then go to Android studio and select import project. You can see that the project icon in eclipse has changed to an android robot icon, indicating that the conversion is successful. In this case, select import project:
Now, you have finished importing an existing Android project from eclipse to Android studio. Now you can start to operate the project!
Ii. Differences between eclipse and Android Studio
- Eclipse projects can be imported to Android studio for running, but projects created in Android studio cannot be run in eclipse;
- The two have different engineering structures. In eclipse, a project represents a project. In Android studio, like intellij, a project represents a workspace, which is equivalent to a workspace in eclipse, in Android studio, a module is equivalent to a project in eclipse. You need to understand this concept. Do not mix it up or get confused.
- In the editing operation, after editing and modifying in eclipse, the file must be manually saved by command + S. In Android Studio, the file is automatically saved like intellij, this is similar to that in xcode.
- In eclipse, SRC is generally a Java file, and RES is a resource file, including layout files and multimedia resources. In Android studio, you can view the directory structure:
The java files and resource files are all stored in the src directory. the src directory contains a main folder, and the following are the Java folder and res folder. In fact, here, the Java folder is equivalent to the SRC in eclipse. Res is still the res. Here I think of the sketch of the instructor Benshan: "src is not the SRC, RES is the res"
3. You can click the android tab at the bottom of the page in Android studio to view the device information and logcat. After the device is connected, the android tab will check the real machine, the project is displayed in device. Click the green arrow on the top to start running the project. One thing to note is that you can select a simulator or a real machine during running, because there is a device priority when running the project in Android studio, if this parameter is not set, it may only run on the simulator. You can set it as follows: Click the run menu and select Run.
Configuration, and select the target device you want to select. It can be a simulator or a real machine, or you can select this device during running:
You can familiarize yourself with the shortcut keys in the official documents, as shown in the following table. You can also customize the configuration options by yourself:
I personally think that android studio still has a certain prospect. here we need to constantly improve and improve Google, so hurry up and rescue everyone from eclipse. In addition, during this period, you can actually try intellij idea, which is also integrated with the android development environment by default. Android
Studio is improved based on the former, and the two are similar in use, which is also a good replacement for eclipse. I will record an article dedicated to Android development using intellij idea later!
To join our QQ group or public account, see: Ryan's
Zone public account and QQ Group
At the same time, you are welcome to follow my Sina Weibo chat with me: @ Tang Ren _ Ryan
I think this article is useful to you!