I am new to Android Studio
.Now what i need was just want to add a few jar file in the External Libraries below the < JDK > folder.
我是Android Studio的新手。现在我只需要在< JDK >文件夹下的外部库中添加几个jar文件。
If anyone have idea about this please help me
如果有人知道这件事,请帮助我
187
A late answer, although I thought of giving an in-depth answer to this question. This method is suitable for Android Studio 1.0.0 and above.
虽然我想对这个问题做个深入的回答,但回答得有点晚。此方法适用于Android Studio 1.0.0及以上版本。
STEPS
步骤
Now you can start using the library in your project.
现在可以开始在项目中使用库了。
98
Add your jar file to the folder app/libs
. Then right click the jar file and click "add as library".
将jar文件添加到文件夹应用程序/libs。然后右键单击jar文件,然后单击“添加为库”。
If there is no libs
folder you can create it. Click on the combo box that says "Android", and change it to "Project"
如果没有libs文件夹,您可以创建它。点击标有“Android”的组合框,将其更改为“Project”
From here, you can right click on "apps" in the directory tree and go to "New" => "Directory"
从这里开始,你可以右键点击目录树中的“apps”,进入“New”=>“directory”
36
Put your JAR in app/libs, and in app/build.gradle add in the dependencies
section:
把你的JAR放到app/libs中,在app/build中。附件部分的附加等级:
compile fileTree(dir: 'libs', include: ['*.jar'])
编译fileTree(dir: 'libs',包括:['*.jar'])
18
Create "libs" folder in app directory copy your jar file in libs folder right click on your jar file in Android Studio and Add As library... Then open build.gradle and add this:
在app目录中创建“libs”文件夹,在libs文件夹中复制你的jar文件,在Android Studio中单击你的jar文件,然后添加为库…然后打开构建。gradle并添加:
dependencies {
compile files('libs/your jar file.jar')
}
9
This is how you can add .jar
file in Android Studio 2.1.3.
这就是如何在Android Studio 2.1.3中添加.jar文件的方法。
将. jar文件复制
paste the file in Libs folder and then right click on .jar file and press Add as library
将文件粘贴到Libs文件夹中,然后右键单击.jar文件,然后按下Add作为库。
打开build.gradle
add lines under dependencies as shown in screenshot
在依赖项下添加行,如屏幕截图所示
Now press play button and you are done adding .jar file
现在按play按钮,就完成了添加.jar文件
8
Example with Parse jar...
例子与解析罐子…
Add jars to libs folder from Project view … create lib folder if not exists
从项目视图中添加jar到libs文件夹,如果不存在,创建lib文件夹。
Copy all jars there...
复制所有罐子…
Add libs to gradle.... in build.gradle file :
添加填词gradle ....在构建。gradle文件:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:percent:23.0.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar’)
}
For add all jars of lib folder... change Parse-*.jar to *.jar
用于添加lib文件夹的所有jar…改变解析- *。jar * . jar
2
The GUI based approach would be to add an additional module in your project.
基于GUI的方法是在项目中添加一个额外的模块。
One final piece of advice. Make sure that the JAR file you include is build with at most JDK 1.7. Many problems relating to error message "com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)" root straight to this :0.
最后一条建议。确保包含的JAR文件是在大多数JDK 1.7中构建的。与错误消息有关的许多问题“com.android.dx.cf.iface”。ParseException:错误的类文件魔术(cafebabe)或版本(0034.0000)“根指向这个:0。
2
A simple way to add Jar file Android Studio Steps:
一种简单的添加Jar文件Android Studio步骤的方法:
1
If anyone is looking for another solution without actually copying the jar file(s) into the project directory, e.g. when using a jar in multiple projects:
Open build.gradle and add
如果有人正在寻找另一种解决方案而实际上并没有将jar文件复制到项目目录中,例如在多个项目中使用jar时:Open build。gradle并添加
def myJarFolder = 'C:/Path/To/My/Jars'
[...]
dependencies {
[...]
compile fileTree(dir: myJarFolder + '/jar/Sub/Folder/1', include: ['*.jar'])
compile fileTree(dir: myJarFolder + '/jar/Sub/Folder/2', include: ['*.jar'])
[...]
}
Note that of course you don't have to use the myJarFolder variable, I find it useful though. The path can also be relative, e.g. ../../Path/To/My/Jars.
Tested with AndroidStudio 3.0
请注意,当然不需要使用jarmyfolder变量,但我发现它很有用。路径也可以是相对的,例如.. ../路径/到/我的/ jar。测试与AndroidStudio 3.0
Update: For Gradle Plugin > 3.0 use implementation instead of compile:
更新:对于等级插件> 3.0使用实现而不是编译:
dependencies {
[...]
implementation fileTree(dir: myJarFolder + '/jar/Sub/Folder/1', include: ['*.jar'])
implementation fileTree(dir: myJarFolder + '/jar/Sub/Folder/2', include: ['*.jar'])
[...]
}
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2014/09/04/6be81164851e486bcc1b1ee26bcb346c.html。