- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经下载了库,它是一个包含多个文件的文件夹: https://github.com/EasyPost/easypost-java/archive/master.zip
我已经添加了我自己的名为 myLibs 的文件夹,并将解压缩的项目文件夹添加到其中(名为 easypost-java-master 的文件夹)。
我的 settings.gradle 如下所示:
include ':app'
include ':myLibs:easypost-java-master'
我的 build.gradle 如下所示:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile files('libs/gson-2.2.4.jar', 'libs/gson-2.2.4-javadoc.jar', 'libs/gson-2.2.4-javadoc.jar')
compile fileTree(dir: 'myLibs', include: ['easypost-java-master'])
}
我没有收到任何错误并且能够同步。但是当我尝试导入例如 import com.easypost.EasyPost;
在我的 MainActivity 时,我得到了错误
无法解析 easypost
我错过了一步吗?
最佳答案
Am I missing a step?
是的,大的。在 EasyPost 库 GitHub 配置文件中,有安装说明。你注意到了吗:
Installation
mvn package
or build the jar from src!
要做到这一点,只需按照以下步骤操作:
In the latest build of Android Studio 1.2, the creation of JAR library has been made as simple as point and click.
Steps to follow :
- Goto File -> New -> New Module
- Select "Java Library" at the end of the options list
- Enter the name of the jar lib and name of class in it and hit finish button
- Thats it !
The next step is adding your Jar Library as dependency in your app. Simple as that just
- Goto File -> Project Structure -> Select 'app' -> Select 'Dependency'
- Select the '+' at the bottom -> Select 'Module Dependency'
- Select your jar lib module you just created above
- Select Ok and thats it!
....Or you could just add the below line to your App gradle file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) // Default Gradle Task, should be already present
compile 'com.android.support:appcompat-v7:21.0.3' // Default Gradle Task, should be already present
compile project(':nameOfYourJarLibraryModule') // This is your jar library module
}Google is promoting the Android Archive(AAR), even though JAR supported is brought back to android studio.To find out the difference between AAR and JAR refer this link
希望对你有帮助
关于java - 如何将 EasyPost 库添加到 Android Studio 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34519448/
我是一名优秀的程序员,十分优秀!