IT story

'AppCompatActivity'기호를 해결할 수 없습니다

hot-time 2020. 5. 7. 08:00
반응형

'AppCompatActivity'기호를 해결할 수 없습니다


방금 Android Studio를 사용하려고했습니다. 빈 프로젝트를 만들고 Activity확장하는 을 만들려고했습니다 AppCompatActivity. 불행한 안드로이드 스튜디오는 "그 말을"

'AppCompatActivity'기호를 해결할 수 없습니다

내가 가진 compile "com.android.support:appcompat-v7:22.0.+"내 "응용 프로그램"모듈과 재건 프로젝트 몇 차례의 의존성 목록에. 그러나 나는 만 사용할 수 있습니다 ActionBarActivity. 내가 무엇을 잘못하고 있지?


올바른 lib 버전과 올바른 클래스를 사용하는 동안 동일한 오류가있는 사람을 위해 여기에 다른 답변이 약간 추가되었습니다.

내가 업그레이드했을 때

appcompat-v7:22.1.0

어떤에서 ActionBarActivity사용되지 않는 빈되고 AppCompatActivty인해 안드로이드 Studio에서 일부 결함에, 길을 가야하는 것입니다, 그것은 아주 버전 변화를 선택하지 않았다.

즉, Gradle이 오류없이 실행되었지만 IDE 자체가 계속 말하고 있습니다 Cannot resolve symbol 'AppCompatActivity'( Ctrl+N검색을 통해서도 사용할 수 없음 )

.idea/libraries폴더를 살펴보고 새 버전의 lib에 적합한 메타 파일이 없다는 것을 알았습니다.

따라서 이전의 신뢰할 수있는 File-> Invalidate Caches / Restart를 사용 하여 트릭을 수행했습니다. Android Studio에서 무언가 마술처럼 잘못되었다고 느낄 때 항상 시도하십시오.


gradle 파일 / "Invalidate caches"및 기타 IDE 도구를 통한 소프트 메소드가 작동하지 않으면 어려운 방법을 사용하십시오.

  1. Android Studio 종료
  2. 프로젝트에서 .idea폴더로 이동
  3. libraries폴더 이름 바꾸기
  4. Android Studio를 다시 시작하십시오. 이제 libraries폴더를 다시 만들고 다시 작동해야합니다.

이것은 나를 위해 일했다.

Android Studio 3.1.2
Build #AI-173.4720617, built on April 13, 2018
JRE: 1.8.0_152-release-1024-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.13.0-38-generic

Shahbaz Ali는 확인했습니다.

Android Studio 3.1.3
Build #AI-173.4819257, built on June 4, 2018
JRE: 1.8.0_152-release-1024-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.13.0-38-generic

moujib 은 Android Studio 3.2.1에서 작동합니다.


오늘 (4 월 22 일) AppCompatActivity지원 라이브러리 v 22.1.0과 함께 릴리스 된 새로운 기능을 사용할 수 있습니다 .

의존성을 변경하십시오.

compile "com.android.support:appcompat-v7:22.1.0"

여기이 새로운 클래스에 대한 자세한 정보가 있습니다.


build.gradle파일로 이동하여 appcompat컴파일과 같은 종속성으로 수정했습니다.'com.android.support:appcompat-v7:XX.X.X'

컴파일하도록 변경했습니다 'com.android.support:appcompat-v7:XX.X.+'

그런 다음 동기화를 클릭하십시오. 코드의 다른 모든 것이 정확하면 모든 빨간색 구불 구불 한 줄이 가야합니다.


너무 간단합니다. 수행해야 할 단계는 다음과 같습니다.

1-Android 스튜디오를 종료하십시오.

2- 프로젝트 디렉토리로 이동하십시오.

내 경우에는 이와 같은 3- 뭔가 (F> Android-> YourProjectName->. idea).

4)-.idea 폴더에있는 라이브러리 폴더를 삭제하십시오.

5)-restart your android studio. and your issue is resolved.


Check for typos too, i wasted my whole day looking for solutions when i had actually typed AppCompactActivity instead of AppCompatActivity


I got the Cannot resolve symbol error for AppCompatActivity and many other classes & methods after updating Android Studio from 2.2.3 to 2.3, updating Android Gradle plugin to 2.3.0, and updating Gradle to 3.3.

File -> Invalidate Caches / Restart did not resolve the issue.

Preferences -> Build, Execution, Deployment -> Gradle showed Use local gradle distribution selected with Gradle home: /Applications/Android Studio.app/Contents/gradle/gradle-2.14.1 and a warning displayed saying the gradle location was incorrect.

Resolved issue by selecting Use default gradle wrapper (recommended).
Probably just pointing to the new local distribution location would also work.


Cannot resolve symbol AppCompatActivity Issue.

Do the Simple Step to resolve the problem.

i) Exit the Android studio.

ii) Go to your project directory.

iii) Find the .idea folder in your project directory.

iv) Delete .idea folder.

v) Restart your android studio.

vi) The Issue Will be resolved.


Try this. In Android Studio, after putting the dependency in build.gradle. Go to Build --> Clean Project.

It worked for me.


Thats really insane, i tried everything, synced with Gradle files, invalidated and restarted android studio. Still the problem persisted. Last resort was deleting .idea/libraries folder and it worked as charm.


You can use new AppCompatActivity appcompat-v7:22.1.+ Just add this to your gradle:

compile 'com.android.support:appcompat-v7:22.1.1'


For me the issue resolved when i updated the appcompact v7 to latest..

compile 'com.android.support:appcompat-v7:25.3.0'

Hope it helps...:)


So my collegue pushed their local.properties which broke everything. I copied my sdk path from another app and did:

File -> Sync Project with Gradle Files

I was getting this same problem with Android SDK 23, while developing on a Mac OS X Yosemite Machine. It turned out that I did not have Java SDK 7.

Once I installed Java SDK 7 and pointed the SDK from with the Android Studio to the new SDK, everything worked for me.

Here are the steps that I followed:

1) Shutdown Android SDK

2) Install Java SDK for Mac OS X from http://www.oracle.com/technetwork/java/javase/downloads/index.html

3) Start the Android SDK and point the SDK for this project to the new 1.7 Java SDK by going to File -> Project Structure -> JDK Location

4) Restart Android Studio

Hope this help


Remember to press Alt+Enter or add the import.

import android.support.v7.app.AppCompatActivity; 

none of below solved my issue

  • Restart Android
  • File >> Synch Project with Gradle Files
  • Build >> Clean Project
  • Build >> Rebuild Project
  • File >> Invalidate Caches / Restart

Instead, I solved it by updating the version of appcompat & design dependencies to the recent version To do so: go to build.grade (Module:app) >> dependencies section and then hit ALT + ENTER on both appcompat & design dependencies then select the shown version in my case it's 24.2.1 as shown in the picture enter image description here


I updated my Gradle 2.3.3 to 4.4 and got an error on AppCompatActivity and also Cardview. I tried with clean project and rebuild project. It won't work, then I go to Project Folder -> .idea -> create backup of libraries folder and remove it -> then Rebuild Project that solved my issue.


After upgrading to the latest support library, I had to upgrade to the latest Android studio (beta) version and gradle version before the IDE recognized AppCompatActivity again (invalidating caches and restart did not do the trick)


Add this dependency in project build .gradle.

Follow the example below.

dependencies {

    compile 'com.android.support:appcompat-v7:22.1.0'
}

Lets get going step by step: first clean project by using

Build->Clean

if this doesn't helps then use your second step

File>Invalidate Caches/Restart...

But the real problem begins when all the above options doesn't works so use your ultimate solution is to close project and go to project location directory and delete

.idea

You can open your project now again.


Easist Way

  • Open app level build.gradle and remove appcompact-v7 dependency & Sync.
  • Add dependency again & Sync.

Error gone!

Before

before

After

after


You Have to just Do some change in your Gradle App File by adding some dependency

compile "com.android.support:appcompat-v7:XX:YY:ZZ"

while XX:YY:ZZ is the version code that you are using in your gradle file, otherwise if you set this version lower or higher than that you are using , then your app will face some problems like it will crash sometimes


i just update my android studio from 2.3.2 to 3.1.2 version. and this error occurs.

i clean project, rebuild project, invalidate cache/restart but nothing works.

i resolve this error by updating appcompat library from

compile 'com.android.support:appcompat-v7:23.4.0'

to

compile 'com.android.support:appcompat-v7:25.1.1'

in app build.gradle file.


If Invalidating caches not helps, just close the project then re-open it. Steps:

  • File > Close Project
  • Remove the project out of the starting project list
  • Close Android Studio
  • Open Android Studio
  • Open existed Project with this project

For me, the issue resolved when I updated the Gradle build version. Don't know why?


I'll tell you how did i solved this problem in eclipse. Download zip file from this link.https://github.com/dandar3/android-support-v7-appcompat then extract this file,open project, in lib folder you will see one jar file named "android-support-v7-appcompat" , add this jar file into your project. Thats it. enter image description here


This can might be in the version difference in the app level gradle check it once and then re-build


For me worked no one of the solutions. But I found out that all the libraries of the support libraries were missing at my external libraries. And in other projects the AppCompatActivity was resolved without problems.

For me it worked to create a new project and copy all the stuff of the old src folder into the new project.

I don't know exact why, but if nothing works, it could be the last possibility. Just if someone has the same trouble as me.


By trying soft ways it wont works, use the hard way: Exit Current Android Studio Screen and goto your project to the .idea folder Rename the libraries->lib_pre folder.

Restart Android Studio.It will now recreate the libraries folder and work again Smoothly. Android Studio 3.1.3


This is the lifesaver code I found somewhere(sorry don't remember the origin). Add it to build.gradle (Module:app). You can replace the version to the relevant.

configurations.all {

    resolutionStrategy.eachDependency { DependencyResolveDetails details -
        def requested = details.requested

 if (requested.group == 'com.android.support') {

            if (!requested.name.startsWith("multidex")) {
                details.useVersion '27.1.1'
            }
        } else if (requested.group == "com.google.android.gms") {
            details.useVersion '15.0.0'
        } else if (requested.group == "com.google.firebase") {
            details.useVersion '15.0.0'
        }
    }
}

참고URL : https://stackoverflow.com/questions/29199891/cannot-resolve-symbol-appcompatactivity

반응형