添加外部.jar到androidstudio项目 [英] Adding external .jar to androidstudio project
问题描述
我已经通过进入项目结构增加了外部库
然后添加.jar文件。 BSH-2.0b4.jar
在Android的工作室的Android项目 - &GT ;模块 - > myProject的 - >制表依赖 - > +星座
我也试着将文件复制到/ libs目录,然后在演播室单击鼠标右键和添加为库...
(两种方法独立!!)。我插入下面的code作为测试
I've added the external library bsh-2.0b4.jar
to an android project in android-studio by going into Project structure -> Modules -> myProject -> Tab-Dependencies -> + Sign
and then add the .jar file.
I also tried to copy the file into the /libs directory and then rightclick in studio and add as library...
(both methods independently!!). I inserted the following code as a test
import bsh.Interpreter;
...
Interpreter interpreter = new Interpreter();
interpreter.eval("result = (7+21*6)/(32-27)");
return interpreter.get("result").toString();
我编译android系统的buildin的按钮。
该的build.gradle如下:
I compile with the buildin button in android. The build.gradle looks like:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 17
}
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
}
但是,当我编译的一切,我收到错误
But when I compile everything I receive the error
Gradle: error: package bsh does not exist
Gradle: error: cannot find symbol class Interpreter
谁能帮我请?
推荐答案
更改您的依赖一样,
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile 'org.beanshell:bsh:2.0b4'
}
您现在可以手动删除下载的依赖关系库
目录。
You can now remove manually downloaded dependencies in libs
directory.
你所做的是添加库仅适用于Android Studio项目。你应该总是将它们添加到摇篮构建文件,因为只有这是由Android生成工具PTED间$ P $。
What you did was adding libraries to Android Studio project only. You should always add them to Gradle build files as only this is interpreted by Android Build Tools.
有也是构建工具18.0.1新版本,您可以安装它们,并在您更改版本的build.gradle
。据我所知,他们可以处理 AAR
依赖更好的。
There is also new version of build tools 18.0.1, you can install them and change version in you build.gradle
. As far as I know they can handle aar
dependencies better.
这篇关于添加外部.jar到androidstudio项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!