Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import module or project as Library on Android Studio

I want to use HoloEverywhere (HE) Preferences AddOn with my live wallpaper project. The project is almost done, i just need it to look the same from android 2.3 to 4.4, so i went on and followed the guide to get HE from GitHub.

After the checkout and the successful test of the "Demo" module, i went back to my project, but i can only create a new module, not import one, and of i try to set the new project to the module's folder (library and addons in my case) Android Studio as me if i want to rewrite the module settings, if i do, it create the folder, but it will not compile and the import org.holoeverywhere will not work.

like image 614
joao Beno Avatar asked Dec 23 '13 14:12

joao Beno


People also ask

What is module in Android Studio project?

Modules. A module is a collection of source files and build settings that allow you to divide your project into discrete units of functionality. Your project can have one or many modules, and one module may use another module as a dependency. You can independently build, test, and debug each module.

How do I import a module into gradle?

In Android Studio, Right-clicking on the folder to add as library. Editing the dependencies in the build. gradle file, adding: compile fileTree(dir: 'libs', include: '*. jar')}

What is the difference between AAR and jar?

The main difference between a Jar and an AAR is that AAR s include resources such as layouts, drawables, etc. . For example if you have multiple apps that use the same login screen, with Jar's you could share classes but not the layout, styles, etc., you still had to duplicate them.

How to import library project or module as dependency in Android Studio?

How to Import Library Project or Module as Dependency in Android Studio Objective Introduction on how to import library project or module as dependency in Android Studio: Step 1 Create New Project in Android Studio Step 2 Now open file menu and click on import module Step 3 Open Directory Step 4 Select Directory Module Step 5 Register Module

How do I add a module to my Android Studio project?

Click the (+) icon and select Module Dependency. Select the module and click Ok. Open your build.gradle file and check that the module is now listed under dependencies. implementation project (path: ':ViewPagerIndicator') Steps to import Module in Android Studio 3.4 and higher (See attached image).

How do I import a Gradle library into Android Studio?

Just click‚ synch the project with Gradle. Your library should be available for your project. Click on “ Import Existing Project “. Step 2: Select the desired library and the desired module. Then click finish. Android Studio will import the library into your project and will sync Gradle files.

How do I import a module in Android?

Import Module in Android 1 Click File > New > Import Module . 2 In the Source directory box, type or select the directory of the module (s) that you want to import: If you are importing one module, indicate its root directory. ... 3 Type your desired module name (s) in the Module name field (s). 4 Click Finish. See More....


Video Answer


2 Answers

You can set external module in this way

In global setting.gradle file add this line

def projectDialogsDir = file('path_of_the_module')
def rootProjectDescriptor = settings.rootProject
settings.createProjectDescriptor(rootProjectDescriptor, 'yourModule', projectDialogsDir)
include(':yourModule')

Then in the build.gradle files of your app's module, you have just to add, under dependencies

dependencies {
  compile project(':yourModule')
}
like image 160
Stefano Avatar answered Oct 13 '22 12:10

Stefano


There isn't an import module command yet; you'll have to do it manually. The high-level overview is that you'll need to set up a build.gradle file for your library module, include the library module in your project's settings.gradle file, and add a dependency from your app to the library project (which you can do by hand or through the Project Structure UI).

To set up the library module and include it, you can either author the relevant changes from scratch, or you can go through the Add Module UI to create a blank module, and then copy the files from the library into the template. If you want instructions on how to do the latter to include the Facebook library, see this: using facebook sdk in android studio and modify as necessary for holoeverywhere.

like image 24
Scott Barta Avatar answered Oct 13 '22 12:10

Scott Barta