最好的方式来增加对依赖Android中使用工作室线摇篮 [英] Best way to add dependency for Wire using Gradle in Android Studio

查看:220
本文介绍了最好的方式来增加对依赖Android中使用工作室线摇篮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是方形的电线库我的Andr​​oid应用程序,使用Android Studio和摇篮。

I'm using Square's Wire library for my Android app, using Android Studio with Gradle.

我最初加入线运行时1.2.0.jar 文件夹我的模块中,并添加这样的依赖于摇篮在我的的build.gradle 文件:

I originally added the wire-runtime-1.2.0.jar into a libs folder in my module, and added the dependency to Gradle like this in my build.gradle file:

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

这工作得很好。

我是新来的摇篮和Android工作室,但基于我取决于谷歌支持的方式和播放服务库,我想我或许可以删除线runtime- 1.2.0.jar 库从我的仓库,只需要声明的依赖关系是这样的(该行是从的 Maven仓库):

I'm new to Gradle and Android Studio, but based on the way I'm depending on the Google Support and Play Services libraries, I thought I might be able to remove the wire-runtime-1.2.0.jar library from my repository and just declare a dependency like this (the line is from the Maven repository):

dependencies {
    compile 'com.squareup.wire:wire:1.0.0'
}

但如果我这样做,然后我打这个错误:

But if I do that then I hit this error:

Gradle: package com.squareup.wire does not exist

有没有一种方法来设置这种依赖性,而不用直接导入JAR文件?还是只为可以通过SDK管理器中安装库工作?

Is there a way to set up this dependency without importing the JAR file directly? Or does that only work for libraries that you can install through the SDK Manager?

推荐答案

有些软件包,如 com.squareup.wire ,在Maven的中央多个文物。你需要选择正确的适合您的需求。在这种情况下,线运行时1.2.0.jar 相当于是线运行神器,不在线神器。

Some packages, like com.squareup.wire, have multiple artifacts in Maven Central. You need to choose the right one for your needs. In this case, the equivalent of wire-runtime-1.2.0.jar is the wire-runtime artifact, not the wire artifact.

这是你的依赖关系部分应该是什么样子:

Here's what your dependencies section should look like:

dependencies {
    compile 'com.squareup.wire:wire-runtime:1.2.0'
}

这篇关于最好的方式来增加对依赖Android中使用工作室线摇篮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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