未解决的参考:android

时间:2019-12-26 16:17:17

标签: android android-studio kotlin

enter image description here

从图片中可以看到,Android Studio无法在此行中解析此导入“ com.android”。

import com.android.volley.toolbox.Volley

我尝试了以下从其他答案中找到的问题:

  1. 清洁并重建
  2. 文件->使缓存无效并重新启动
  3. 通过build.gradle打开项目
  4. 删除项目中的.idea文件夹
  5. 安装旧的sdk(Android 6.0)和最新的

但是似乎没有任何帮助。请帮助。

build.gradle(模块)文件: 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'

}

3 个答案:

答案 0 :(得分:2)

我以为您忘记了在gradle文件中添加依赖项。将依赖项添加到模块级别的build.gradle文件

dependencies {
    ...
    implementation 'com.android.volley:volley:1.1.1'
}

答案 1 :(得分:0)

尝试删除构建文件夹,然后重新同步。有时即使使用.childChanged命令,生成的文件也无法正确删除

答案 2 :(得分:0)

这听起来很愚蠢,但就我而言,我同时在const emoji = message.guild.emojis.cache.array(); message.channel.send(emoji); 模块文件夹中拥有build.gradlebuild.gradle.kts文件。

删除:app文件后,它可以正常工作。