How to add Android Support Repository to Android Studio?

前端 未结 6 2035
礼貌的吻别
礼貌的吻别 2020-12-09 07:47

I\'m using Android Studio with an external Android SDK. I have installed the support library and the support repository. The support repository is in:

~/Deve         


        
6条回答
  •  北海茫月
    2020-12-09 08:08

    Android Studio 3

    Make sure you have the latest version of Android Studio. The support library is included by default when you create new projects. If you are adding the Support Library to a project that doesn't have it, then you just need to add a single line to your app module's build.gradle file, and then sync gradle.

    build.gradle

    dependencies {
        ...
        implementation 'com.android.support:appcompat-v7:27.1.1'
    } 
    

    It should just be that easy, though there may be some things to note:

    • Android Studio should give you a warning nowadays if the support library needs to be updated. Just update the 27.1.1 numbers that I have here to whatever it tells you to. You can also manually check what the latest revision is if you want to.
    • The implementation keyword replaces compile that was used in Android Studio 2.x. (What's the difference?)
    • There are other support library packages that you may need to include depending on what your app uses (like constraint-layout or recyclerview).
    • Make sure that you have the latest updates for everything in the SDK Manager. Go to Tools > SDK Manager.

    Documentation

    • Support Library
    • Support Library Setup
    • Support Library Features

提交回复
热议问题