Import Android volley to Android Studio

前端 未结 17 2156
孤街浪徒
孤街浪徒 2020-12-07 11:33

I wanna use the google\'s volley library

I am using Android Studio and I know how to add .jar libraries.

But I could not create a .jar library with the voll

相关标签:
17条回答
  • 2020-12-07 12:00

    So Volley has been updated to Android studio build style which makes it harder create a jar. But the recommended way for eclipse was using it as a library project and this goes for android studio as well, but when working in android studio we call this a module. So here is a guide to how do it the way Google wants us to do it. Guide is based on this nice tutorial.

    1. First get latest volley with git (git clone https://android.googlesource.com/platform/frameworks/volley).

    2. In your current project (android studio) click [File] --> [New] -->[Import Module].

    3. Now select the directory where you downloaded Volley to.

    4. Now Android studio might guide you to do the rest but continue guide to verify that everything works correct

    5. Open settings.gradle (find in root) and add (or verify this is included):

      include ':app', ':volley'

    6. Now go to your build.gradle in your project and add the dependency:

      compile project(":volley")

    Thats all there is to it, much simpler and easier than compiling a jar and safer than relying on third parties jars or maven uploads.

    0 讨论(0)
  • 2020-12-07 12:00

    step 1:- Download volley.jar file.

    step 2:- Go to your project and set the display menu from Android to Project then go to

    app -> libs-> paste your volley.jar file here

    step 3:- Right click on the volley.jar file and click on "add as library". and its all done.

    0 讨论(0)
  • 2020-12-07 12:04

    two things

    one: compile is out of date rather it is better to use implementation,

    and two: volley 1.0.0 is out of date and syncing project will no work

    alternatively in build.gradle add implementation 'com.android.volley:volley:1.1.1' or implementation 'com.android.volley:volley:1.1.+' for 1.1.0 and newer versions.

    0 讨论(0)
  • 2020-12-07 12:10

    Add this dependency in your gradle.build(Module:app)file

    compile 'com.android.volley:volley:1.0.0'
    

    And then sync your gradle file.

    0 讨论(0)
  • 2020-12-07 12:10

    it also available on repository mavenCentral() ...

    dependencies {
        // https://mvnrepository.com/artifact/com.android.volley/volley
        api "com.android.volley:volley:1.1.0'
    }
    
    0 讨论(0)
  • 2020-12-07 12:12

    Most of these answers are out of date.

    Google now has an easy way to import it.. We will continue to see a lot of outdated information as they did not create this solution for a good 2-3 years.

    https://bintray.com/android/android-utils/com.android.volley.volley/view

    All you need to do is add to your Build.Gradle the following:

    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'
    }
    
    0 讨论(0)
提交回复
热议问题