Octotentacles
Octotentacles

Reputation: 80

Why "androidx.appcompat" and "android.support.v7" libraries are not compatible for some versions of Android Studio?

I made an android application using Android Studio during lectures at university. Then I uploaded the project to drive and when I got home, after I installed the latest Android Studio, I opened my project and almost every line of code was marked as libraries were not found.

I found that when developing on a computer I use android.support.v7.app.AppCompatActivity but it's not recognized at home. So I tried creating an empty project at home and I found it uses androidx.appcompat.app.AppCompatActivity.

A solution I tried, was to delete all imported libraries and then I let Android Studio to import what he needs, but it's stupid. I have to do that every time I switch the working station.

Why can't it be just one library? Is there other solution, not to re-import all the libraries?

Upvotes: 1

Views: 1713

Answers (2)

cutiko
cutiko

Reputation: 10507

Your problem is "uploaded the project to drive", that also saved the .idea folder where everything regarding the IDE and computer is stored. So you are opening a project on another computer with routes to your old computer. Solutions:

  • Close Android Studio and then delete the .idea and .gradle folder from the project, re-open it
  • File/Invalidate Cache and Restart

Recommended Solution Use a version control system like git. Android Studio does a pretty good job integrating with VCS. In the menus look for VCS/Enable Version Control Integration you need to install git previously and know how to use git.

There is another thing, the new AS version has a sync gradle icon, is an elefant with and arrow, sometimes big changes on gradle can go unnoticed so click it. There is also the usual, clean project or rebuild project.

The other part of the problem is: the different libraries. Androidx was introduced to consolidate in 1 library the support libraries. It is recommended to use it. If the latest version of Android Studio dont support it then you will have to, and also update the IDE on the other desktop

Upvotes: 1

Md. Asaduzzaman
Md. Asaduzzaman

Reputation: 15423

You can't mix AndroidX library with support library in modern android application development. support is already deprecated and AndroidX is future. So, migrate your existing project to AndroidX

With Android Studio 3.2 and higher, you can migrate an existing project to AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.

Check official documents for more information

Upvotes: 2

Related Questions