将Android排球导入Android Studio

nsv*_*vir 80 android android-library android-studio android-volley

我想使用谷歌的凌空图书馆

我正在使用Android Studio,我知道如何添加.jar库.

但我无法使用volley文件创建.jar库:

https://android.googlesource.com/platform/frameworks/volley

在这里我做了什么:(使用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'

  • 我有一个像@SundeepBadhotiya这样的类似问题它是通过将所提到的编译语句放入Module的build.gradle而不是Project的gradle文件来解决的. (3认同)
  • @Shavik Gradle 在将其添加到 build.gradle 文件时不同步,我收到如下错误:无法解析:com.android.volley:volley:1.0.0 (2认同)

War*_*zit 52

所以Volley已经更新为Android studio构建风格,这使得创建jar变得更加困难.但是eclipse的推荐方法是将它用作图书馆项目,这也适用于Android工作室,但是当在android studio中工作时,我们称之为模块.所以这里有一个指南,告诉我们谷歌希望我们这样做的方式.指南基于这个很好的教程.

  1. 首先用git获取最新的排球(git clone https://android.googlesource.com/platform/frameworks/volley).
  2. 在您当前的项目(android studio)中单击[File]- > [New]- > [Import Module].
  3. 现在选择您下载Volley的目录.
  4. 现在Android工作室可能会指导您完成剩下的工作,但继续指导以验证一切正常
  5. 打开settings.gradle(在root中查找)并添加(或验证它包括在内):

    include ':app', ':volley'

  6. 现在转到项目中的build.gradle并添加依赖项:

    compile project(":volley")

这就是它的全部内容,比编译jar更简单,更容易,比依赖第三方罐子或maven上传更安全.


Al *_*ath 19

更新Warpzit对Android Studio 1.3.2的回答(粗体差异)
(更新:对于Android 2.0来说似乎相同)

  1. 首先用git获得最新的截击.
  2. 在您当前的项目(android studio)中,单击[ 文件] - > [新建] - > [新模块].
  3. 现在选择[Import Gradle Project],单击Next
  4. 现在选择您下载Volley的目录.
  5. 现在Android工作室可能会指导您完成剩下的工作,但继续指导以验证一切正常
  6. 打开settings.gradle(在root中查找)并添加(或验证它包括在内):

    包括':app',':volley'

  7. 现在转到项目中的build.gradle并添加依赖项:

    编译项目(":volley")


wil*_*ing 18

太复杂的家伙.只需将它包含在您的gradle依赖项中:

dependencies {
    ...
    compile 'com.mcxiaoke.volley:library:1.0.17'
}
Run Code Online (Sandbox Code Playgroud)

  • 值得指出的是,这不是官方存储库.因此,始终存在恶意代码可能包含在其中的可能性.可能不会发生,对吧?但最好知道它可以. (17认同)
  • 已弃用请注意,此项目已弃用且不再维护,请使用jCenter的官方版本.编译'com.android.volley:volley:1.0.0' (5认同)

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 次

最近记录:

6 年,10 月 前