我在Android Studio中使用gradle进行android项目。我有一个下载的jar,名为TestFlightAppLib.jar
。这个jar在Maven仓库中不存在,所以我不能仅仅把它放在我的build.gradle
。
如何将此JAR文件添加到我的项目中?我看不到任何将外部jar添加到项目的选项。
更新资料
这是我完整的build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 18
}
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:18.0.+'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.squareup.retrofit:retrofit:1.2.2'
compile 'com.github.rtyley:roboguice-sherlock:1.5'
compile 'org.roboguice:roboguice:2.0'
compile files('libs/TestFlightLib.jar')
}
这是错误消息:
Gradle: Execution failed for task ':MyProject:compileDebug'.
> Compilation failed; see the compiler error output for details.
/Users/droid/android/MyProjectProject/MyProject/src/main/java/com/mypkg/ui/activity/MainApplication.java
Gradle: error: package com.testflightapp.lib does not exist
这是课程:
import com.testflightapp.lib.TestFlight;
public class MainApplication {
}
只需添加
compile fileTree(dir: 'libs', include: '*.jar')
到您dependencies
的build.gradle
文件夹中,那么libs文件夹中的所有jar都将包括在内。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句