問題描述
我一直在嘗試將 這個庫項目 添加到我在 Android Studio 中的現有項目中.這是我第一次使用圖書館項目,我遇到了困難.我從周圍的教程和帖子中尋找了很多方法來做到這一點,但無法完成.
I have been trying to add this library project to my existing project in Android Studio. It's the first time I am going to use a library project and I am having tough time. I have looked around for many ways to do this from tutorials and posts around but couldn't get it done.
推薦答案
我不確定是否已經可以通過 IDE 添加庫項目(-> 沒有任何問題).我通過像這樣配置我的項目的 gradle 文件來做到這一點:
I'm not sure if it's already possible to add a library project via the IDE (-> without any problems). I do this by configuring the gradle files of my project like this:
- 在您的項目根目錄中創建一個名為
libs
的文件夾 - 將文件夾
datetimepicker-library
復制到libs
使用以下命令將這個庫添加到您的
settings.gradle
中:
include ':libs:datetimepicker-library'
轉到您的 AppProject
的 build.gradle
文件,然后將以下行添加到您的 dependencies
:
go to your build.gradle
file of your AppProject
and add the following line to your dependencies
:
implementation project(':libs:datetimepicker-library')
至少你必須同步你的 gradle 文件:Tools -> Android -> Sync Project with Gradle Files
at least you have to sync your gradle files: Tools -> Android -> Sync Project with Gradle Files
請試試這個.如果您遇到錯誤,請發布日志文件.
Please try this. If you get errors please post the log file.
這篇關于如何在 android studio 中使用庫項目的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!