如何导入第三方库 [英] How to import 3rd party libraries

查看:218
本文介绍了如何导入第三方库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一些很酷的Andr​​oid库中的一天,并决定尝试一下。但我无法正确导入库。

I found some cool android libraries the other day and decided to try some. But I'm having trouble correctly importing the library.

这是图书馆的网址: https://github.com/dmytrodanylyk/android-流程按钮

我第一次尝试导入库偏食(在java目录中的文件移动到src目录,并设置项目作为库),并导入样本Eclipse和设置使用的库项目(属性 - > Android->库)。但它没有工作。布局文件说,它未能实例[自定义Widget类。

I first tried importing the library to eclipse (and move the files in java directory to src directory and set the project as library) and importing the sample to eclipse and set it to use the library project (Properties->Android->Libraries). But it didn't work. The layout files said it failed to instantiate [custom widget class].

在我尝试导入.jar文件到libs目录(和更新Java构建路径),但它也不能工作。这表明在java错误的文件了。

The I tried importing the .jar file to libs directory (and update the java build path) but it didn't work either. It showed errors in the java files too.

然后我尝试了所有的Java和布局文件复制到示例项目目录和它的工作。但我猜这不是与第三方库的工作方式。

I then tried copying all the java and layout files to the sample project directory and it worked. But I'm guessing that's not the way to work with 3rd party libraries.

我首先想到它的一些错误的库,但所有其他库我试图导入到我的项目面临着同样的问题。

I first thought it's some error with the library but all the other libraries I tried to import to my projects faced the same problem.

有人能引导我如何正确导入第三方库到我的Andr​​oid项目?

Can someone walk me through how to correctly import a 3rd party library to my android project?

推荐答案

你能做的最好的选择是使用作为的gradle你的依赖经理。

The best option you can do is to use gradle as your dependency manager.

您已经张贴在使用摇篮库,所以你可以链接到该库是这样的:

The library you have posted is using Gradle so you can link to this library in this way:

dependencies {
  compile 'com.github.dmytrodanylyk.android-process-button:library:0.0.7'
}

瞧!你有你的库准备好您的应用程序使用:D

And voilá! You have your library ready to use in your app :D

我会告诉你一些有用的链接上使用的摇篮正确:

I'll let you a couple of useful links to use Gradle properly:


  • 马克Allison的关于摇篮教程该会解释一步一步的摇篮是如何工作的(记住正在使用Android的摇篮插件过时的版本,你要适应的版本到当前是 0.10

  • 约摇篮的官方开发者文档在这里你可以找到另一个步骤教程一步配置和使用摇篮(这是更多的更新)。

  • Mark Allison's tutorial about Gradle It will explain step by step how Gradle works (keep in mind that is using an outdated version of Android Gradle plugin, you have to adapt the version to the current one which is 0.10)
  • Official Developer Docs about Gradle In here you can find another step by step tutorial to configure and use Gradle (this one is more updated).

您可以直接在Android的工作室(的IntelliJ)使用摇篮,如果你不介意改变你的主编辑器。

You can use Gradle directly in Android Studio (Intellij) if you don't mind to change your main editor.

如果你想留下来与Eclipse,然后<一个href=\"http://stackoverflow.com/questions/19912393/is-there-any-way-to-integrate-eclipse-with-gradle-in-android-project\">this计算器的链接可能会有所帮助!

If you want to stick around with Eclipse then this stackoverflow link may be helpful!

编辑:

哦!如果你想搜索已经Gradlized库可以导航到摇篮请的!

Oh! And if you want to search already Gradlized libraries you can navigate to Gradle Please!

这篇关于如何导入第三方库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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