如何将 Maven 模块导入到 Android Studio 项目中

如何将 Maven 模块导入到 Android Studio 项目中

问题描述:

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

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.

在您的克隆的 POM 中使用自定义组和/或工件,这样您的克隆就不会与原始的混淆.

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

像往常一样使用 Maven 构建和安装 Retrofit 的克隆:mvn install.(使用命令行或 Android Studio 以外的 IDE.)您必须在每次更改后手动构建 Retrofit 克隆,以便 Gradle 看到更改.

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.

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

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()
}

将克隆的 GAV 添加为 Gradle 脚本的依赖项:

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

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