nsv*_*vir 80 android android-library android-studio android-volley
我想使用谷歌的凌空图书馆
我正在使用Android Studio,我知道如何添加.jar库.
但我无法使用volley文件创建.jar库:
在这里我做了什么:(使用Windows 7)
git clone https://android.googlesource.com/platform/frameworks/volley
cd volley
android.bat update project -p . --target android-19
ant.jar jar
Run Code Online (Sandbox Code Playgroud)
我得到了输出:
发生了一个java异常.
怎么了?我怎样才能添加一个非.jar库?
sha*_*vik 166
Volley现已在JCenter正式上市:
将此行添加到Android项目的app模块的gradle依赖项中:
implementation 'com.android.volley:volley:1.1.1'
War*_*zit 52
所以Volley已经更新为Android studio构建风格,这使得创建jar变得更加困难.但是eclipse的推荐方法是将它用作图书馆项目,这也适用于Android工作室,但是当在android studio中工作时,我们称之为模块.所以这里有一个指南,告诉我们谷歌希望我们这样做的方式.指南基于这个很好的教程.
[File]- > [New]- > [Import Module].打开settings.gradle(在root中查找)并添加(或验证它包括在内):
include ':app', ':volley'
现在转到项目中的build.gradle并添加依赖项:
compile project(":volley")
这就是它的全部内容,比编译jar更简单,更容易,比依赖第三方罐子或maven上传更安全.
Al *_*ath 19
更新Warpzit对Android Studio 1.3.2的回答(粗体差异)
(更新:对于Android 2.0来说似乎相同)
打开settings.gradle(在root中查找)并添加(或验证它包括在内):
包括':app',':volley'
现在转到项目中的build.gradle并添加依赖项:
编译项目(":volley")
wil*_*ing 18
太复杂的家伙.只需将它包含在您的gradle依赖项中:
dependencies {
...
compile 'com.mcxiaoke.volley:library:1.0.17'
}
Run Code Online (Sandbox Code Playgroud)
Sta*_*nd0 10
大多数答案都已过时.
谷歌现在有一个简单的方法来导入它..我们将继续看到很多过时的信息,因为他们没有创建这个解决方案好2 - 3年.
https://bintray.com/android/android-utils/com.android.volley.volley/view
您需要做的就是添加以下内容:Build.Gradle:
compile 'com.android.volley:volley:1.0.0'
IE
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.example.foobar.ebay"
minSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.volley:volley:1.0.0'
testCompile 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
187151 次 |
| 最近记录: |