将 jar 库导入 android-studio [英] importing jar libraries into android-studio
问题描述
android-studio 0.2.7
Fedora 18
你好
我正在尝试将 jtwitter jar 添加到我的项目中.
I am trying to add the jtwitter jar to my project.
首先我尝试执行以下操作:
First I tried doing the following:
1) Drag the jtwitter.jar into the root directory of my project explorer, see picture
2) File | project structure
3) Modules | yamba-yamba | dependencies
4) Click the plus sign | jars or directories | and navigate to jtwitter jar | click ok
导入 jar 文件时出现以下错误:
When I import the jar file I get the following error:
import winterwell.jtwitter.Twitter;
Cannot resolve symbol winterwell
Gradle: error: package winterwell.jtwitter does not exist
我研究发现android-studio有一些问题,你必须自己编辑build.gradle
文件.
I researched and found that android-studio has some issues and that you have to edit the build.gradle
file yourself.
所以我尝试将其添加到我的 build.gradle 文件中:
So I tried adding this to my build.gradle file:
dependencies {
compile files('libs/jtwitter.jar')
并收到错误消息:cannot resolve symbol dependencies
另一个问题,libs 文件夹在哪里.是指外部库
吗?
Another question, where would the libs folder be. Does it mean the External Libraries
?
推荐答案
更新了 Android Studio 2 的答案
将 jar/aar 导入项目的简单且正确的方法是将其作为模块导入.
Updated answer for Android Studio 2
The easy and correct way to import a jar/aar into your project is to import it as a module.
模块">
这篇关于将 jar 库导入 android-studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!