Android Studio Java Android ContextCompat和ActivityCompat导入突然无法解决

7d7tgy0s  于 2023-06-30  发布在  Android
关注(0)|答案(1)|浏览(183)

我遇到了一个Java项目的问题,这个项目以前工作得很好,直到我加载它,它突然无法解析ActivityCompat和ContextCompat符号。
我该怎么解决这个问题?
有一些建议,Recommended action: Use a different version of dependency 'androidx.core:core:1.12.0-alpha01', or set compileSdkPreview to "UpsideDownCake" in your build.gradle file if you intend to experiment with that preview SDK.但我没有改变任何东西。我该如何设置这个,这会解决问题吗?这是由某种更新引起的吗?

qgelzfjb

qgelzfjb1#

我也遇到了同样的问题,突然间它给了我几十个Cannot resolve symbol X
我做了以下操作:
1.清洁项目-无影响
1.关闭和重新开放-没有立即产生影响
然而,几分钟后,年级同步开始,并采取了相当多的时间,并在它结束时解决了所有的符号。在日志中,我看到了一些突出的项目:

2023-06-28 18:52:58,249 [      6]   INFO - #c.i.i.StartupUtil - ------------------------------------------------------ IDE STARTED ------------------------------------------------------
2023-06-28 18:53:43,834 [  45591]   INFO - #c.a.t.i.g.p.AndroidGradleProjectStartupActivity - Up-to-date models found in the cache. Not invoking Gradle sync.
2023-06-28 18:54:57,608 [ 119365]   INFO - #o.j.p.g.GradleManager - Instructing gradle to use java from C:/Program Files/Java/jdk-17.0.1
2023-06-28 18:55:00,203 [ 121960]   INFO - #o.j.a.u.ViewLoader - getPackageName: failed to find packageName for library androidx.core:core:1.9.0@aar
2023-06-28 18:55:00,203 [ 121960]   INFO - #o.j.a.u.ViewLoader - loadAndParseRClass: failed to find manifest package for project <ProjectName>
2023-06-28 18:55:00,323 [ 122080]   INFO - #o.j.a.u.ViewLoader - getPackageName: failed to find packageName for library androidx.core:core-ktx:1.9.0@aar
2023-06-28 18:55:00,323 [ 122080]   INFO - #o.j.a.u.ViewLoader - loadAndParseRClass: failed to find manifest package for project <ProjectName>
2023-06-28 18:55:00,710 [ 122467]   INFO - #o.j.a.u.ViewLoader - getPackageName: failed to find packageName for library com.google.android.material:material:1.8.0@aar
2023-06-28 18:55:00,710 [ 122467]   INFO - #o.j.a.u.ViewLoader - loadAndParseRClass: failed to find manifest package for project <ProjectName>
2023-06-28 18:55:00,985 [ 122742]   INFO - #o.j.a.u.ViewLoader - getPackageName: failed to find packageName for library com.google.android.gms:play-services-basement:18.1.0@aar
2023-06-28 18:55:00,986 [ 122743]   INFO - #o.j.a.u.ViewLoader - loadAndParseRClass: failed to find manifest package for project <ProjectName>
2023-06-28 18:55:01,675 [ 123432]   INFO - #o.j.a.u.ViewLoader - getPackageName: failed to find packageName for library com.google.android.gms:play-services-auth:20.4.1@aar
2023-06-28 18:55:01,675 [ 123432]   INFO - #o.j.a.u.ViewLoader - loadAndParseRClass: failed to find manifest package for project <ProjectName>
2023-06-28 18:55:01,705 [ 123462]   INFO - #o.j.a.u.ViewLoader - getPackageName: failed to find packageName for library com.google.android.gms:play-services-fido:19.0.1@aar
2023-06-28 18:55:01,705 [ 123462]   INFO - #o.j.a.u.ViewLoader - loadAndParseRClass: failed to find manifest package for project <ProjectName>

...

2023-06-28 19:01:04,591 [      5]   INFO - #c.i.i.StartupUtil - ------------------------------------------------------ IDE STARTED ------------------------------------------------------
2023-06-28 19:01:32,269 [  27683]   INFO - #c.i.u.i.UnindexedFilesUpdater - Started scanning for indexing of <ProjectName>. Reason: On project open
2023-06-28 19:04:50,786 [ 226200]   INFO - #c.i.u.i.UnindexedFilesUpdater - Started scanning for indexing of <ProjectName>. Reason: On updated roots of library 'Kotlin Script dependencies'
2023-06-28 19:04:57,473 [ 232887]   INFO - #c.i.u.i.UnindexedFilesUpdater - Started scanning for indexing of <ProjectName>. Reason: Merged changes in: "Library Gradle: androidx.annotation:annotation-jvm:1.6.0", "Library Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.8.10", "Library Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.8.10", "Library Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0", "Library Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0", "Library Gradle: androidx.core:core:1.10.1@aar", "Library Gradle: androidx.core:core-ktx:1.10.1@aar", "Library Gradle: com.google.android.material:material:1.9.0@aar", "Library Gradle: com.google.android.gms:play-services-basement:18.2.0@aar", "Library Gradle: com.google.android.gms:play-services-auth:20.5.0@aar" and 1 iterators more with changes in: "Library Gradle: androidx.arch.core:core-runtime:2.0.0@aar" with changes in: "Library Gradle: androidx.core:core-ktx:1.3.2@aar" with changes in: "Library Gradle: androidx.test.espresso:espresso-idling-resource:3.5.1@aar" with changes in: "Library Gradle: androidx.test:runner:1.5.2@aar" with changes in: "Library Gradle: androidx.test.espresso:espresso-core:3.5.1@aar" with changes in: "Library Gradle: androidx.test.services:storage:1.4.2@aar" with changes in: "Library Gradle: androidx.test:annotation:1.0.1@aar" with changes in: "Library Gradle: androidx.test:monitor:1.6.1@aar" with changes in: "Library Gradle: androidx.test:core:1.5.0@aar" with changes in: "Library Gradle: androidx.test.ext:junit:1.1.5@aar"
2023-06-28 19:06:24,828 [ 320242]   INFO - #c.i.d.PerformanceWatcherImpl - Reindexing refreshed files of <ProjectName> took 76ms; general responsiveness: ok; EDT responsiveness: ok

相关问题