将 Volley(或其他库)合并到 Android Studio 项目中的最佳方式 [英] Best way to incorporate Volley (or other library) into Android Studio project

查看:28
本文介绍了将 Volley(或其他库)合并到 Android Studio 项目中的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了有关执行此操作的最佳方法的不同建议这个问题包括创建一个 jar.在其他地方,我看到了简单地将 volley 源复制到您自己的项目中的建议.本节关于图书馆android.com 似乎是最权威的.但是,编译 volley 后,我没有 aal 库,而该部分说我应该有.

I've seen different advice on the best way to do this This question covers creating a jar. Elsewhere, I've seen advice to simply copy the volley source into your own project. This section on libraries at android.com would seem the most authoritative. However, after compiling volley, I don't have an aal library, whereas that section says I should have.

所以我的问题是:我有一个标准布局的现有 Android Studio 项目和一个 git 存储库;我该怎么做才能添加凌空抽射?我应该在哪里下载它?我应该如何将它添加到 Android Studio?我需要修改哪些 Gradle 文件(如果有).

So my question is this: I have an existing Android Studio project with a standard layout, and a git repository; what should I do to add volley? Where should I download it to? How should I add it to Android Studio? Which Gradle files, if any, do I need to modify.

希望对于那些已经做过几次的人来说,这应该是面包和黄油的东西,但我找不到简单的描述.

Hopefully, for those of you have done this a few times, this should be bread-and-butter stuff, but I haven't been able to find a straightforward description.

--

更新,根据 Scott Barta 的建议.

Updating, per Scott Barta's suggestion.

volley 仓库中的 gradle.build 文件有这一行.

The gradle.build file in the volley repository has this line.

apply plugin: 'android-library'

根据文档:库项目不生成 APK,它们生成一个 .aar 包(代表 Android 存档)."但是,当我构建 volley 项目时,没有创建 .aar.

According to the documentation: "Library projects do not generate an APK, they generate a .aar package (which stands for Android archive)." However, when I build the volley project, no .aar is created.

我的感觉是,由于 Volley 是一个库项目,由 Android 团队创建,因此很可能打算生成并用作 .aar 包.任何关于是否最好生成 .aar 以及如何生成的建议,我们将不胜感激.

My feeling is that as Volley is a library project, created by the Android team, it is most probably intended to be generated and used as .aar package. Any advice on whether it would be preferable to generate a .aar, and how to do that, would be appreciated.

推荐答案

最新更新:

改用jCenter的官方版本

Use the official version from jCenter instead.

dependencies {
    compile 'com.android.volley:volley:1.0.0'
}

以下依赖项指向不再维护的已弃用的 volley.

The dependencies below points to deprecated volley that is no longer maintained.

原答案

你可以在 build.gradle 文件的依赖部分使用它来使用 volley

You can use this in dependency section of your build.gradle file to use volley

  dependencies {
      compile 'com.mcxiaoke.volley:library-aar:1.0.0'
  }

更新:

它不是官方的,而是官方 Volley 的镜像副本.它会定期与官方 Volley Repository 同步和更新,因此您可以毫无顾虑地继续使用它.

Its not official but a mirror copy of official Volley. It is regularly synced and updated with official Volley Repository so you can go ahead to use it without any worry.

https://github.com/mcxiaoke/android-volley

这篇关于将 Volley(或其他库)合并到 Android Studio 项目中的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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