Android Studio: Add jar as library?

后端 未结 30 3022
天命终不由人
天命终不由人 2020-11-21 05:54

I\'m trying to use the new Android Studio but I can\'t seem to get it working correctly.

I\'m using the Gson library to serialize/deserialize JSON-o

30条回答
  •  执笔经年
    2020-11-21 06:38

    Easy steps to add external library in Android Studio

    1. If you are in Android View in project explorer, change it to Project view as below

    1. Right click the desired module where you would like to add the external library, then select New > Directroy and name it as 'libs'
    2. Now copy the blah_blah.jar into the 'libs' folder
    3. Right click the blah_blah.jar, Then select 'Add as Library..'. This will automatically add and entry in build.gradle as compile files('libs/blah_blah.jar') and sync the gradle. And you are done

    Please Note : If you are using 3rd party libraries then it is better to use dependencies where Gradle script automatically downloads the JAR and the dependency JAR when gradle script run.

    Ex : compile 'com.google.android.gms:play-services-ads:9.4.0'

    Read more about Gradle Dependency Mangement

提交回复
热议问题