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?
我想在我的Android Studio项目中包含改造作为模块。问题是改造是一个maven项目,所以Android Studio不允许我导入它。有没有解决的办法?
A similar question has been asked before, but it received no answers.
之前曾提出类似的问题,但没有得到答案。
5 个解决方案
#1
14
Use a custom group and/or artifact in the POM of your clone, so your clone cannot be confused with the original.
在克隆的POM中使用自定义组和/或工件,因此不能将克隆与原始克隆混淆。
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构建和安装Retrofit的克隆:mvn install。 (使用命令行或Android Studio以外的IDE。)您必须在每次更改后手动构建Retrofit克隆,Gradle才能查看更改。
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():
将本地Maven存储库添加到Gradle脚本。请参阅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:
将克隆的GAV添加为Gradle脚本的依赖项:
dependencies {
compile 'com.yourgroup:retrofit:1.9.0-custom'
}
#2
5
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.
转到您的项目然后转到应用程序。您将在app下看到build.gradle文件(不要使用gradle文件夹下的gradle,而是使用app下的ine文件夹)。添加此行。
dependencies {
....
compile 'com.squareup.retrofit:retrofit:1.9.0'
...
}
Then, make sure that you define the repository details in directory and add the url.
然后,确保在目录中定义存储库详细信息并添加URL。
repositories {
flatDir {
dirs 'libs'
}
maven { url 'http://download.crashlytics.com/maven' }
}``
#3
1
Just add it to the dependencies { }
block of your application's build.gradle file.
只需将其添加到应用程序的build.gradle文件的dependencies {}块即可。
dependencies {
compile 'com.squareup.retrofit:retrofit:1.9.0'
}
#4
#5
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
在android studio中只需转到项目结构 - >模块你要添加改装 - >依赖项选项卡 - >加(添加) - >库依赖项然后在文本框中键入retrofit并选择com.squareup.retrofit:retrofit并添加到你的依赖
#1
14
Use a custom group and/or artifact in the POM of your clone, so your clone cannot be confused with the original.
在克隆的POM中使用自定义组和/或工件,因此不能将克隆与原始克隆混淆。
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构建和安装Retrofit的克隆:mvn install。 (使用命令行或Android Studio以外的IDE。)您必须在每次更改后手动构建Retrofit克隆,Gradle才能查看更改。
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():
将本地Maven存储库添加到Gradle脚本。请参阅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:
将克隆的GAV添加为Gradle脚本的依赖项:
dependencies {
compile 'com.yourgroup:retrofit:1.9.0-custom'
}
#2
5
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.
转到您的项目然后转到应用程序。您将在app下看到build.gradle文件(不要使用gradle文件夹下的gradle,而是使用app下的ine文件夹)。添加此行。
dependencies {
....
compile 'com.squareup.retrofit:retrofit:1.9.0'
...
}
Then, make sure that you define the repository details in directory and add the url.
然后,确保在目录中定义存储库详细信息并添加URL。
repositories {
flatDir {
dirs 'libs'
}
maven { url 'http://download.crashlytics.com/maven' }
}``
#3
1
Just add it to the dependencies { }
block of your application's build.gradle file.
只需将其添加到应用程序的build.gradle文件的dependencies {}块即可。
dependencies {
compile 'com.squareup.retrofit:retrofit:1.9.0'
}
#4
#5
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
在android studio中只需转到项目结构 - >模块你要添加改装 - >依赖项选项卡 - >加(添加) - >库依赖项然后在文本框中键入retrofit并选择com.squareup.retrofit:retrofit并添加到你的依赖