You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio中Settings Gradle报错:Cannot resolve symbol 'File'

环境配置
  • Android Studio IDE
  • SDK版本:32
  • Build Tools版本:33
  • Java版本:1.8

输入图片描述

问题描述

Cannot resolve symbol 'File'

Gradle已同步成功,文件也已创建,但该报错持续存在。


Settings Gradle内容

pluginManagement {
repositories {
    gradlePluginPortal()
    google()
    mavenCentral()
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
    google()
    mavenCentral()

    maven {
        url "https://dl.cloudsmith.io/public/cometchat/cometchat-pro-android/maven/"
    }
}
}
rootProject.name = "ViegerT2"
include ':app'
include ':uikit'
project(':uikit').projectDir = new File(rootDir, 'android-java-chat-ui-kit/uikit/')

Project Gradle内容

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}

task clean(type: Delete) {
delete rootProject.buildDir
}

APP Gradle内容

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}

android {
compileSdk 32

defaultConfig {
    applicationId "com.example.viegert2"
    minSdk 21
    targetSdk 32
    versionCode 1
    versionName "1.0"
    manifestPlaceholders = [file_provider: "ViagerT2"]

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = '1.8'
}
buildFeatures {
    viewBinding true
}
packagingOptions {
    exclude 'META-INF/proguard/androidx-annotations.pro'
    exclude 'META-INF/androidx.cardview_cardview.version'

}
buildToolsVersion '33.0.0'

}

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.annotation:annotation:1.4.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
//noinspection GradleCompatible
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
apply plugin: 'kotlin-android-extensions'



//implementation 'androidx.core:core-ktx:1.3.2'
//implementation 'androidx.appcompat:appcompat:1.3.1'
//implementation 'com.google.android.material:material:1.4.0'
//implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation platform('com.google.firebase:firebase-bom:29.0.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-database-ktx'
implementation 'com.google.firebase:firebase-storage-ktx'
implementation 'com.cometchat:pro-android-chat-sdk:3.0.0'
implementation 'com.cometchat:pro-android-calls-sdk:2.1.0'
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation 'com.github.bumptech.glide:glide:4.12.0'
//implementation project(path: ':uikit-kotlin')
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'





implementation project(path: ':uikit')
 }  

Module(uikit)Gradle内容

apply plugin: 'com.android.library'
android {
compileSdkVersion 30

defaultConfig {
    minSdkVersion 21
    targetSdkVersion 30
    versionCode 1
    versionName "3.0.9-1"
    multiDexEnabled true
    vectorDrawables.useSupportLibrary = true
    renderscriptSupportModeEnabled true
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    consumerProguardFiles 'consumer-rules.pro'

    ndk {
        abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}

sourceSets {
    main {
        manifest.srcFile 'src/main/AndroidManifest.xml'
        java.srcDirs = ['src/main/java', '.apt_generated']
        aidl.srcDirs = ['src/main/aidl', '.apt_generated']
        res.srcDirs = [
                'src/main/res',
                'src/main/res-components',
                'src/main/res-components/calls',
                'src/main/res-components/chats',
                'src/main/res-components/cometchatui',
                'src/main/res-components/groups',
                'src/main/res-components/messagebubbles',
                'src/main/res-components/messages',
                'src/main/res-components/others',
                'src/main/res-components/shared',
                'src/main/res-components/userprofile',
                'src/main/res-components/users'
                ]
    }
}

dataBinding {
    enabled = true
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

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

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.preference:preference:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

//RecyclerView
implementation 'androidx.recyclerview:recyclerview:1.0.0'

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

implementation 'androidx.emoji:emoji:1.1.0-rc01'
implementation 'androidx.emoji:emoji-bundled:1.1.0'

implementation 'androidx.emoji:emoji-appcompat:1.0.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'

implementation 'com.google.android.material:material:1.2.0-alpha04'

implementation 'com.facebook.shimmer:shimmer:0.4.0'

implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
//cometchat
compileOnly 'com.cometchat:pro-android-chat-sdk:3.0.9'
compileOnly 'com.cometchat:pro-android-calls-sdk:2.2.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.0'
}

内容的提问来源于stack exchange,提问作者Skmp

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 21:48:31