Siavash Siavash - 4 months ago 37
Android Question

error: package com.android.volley does not exist

I am trying to add Volley to my android project in Android Studio.
I downloaded Volley from git, and added it as a module using the Project Structure tool, as an android library. I fixed the errors regarding the build version an was able to compile with the new module added to my project. I started writing code and the Volley stuff even shows up in my auto complete and the packages were automatically added to my source file.

But when I compile, i get

error: package com.android.volley does not exist


Does anyone know what my problem is?

here is my project structure:
enter image description here

here is my apps build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 20
buildToolsVersion "20.0.0"

defaultConfig {
applicationId "com.loop"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v13:20.0.0'
compile 'com.google.android.gms:play-services:4.4.+'
}


and settings.gradle:

include ':app', ':volley'

Answer

I had to add compile project(':volley') to my dependencies under build.gradle

so final code is

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v13:20.0.0'
    compile 'com.google.android.gms:play-services:4.4.+'
    compile project(':volley')
}