gpt4 book ai didi

java - Android SDK 28源文件和jar文件不匹配

转载 作者:太空宇宙 更新时间:2023-11-04 09:31:13 26 4
gpt4 key购买 nike

我已经安装了Android SDK平台28和Android 28的Sources。我的项目可以正确构建。但是,当我查看SDK源代码(例如Activity.java)时,Android Studio会向我显示烦人的错误(无法解析符号)。我尝试重新安装Android SDK平台28和适用于Android 28的源,并使缓存/重新启动Android Studio无效,但是它们均无济于事。我比较了android.jar的结构和SDK中的sources目录,发现有
源目录中的类比android.jar多。我猜想源代码和android.jar文件不匹配,但是我不知道如何解决。我尝试在新的Ubuntu虚拟机上安装Android Studio和SDK,Android Studio向我显示了相同的错误。
enter image description here

以下是我的build.gradle文件:

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
}

最佳答案

尝试以下方法之一:

1)您可以执行文件-> Invalidate Caches / Restart,然后选择Invalidate and Restart选项来解决此问题。

2)选择工具-> android-> SDK manager并下载所有SDK build toolsSDK platformGoogle API's

3)清理项目并重建

4)备份您的项目。删除所有.iml文件和.idea文件夹重新启动Android Studio并重新导入项目。

5)compileSdkVersion 29targetSdkVersion 29

关于java - Android SDK 28源文件和jar文件不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57075710/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com