如何将Maven模块导入到Android Studio项目 [英] How to import a maven module to an Android Studio project

查看:810
本文介绍了如何将Maven模块导入到Android Studio项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Android Studio项目中将改造作为一个模块加入。问题是改造是一个maven项目,所以Android Studio不会让我导入它。有没有解决的办法?

一个类似的问题已被询问 之前,但它没有收到任何答案。 在你的克隆的POM中使用自定义组和/或工件,这样你的克隆就不会与原来的混淆。



使用Maven构建和安装Retrofit的克隆为通常: mvn install 。 (使用命令行或Android Studio以外的其他IDE。)每次更改后,您都必须手动构建您的Retrofit克隆,以便Gradle查看更改。



将本地Maven存储库添加到您的Gradle脚本中。请参阅 https://docs.gradle.org/2.5/dsl/org.gradle.api.artifacts.dsl.RepositoryHandler.html#org.gradle.api.artifacts.dsl.RepositoryHandler:mavenLocal()


 存储库{
mavenLocal()
}

将您的克隆的GAV作为依赖项添加到您的Gradle脚本中:

 依赖关系{
compile'c​​om.yourgroup:retrofit:1.9.0-custom'
}


I would like to include retrofit as a module in my Android Studio project. The problem is that retrofit is a maven project and so Android Studio won't let me import it. Is there a way around this?

A similar question has been asked before, but it received no answers.

解决方案

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'
}

这篇关于如何将Maven模块导入到Android Studio项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆