2

enter image description here

As you can see from the image, Android studio is not able to resolve this import "com.android" in this line.

import com.android.volley.toolbox.Volley

I tried the following truobleshooting found from some other answers:

  1. Clean and rebuild
  2. File -> invalidate caches and restart
  3. Opening the project by build.gradle
  4. Deleting the .idea folder in the project
  5. Installing old sdk (Android 6.0) along with latest

But none seem to be helping. Help please.

build.gradle (module) file : https://textsaver.flap.tv/lists/326r

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "..."
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

}
2
  • Add module level build.gradle file Commented Dec 26, 2019 at 16:37
  • Added the module build.gradle file. Commented Dec 26, 2019 at 16:46

4 Answers 4

2

As I thought you forgot to add dependency in your gradle file. Add dependency to module level build.gradle file

dependencies {
    ...
    implementation 'com.android.volley:volley:1.1.1'
}
Sign up to request clarification or add additional context in comments.

Comments

1

Try to delete the build folder then resynchronize. Sometimes even using ./gradlew clean command, the generated file not deleted correctly

4 Comments

Tried both. Still the same
Is it just happen to volley lib ? if true then did you already add the volley lib to your Gradle ?
as i see on your gradle file, you have not add the volley lib.
Good, glad to help you
0

It sounds stupid, but in my case, I had build.gradle and build.gradle.kts files at the same time in the :app module folder.

After deleting build.grale file it worked correctly.

Comments

0

Sometimes for any reason, the following line appears among the imports

import android.R

This caused (at least in my case) the error Unresolved reference: android.

After removing this line, the error disappears.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.