title: 安装与初始化

本篇文档介绍如何安装和初始化 SDK。

1. 安装 SDK

SDK 的安装方式有两种,你可以任选其一:

  • 使用 Maven
  1. <dependency>
    <groupId>com.wilddog.location</groupId>
    <artifactId>wilddog-location-android</artifactId>
    <version>0.1.0</version>
    </dependency>
  • 使用 Gradle

在build.gradle中添加:

  1. dependencies {
    compile 'com.wilddog.location:wilddog-location-android:0.1.0'
    }

2. 初始化 Location SDK

初始化需要有高德的 API Key,以及野狗 AppID:

1. 引入高德 API

build.gradle中,引入:

  1. compile 'com.amap.api:map2d:latest.integration'

2. 初始化 WilddogLocation 服务:

WilddogLocation SDK 依赖于 Wilddog Sync,所以也可以先初始化 Sync 的 App,再用 Sync App 的 Reference 来创建 WilddogLocation 服务:

  1. // 初始化
  2. WilddogOptions options = new WilddogOptions.Builder().setSyncUrl("https://<wilddog appId>.wilddogio.com").build();
  3. WilddogApp.initializeApp(this, options);
  4. SyncReference ref = WilddogSync.getInstance().getReference();
  5. WilddogLocation location = new WilddogLocation(ref);