[JAVA] [Android Studio] I want to use Maven library on Android


I think there are many times when you want to add an external library to your Android project. Among the various ways to add libraries, there is only "Import Project / Module" to customize the library source. However, this method had many parts that had to be rewritten, and it was a lot of troublesome work, so I wrote an article instead of a memo.


You probably have a Maven external library that you want to add. First, let's make it possible to manage the Maven library with gradle.

cd [Folder containing the library you want to add]
gradle init --type pom

Android Studio cannot read pom.xml which exists like build.gradle in Maven. Therefore, the above command converts pom.xml to build.gradle.

Now that it's sunny and can be loaded in Android Studio, select the project you want to add the library to and select [File]-> [New]-> [Import Project].


Then select the library you converted earlier. It's finally the turning point here (laughs)

You'll probably get a Gradle Sync error here like this: -I don't have ~ / AndroidManifest.xml? ――The description of ~ / build.gradle is not enough! With a feeling

If you get angry, you have to fix it, so Do as the error says.

  1. AndroidManifest.xml It seems that it is useless without PackageName, so create a new AndroidManifest.xml file described as follows.

    <?xml version="1.0" encoding="utf-8"?>
    <manifest package="com.○○○.△△△"> //Write ○ and △ with reference to Maven(suitable)
      <application />
  2. build.gradle The previous command gradle init --type pom only ported dependencies, so you have to write the rest yourself. The following is a sample, but please adjust to your environment as appropriate.

    apply plugin: "com.android.library"
    android {
      compileSdkVersion 26
      buildToolsVersion "26.0.1"
      defaultConfig {
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    description = 'Library name'
    dependencies {

This is the end of preparation. After that, right-click the project you want to add and select [Configure Project Subset]. I think that the library you imported earlier has not been checked yet, so let's check it.

How about that? The rest is complete if you do a Rebuild Project.

Reference site

Make a pom.xml project into an Android Library and let the IDE read it

Recommended Posts

[Android Studio] I want to use Maven library on Android
I want to use NetBeans on Mac → I can use it!
I want to simplify the log output on Android
I want to use FormObject well
I want to use screen sharing on the login screen on Ubuntu 18
I want to display background-ground-image on heroku.
I want to use swipeback on a screen that uses XLPagerTabStrip
I want to use DBViewer with Eclipse 2018-12! !!
I want to install PHP 7.2 on Ubuntu 20.04.
I want to use @Autowired in Servlet
How to use ExpandableListView in Android Studio
I want to use arrow notation in Ruby
3 ways to import the library in Android Studio
I want to use java8 forEach with index
I want to use Clojure's convenient functions in Kotlin
How to use Maven that I can't hear anymore
I want to use fish shell in Laradock too! !!
How to use java non-standard library on IntelliJ IDEA
I want to use ES2015 in Java too! → (´ ・ ω ・ `)
How to use Truth (assertion library for Java / Android)
I made a library for displaying tutorials on Android.
Multipart transmission library on Android
Use serial communication on Android
I want to convert characters ...
Use native code on Android
[Beginner] I want to modify the migration file-How to use rollback-
I tried adding a separator line to TabLayout on Android
How to use OpenCV 4 on Android and view camera live view
Use Java included with Android Studio to build React Native
I want to use the sanitize method other than View.
I want to put the JDK on my Mac PC
I want to use FireBase to display a timeline like Twitter
I want to use Java Applet easily on the command line without using an IDE
When you want to implement Java library testing in Spock with multi-module in Gradle in Android Studio 3
Swift: I want to chain arrays
How to use PlantUML with Visual Studio Code (created on October 30, 2020)
I tried to create a simple map app in Android Studio
How to "hollow" View on Android
I want to add a browsing function with ruby on rails
I just want to write Java using Eclipse on my Mac
How to use Ruby on Rails
I want to convert InputStream to String
How to use Bio-Formats on Ubuntu 20.04
I want to docker-compose up Next.js!
Easy to use Cloud Firestore (Android)
Preparing to use electron-react-boilerplate on Ubuntu 20.4
I want to add the disabled option to f.radio_button depending on the condition
Steps to install Maven on Mac and use it in Eclipse
[Android] I want to get the listener from the button in ListView
Summary of means when you want to communicate with HTTP on Android
eclipse I definitely want you to use Transcendental Recommended Shortcut Key (Windows)
[Java Spring MVC] I want to use DI in my own class
I want you to use Enum # name () for the Key of SharedPreference
Is it possible to put the library (aar) in the Android library (aar) and use it?
I want to develop a web application!
A memorandum on how to use Eclipse
How to use Apache Derby on Eclipse
I want to write a nice build.gradle
I want to eliminate duplicate error messages
[Ruby on Rails] How to use CarrierWave
Sample to display (head-up) notifications on Android