简体   繁体   English

Android-如何从Maven Central导入库?

[英]Android - How to import library from Maven Central?

I want to use zt-zip library in my project. 我想在我的项目中使用zt-zip库。 Library page on github says that I should have this dependency: github上的库页面说我应该有这个依赖关系:

<dependency>
    <groupId>org.zeroturnaround</groupId>
    <artifactId>zt-zip</artifactId>
    <version>1.8</version>
    <type>jar</type>
</dependency>

I used to add dependency in this way for other libraries. 我曾经以这种方式为其他库添加依赖项。 For zt-zip I could not find dependency like this: 对于zt-zip,我找不到这样的依赖项:

compile 'com.loopj.android:android-async-http:1.4.9'

So I tried this: 所以我尝试了这个:

compile 'org.zeroturnaround.zt-zip:1.8'

Unfortunately getting this error: 不幸的是得到这个错误:

Error:Failed to resolve: org.zeroturnaround.zt-zip:1.8 错误:无法解决:org.zeroturnaround.zt-zip:1.8

I have tried to add mavenCentral() and maven() with url: 我试图用URL添加mavenCentral()和maven():

repositories {
    jcenter()
    maven { url 'http://repo1.maven.org/maven2' }
    mavenCentral()
}

Still getting this error: 仍然出现此错误:

Error:Failed to resolve: org.zeroturnaround.zt-zip:1.8 错误:无法解决:org.zeroturnaround.zt-zip:1.8

Question: how to add dependency from Maven Central? 问题:如何从Maven Central添加依赖项?

The Maven Central Repository is your friend. Maven中央存储库是您的朋友。 Just do a quick search for your desired package and it will return the correct format for Maven, Ivy, Gradle and more. 只需快速搜索所需的软件包,它将为Maven,Ivy,Gradle等返回正确的格式。 In this case, you need to write the dependency as: 在这种情况下,您需要将依赖性写为:

compile 'org.zeroturnaround:zt-zip:1.8'

You have a dot in 你有一个点

compile 'org.zeroturnaround.zt-zip:1.8'

try with a colon 尝试用冒号

compile 'org.zeroturnaround:zt-zip:1.8'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM