How to import a maven module to an Android Studio project

余生长醉 提交于 2019-12-01 15:44:45

Use a custom group and/or artifact in the POM of your clone, so your clone cannot be confused with the original.

Build and install your clone of Retrofit using Maven as usual: mvn install. (Using the command line or an IDE other than Android Studio.) You have to build your Retrofit clone manually after each change you make to it, for Gradle to see the changes.

Add the local Maven repository to your Gradle script. See https://docs.gradle.org/2.5/dsl/org.gradle.api.artifacts.dsl.RepositoryHandler.html#org.gradle.api.artifacts.dsl.RepositoryHandler:mavenLocal():

repositories {
    mavenLocal()
}

Add the GAV of your clone as a dependency to your Gradle script:

dependencies {
    compile 'com.yourgroup:retrofit:1.9.0-custom'
}
Bamra Lochaz

Go to your project then goto the app. You will see a build.gradle file under app (DO NOT use the gradle under gradle folder but the ine under app folder). Add this line.

 dependencies {
....
compile 'com.squareup.retrofit:retrofit:1.9.0'

...

}

Then, make sure that you define the repository details in directory and add the url.

 repositories {
        flatDir {
            dirs 'libs'
        }
        maven { url 'http://download.crashlytics.com/maven' }
    }``
dhaag23

See Migrating from Maven to Gradle. Just execute gradle init.

Just add it to the dependencies { } block of your application's build.gradle file.

dependencies {
    compile 'com.squareup.retrofit:retrofit:1.9.0'
}

In android studio simply go to project structure -> module you want to add retrofit -> dependencies tab -> plus(add) -> library dependency and then type retrofit in text box and select com.squareup.retrofit:retrofit and add to your dependencies

another soluation , just download latest jar file from https://github.com/google/retrofit then goto new module ->create module of jar->select the path of that jar file->then on your project module gradle dependency add(implementation(':name retrofit module').

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!