Android的工作室:如何添加和使用项目作为库,而不是作为模块 [英] Android Studio: how to add and use project as library, not as module

查看:141
本文介绍了Android的工作室:如何添加和使用项目作为库,而不是作为模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个库:


  1. 奇尔卡特-9.5.0-Android的所有

  2. 简单文件选择主

我抄俱进libs文件夹,并用它作为库。当我尝试将这些库导入到我的java类我得到了他们的名字的红色标记。这意味着机器人工作室找不到thees库。
无论如何,我不得不为项目添加文件选择我的主要应用程序。但是,当我'跑'我的应用程序首先我得编译文件选择不是我的主要应用程序。

I have copied both into libs folder and used it as libs. When I try to import these libs into my java class I got red markup on their names. It means that android studio can't find thees libs. Anyway i had add file chooser as project to my main application. But when I 'Run' my app firstly I've got compiled file chooser not my main app.

所以我的主要问题是如何添加.zip或.jar文件图书馆没有项目或模块。

So my main question is how to add .zip or .jar files as LIBRARIES not as project or module.

我将分享这些库的下载链接:

I will share these libraries download links:


  1. https://www.chilkatsoft.com/chilkatAndroid.asp

https://github.com/ingyesid/simple-file-chooser

我知道,这不是编程问题,但对于许多谁开始蚀之后使用Android工作室的人还是有用的。

I know that this is not programming question but still useful for many people who started to use android studio after eclipse.

推荐答案

今天我实现一个.jar库在我的项目,做了以下内容:

I implemented a .jar library today in my project and did the following:


  1. .jar文件添加到项目的libs文件夹

  1. add the .jar file to the libs folder of your project

在的build.gradle文件中加入:编译文件树(导演:'库',包括:['的* .jar'])来的依赖关系。

in the build.gradle file add: compile fileTree(dir: 'libs', include: ['*.jar']) to the dependencies.

生成项目

现在尝试导入在你的类的对象:)

now try to import the objects in your class :)

是这样的:
    依赖{
        编译文件树(导演:'库',包括:['的* .jar'])
    }

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

另一件事是:在Android的Studio中的.jar单击鼠标右键,选择制作模块。 - 并重新建立。

other thing you can try is: right mouse click on your .jar in Android Studio and select "make module". - and build again.

这篇关于Android的工作室:如何添加和使用项目作为库,而不是作为模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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