Guo Xiaoxing
Weibo: Guo Xiaoxing's Sina Weibo
Email:[email protected]
Blog: http://blog.csdn.net/allenwells
Github:https://github.com/allenwell
List of "Android Studio Discovery Road Series" chapters
One of the "Android Studio Discovery Trail Series": Android Studio begins
Android Studio Discovery Road Series II: Android Studio Software Installation
Android Studio Discovery Road Series III: Android Studio interface elements
Android Studio Discovery Trail Series: Android Studio shortcut keys
"Android Studio Discovery Road Series": Android Studio project creation
"Android Studio Discovery Trail Series" VI: Android Studio joins dependencies
"Android Studio Discovery Trail Series" VII: Android Project building System-Gradle
This article explains how to include jar, module, and so libraries in Android studio.
Dependency configuration for a jar package
First use the shortcut key ctrl+alt+shift+s to open the configuration of the current project. For example, as seen in:
1.1 Direct Search method
Click +->library dependency, for example, select the libraries you would like to join with the search you see.
1.2 Libs Addition method
Copy the library files directly to the Libs folder, assuming you are not able to create a new one, for example, as seen in:
Note: The Projectlibs folder for Eclipse import is under the root folder.
1.3 Gradle Addition method
We are also able to configure the library's dependencies directly in the module Build.gradle, for example, as seen in:
Dependent configuration of two module
Join the module that project relies on, such as what you see:
Dependency configuration of the three so libraries
Create the corresponding folder according to the CPU type, put in so library, and then copy the folder to the Libs folder. For example, as seen in:
Then add the following to the Build.gradle in the module, for example, as seen in:
After the so library link succeeds, a Jnilibs folder is generated next to the Src/main folder.
These are the import methods that rely on libraries. Since the project was developed on the basis of eclipse. Here's how to move the Eclipse project to Android Studio.
Export from eclipse
For example, as seen in:
- Upgrade your ADT plugin version number to more than 22.0.
- In Eclipse, select File–>export.
- In the export form that pops up, open the Android folder and select "Generate Gradle Build Files".
- Select the items you want to import into Android studio and click Finish.
The exported project will be in the same folder as the original project, overwriting the original same time, will add a file called Build.gradle, when importing Android studio will first read this file.
Import to Android Studio
For example, as seen in:
- In Android Studio, first turn off your current open project.
- On the Welcome screen, click Import Project (note: You can also select Import Project directly from the menu)
- Select the project that you exported in eclipse. Expand the folder and click the Build.gradle file. Then OK
- In the pop-up dialog box that follows. You will be asked to choose the Gradle configuration. Select the use Gradle wrapper. (Note: You can also define your own machine-installed gradle)
Suppose there is no grade build file. It is also possible to import an ordinary Android project into Android Studio, which will use the existing ant build. But in order to better use the post-function and make full use of build variables, it is strongly recommended to first generate the Gradle file from the ADT plugin and import it into Android studio.
"Android Studio Discovery Trail Series" VI: Android Studio joins dependencies