Android kotlin AppCompatActivity错误::Cannot access ‘androidx.activity.contextaware.

An error occurred: the MainActivity class reported red

Cannot access androidx.activity.ComponentActivity

At the beginning, I was still very confused. Why was it okay to create a project before, but why did it become popular this time?

So I started to find the reason: I found that the reason was that the dependent version had been upgraded! feel puzzled

Previous android, appcompat:appcompat:1.0.2 version

Solution: There are two

The first method: In the app of the Module module, find the build.gradle, and add the dependencies that need to be implemented in the dependencies{} structure

implementation "androidx.activity:activity-ktx:1.2.0-beta01"

The second: directly in the dependencies{} structure 

implementation androidx.appcompat: increase the number of versions in appcompat

 

 Finally back to normal!

 

Guess you like

Origin blog.csdn.net/qq_46687516/article/details/124100968