简体   繁体   English

向jar项目的Android项目添加依赖项

[英]Adding a dependency to Android project for jar

I'm attempting to integrate Localytics into my Android project. 我正在尝试将Localytics集成到我的Android项目中。 Their steps for integration include: 他们的集成步骤包括:

Add a dependency to your project for the jar.

How do I do that? 我怎么做?

using gradle : 使用gradle:

repositories {
       flatDir {
           dirs 'libs'
       }
    }


    dependencies {
       compile name: 'gson-2.2.4'
    }
  1. Put your .jar file in your libs folder. 将您的.jar文件放在libs文件夹中。

PROJECT_NAME/app/libs/example.jar PROJECT_NAME / app / libs / example.jar

  1. Add the .jar file to your dependencies in the gradle file. 将.jar文件添加到gradle文件中的依赖项中。

     dependencies { compile files('libs/example.jar') } 

If you are using Android studio, switch to "Project" view, locate the Jar(s) you want to add as dependency. 如果您使用的是Android Studio,请切换到“项目”视图,找到要添加为依赖项的Jar。 Right click on the Jars and select "Add as Library". 右键单击Jars,然后选择“添加为库”。

PS: To open the "Project" view. PS:打开“项目”视图。 Use the menu View > Tool Windows > Project 使用菜单视图>工具窗口>项目

  1. Copy the Localytics jar into your app/libs folder. 将Localytics jar复制到您的app / libs文件夹中。
  2. Right click on the Localytics.jar file and select "Add as Library" from the conntext menu 右键单击Localytics.jar文件,然后从上下文菜单中选择“添加为库”
  3. Finally make sure that you see the folling in app/build.gradle 最后确保您在app / build.gradle中看到了问题

    dependencies { compile files('libs/localytics.jar') } 依赖项{编译文件('libs / localytics.jar')}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM