android studio怎麽android 导入libraryy

温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
注意:你的library project一定要保证有自己的build.gradle,如果没有,应该用Eclipse导出该工程在Eclipse中选择要导出的项目,然后依次选择菜单 file-&export-&Android-&Generate Gradle build&files. 之后依次点击next到finish即可&回到Android studio打开settings.gradle,添加include ':libraries:你的库工程名称'&ctrl+alt+shift+s 打开 project structure 在左侧面板选中module,在中间面板选中module名,再在右边面板选中denpendecies在面板的最右边出现一个加号,点击+号,选择第三项module&denpendecy&&此时弹出一个对话框,显示你的library project ,选中它,点击OK,最后在&project structure面板依次点击Apply,OK&完成以上步骤,有可能会遇到如下问题:1 报错:类似于:&那是因为你的library project的build.gradle里的配置的SDK版本与你现有工程的build.gradle所配置的SDK版本不一致,修改library project的build.gradle里的SDK版本,使它与现有工程一致就可以解决例如library project的build.gradle&原有工程的build.gradle&把library project的build.gradle对应的字段值参照原有工程来修改,修改完毕后,rebuild一下工程2 在rebuild工程后仍报错&此时依次打开File--Invalidate Caches/Restart,弹出对话框&点击第一项Invalidate and Restart,待Android studio重启即可解决问题,然后你就可以用上你的library project了
阅读(23578)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'关于Android Studio如何导入library project',
blogAbstract:'在项目根目录下建立一个libraries文件夹,移动你要使用的library project到libraries目录(为什么是移动?本人试过复制到工程,但复制过来的库工程里面的src目录下的代码会丢失)',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:8,
publishTime:3,
permalink:'blog/static/',
commentCount:2,
mainCommentCount:1,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'0',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}android studio怎么引用library项目
该用户从未签到主题帖子e币
将jar文件放在libs引用包里,项目会自动引用
看清楚问题好吗,是添加library,不是jar
该用户从未签到主题帖子e币
没用过android studio,用的是idea,应该是一样的
在idea中所有工程都是以module存在的,在你主工程module的依赖里添加要使用的module就ok了
我在Project Structure的Modules选项中,只有添加新的Module选项,没有导入选项&
该用户从未签到主题帖子e币
没用过android studio,用的是idea,应该是一样的
在idea中所有工程都是以module存在的,在你主工程module ...
我在Project Structure的Modules选项中,只有添加新的Module选项,没有导入选项
该用户从未签到主题帖子e币
没有import?
本帖子中包含更多资源
才可以下载或查看,没有帐号?
表示真的是木有import,只有new&
签到天数: 8 天连续签到: 1 天[LV.3]偶尔看看II主题帖子e币
木用这个哦
签到天数: 8 天连续签到: 1 天[LV.3]偶尔看看II主题帖子e币
这个比较好用
该用户从未签到主题帖子e币
没有import?
表示真的是木有import,只有new
该用户从未签到主题帖子e币
File -& Project Structure -& Modules -& 你的主工程 -& Dependencies
表示,我的没有这个选项啊
那就可能在下面有个+号&
没有哪个选项?&
该用户从未签到主题帖子e币
表示,我的没有这个选项啊
没有哪个选项?
[attachimg]118888[/attachimg]
我找到了你说的选项了,但是点击了之后,里面什么东西都没有。
能加个QQ交流一下么&
[attachimg]118887[/attachimg]
我的这个项目的Project Structure比你的少了好多东西的样子啊&
该用户从未签到主题帖子e币
没有哪个选项?
我的这个项目的Project Structure比你的少了好多东西的样子啊
本帖子中包含更多资源
才可以下载或查看,没有帐号?
该用户从未签到主题帖子e币
没有哪个选项?
我找到了你说的选项了,但是点击了之后,里面什么东西都没有。
能加个QQ交流一下么
本帖子中包含更多资源
才可以下载或查看,没有帐号?
那是因为你里面没有library module吧&
该用户从未签到主题帖子e币
我找到了你说的选项了,但是点击了之后,里面什么东西都没有。
能加个QQ交流一下么
那是因为你里面没有library module吧
大神,貌似你用的好像是idea,我用的是as。&
该用户从未签到主题帖子e币
那是因为你里面没有library module吧
大神,貌似你用的好像是idea,我用的是as。
看左上角的图标,就知道是铁铁的android studio啊&
该用户从未签到主题帖子e币
大神,貌似你用的好像是idea,我用的是as。
看左上角的图标,就知道是铁铁的android studio啊
签到天数: 180 天连续签到: 1 天[LV.7]常住居民III主题帖子e币
现在直接把eclipse导入,IDE它自己就搞得定了 我的版本是0.5.8
QQ已认证,此人靠谱
推荐阅读热门话题
61886420384328283281261252226218208204201192715
16&分钟前1&小时前2&小时前2&小时前2&小时前2&小时前昨天&23:58昨天&17:01昨天&16:55昨天&15:47昨天&15:44昨天&15:40昨天&14:32昨天&14:03昨天&11:59昨天&10:35
Powered by
扫一扫 关注eoe官方微信choose your .jar file --> than import as a .jar --
Then CTRL+ALT+SHIFT+S --> project sturure -->choose the module you want ato add a jar -->Dependencendies --> Module Dependency. build.gradle of the module will updated automatically.
Ive done above 3 steps and its work charm for me.
(I am using Android Studio 2.1.2)
Add your jar package name (as an example compile 'com.squareup.okhttp3:okhttp:3.3.1') into gradle build script under build.gradle(Module:app).
Right click on app folder -> New -> Module
Step 3: Click Import JAR/.AAR Package Then browse your package. as an example:
2,72022960
menu File -& project struct -& module select "app" -& dependencies tab -& + button
-& File dependency -& PATH/myfile.jar
3,06512030
Just put the .jar files in libs folder of the Android project.
compile fileTree(dir: 'libs', include: ['*.jar'])
this line of code in the apps graddle file will do the rest.
Happy Coding :)
2,19111834
Create a folder libs. Add your .jar file. Right click on it and you will find add jar as dependency. Click on it. Its all you need to do.
You can find the dependencies added to your build.gradle file.
1) create an 'your_libs' folder inside the Project/app/src folder.
2) Copy your jar file into this 'your_libs' folder
3) In Android Studio, go to File -> Project Structure -> Dependencies -> Add -> File Dependency and navigate to your jar file, which should be under 'src/your_libs'
3) Select your jar file and click 'Ok'
and then you can see on your build.gradle like this :
files('src/your_libs/your.jar')
In android Studio 1.1.0 .
I solved this question by following steps:
1: Put jar file into libs directory. (in Finder)
2: Open module settings , go to Dependencies ,at left-bottom corner there is a plus button. Click plus button then choose "File Dependency" .Here you can see you jar file. Select it and it's resolved.
Step 1 : Now under your app folder you should see libs, if you don't see it, then create it .
Step 2 : Drag & Drop the .jar file here, you may be get a prompt "This file does not belong to the project", just click OK Button .
Step 3 : Now you should see the jar file under libs folder, right click on the jar file and select "Add as library", Click OK for prompt "Create Library"
Step 4 : Now this jar has been added.
30.5k97082
On Mac OS X:
Add jar as library (drag jar to libs, right click add as lib)
Add compile statement to build.grade
Install gradle v1.6 (use homebrew)
brew install gradle
if not v1.6, upgrade homebrew
gradle clean (rebuild android did not work)
This sorted me out.
Like many before pointed out you shall add
compile files('libs/gson-2.2.3.jar')
to your build.gradle file.
However I have a project in Android Studio that was migrated from Eclipse and in this case the "libs" folder is named "lib" so for me removing the "s" solved the problem.
compile fileTree(dir: 'libs', include: '*.jar') works fine but not compile files(...) have tested with Studio Beta 0.8.1
My answer is basically gathering some of the right but incomplete answers provided above.
Open build.gradle
Add the following:
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.3'
This will allow support for two different ways of adding dependencies. The compile fileTree(dir: 'libs', include: ['*.jar']) (as @Binod mentioned) tells the compiler to look under the folder libs for ANY jar. It is a good practice to create such a folder 'libs' which will contain the jar packages that our application needs to use.
But this will also allow support for Maven dependency. The compile 'com.google.code.gson:gson:2.3' (as mentioned by @saneryee) it is another recommended way to add dependencies that are in a central remote repository and not in our /libs "local repository". It is basically telling gradle to look for that version of that package and it's telling the compiler to consider it when compiling the project (having it in the classpath)
PS: I use both
2,60121747
For newer Android 1.0.2 the following is already there in your build.gradle file
compile fileTree(include: ['*.jar'], dir: 'libs')
Add the library jar to your libs folder -> right click the library -> click add as a library -> it asks you for the project to add it for -> select your project-> click ok
The following line is automatically added to build.gradle
compile files('libs/android-query.jar')
That did it for me. nothing more was required. i have shown this for android aquery another third party library for android.
Added the "libs" folder at the level of "app".
Added all the "jars" in this project.
Next, selected all the jars, in the "libs" folder,
right click on the selected items, and say "add library"
then you will find the jars expansion option, within the project explorer itself.
I observed "CTRL+ALT+SHIFT+S --> project structure --> app-module -->Dependencies" already had an entry as "(dir: 'libs', include: '*.jar')" under "compile-option", initially. And after adding the jar's as per the steps stated above, the "build.gradle" got the entries for the new added jar's, itself.
In Android Studio 2.1 I follow the this way,
Goto app -> src-> main -> assets folder (If not available create it) -> put your JAR files
In your build.gradle add dependency like this,
compile files('src/main/assets/jsoup.jar')
compile files('src/main/assets/org-apache-xmlrpc.jar')
compile files('src/main/assets/mons.httpclient.jar')
compile files('src/main/assets/ws-commons-util-1.0.2.jar')
Now your JAR files ready to use.
5,05053465
Create libs folder under the application folder.
Add .jar files to libs folder.
Then add .jar files to app's build.gradle dependency.
Finally Sync project with Gradle files.
protected by ♦
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10
on this site (the ).
Would you like to answer one of these
Not the answer you're looking for?
Browse other questions tagged
The week's top questions and answers
Important community announcements
Questions that need answers
By subscribing, you agree to the
Stack Overflow works best with JavaScript enabledAndroidStudio项目导入第三方library_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
AndroidStudio项目导入第三方library
上传于|0|0|暂无简介
阅读已结束,如果下载本文需要使用1下载券
想免费下载本文?
定制HR最喜欢的简历
下载文档到电脑,查找使用更方便
还剩3页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢

我要回帖

更多关于 androidstudio导入sdk 的文章

 

随机推荐