简体   繁体   English

在Android Studio中使用android-maps-utils

[英]Use android-maps-utils in Android Studio

I am trying to use this library [1] in an Android project either with Android Studio or with ADT. 我试图在Android项目中使用Android库或ADT使用此库[1]。 But it doesn't work at all. 但它根本不起作用。 In ADT I don't know how to handle gradle stuff and in Android Studio, when I try to "Import Project", I get the error "Could not find com.google.android.gms:play-services:3.1.36. 在ADT我不知道如何处理gradle的东西,在Android Studio中,当我尝试“导入项目”时,我收到错误“找不到com.google.android.gms:play-services:3.1.36。

(don't have enough reputation to post picture, it's on imgur with xswZ3.jpg) (没有足够的声望来发布图片,它与xswZ3.jpg有关)

I am not familiar with gradle and I only have a vague idea of what it does but all I want is to use something like BubbleIconFactory f = new BubbleIconFactory(this) in my own project. 我不熟悉gradle,我对它的作用只有一个模糊的想法,但我只想在我自己的项目中使用像BubbleIconFactory f = new BubbleIconFactory(this)这样的东西。

Any help is appreciated! 任何帮助表示赞赏!

[1] https://github.com/googlemaps/android-maps-utils [1] https://github.com/googlemaps/android-maps-utils

Perhaps your problem is needing the repositories outside of the buildscript block. 也许你的问题是需要在buildscript块之外的repositories

The repositories internal to the buildscript is for managing the gradle dependency itself, I believe. 我相信,内置于buildscriptrepositories用于管理gradle依赖本身。 Here's how I resolved my problem with google-maps-utils as a library dependency. 以下是我将google-maps-utils作为库依赖项解决问题的方法。 Hopefully this helps. 希望这会有所帮助。 I included my maps and support-v4 libs too. 我也包括了我的地图和support-v4库。

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.10+'
    }
}

apply plugin: 'android'

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    // Support Libraries
    compile 'com.google.android.gms:play-services:4.1.32'
    compile 'com.android.support:support-v4:19.0.1'
    compile 'com.google.maps.android:android-maps-utils:0.3+'
}

com.google.android.gms:play-services:3.1.36 can be downloaded by going to your SDK Manager and installing the Extras->Google Repository package (you may want to install the Extras->Android Support Repository as well while you are there). com.google.android.gms:play-services:3.1.36可以通过转到SDK Manager并安装Extras->Google Repository包下载(您可能还需要安装Extras->Android Support Repository)在那儿)。 These allow Gradle to automatically use these resources without the need for library projects or jars manually added to your project. 这些允许Gradle自动使用这些资源,而无需手动将库项目或jar添加到项目中。

Add the following dependency to your Gradle build file: 将以下依赖项添加到Gradle构建文件:

dependencies {
    compile 'com.google.maps.android:android-maps-utils:0.2+'
}

You'll need to install the "Google Repository" from the Android SDK manager. 您需要从Android SDK管理器安装“Google Repository”。

See demo/build.gradle for an example. 有关demo/build.gradle请参阅demo/build.gradle

You can, of course, copy the library directory and use it like any other Android library project. 当然,您可以复制library目录并像使用任何其他Android库项目一样使用它。

Let me know if this helps! 如果这有帮助,请告诉我!

Chris 克里斯

Steps: 脚步:

  1. First File>Project Structure>Click Plus Button >Import Graddle Project>Select the file(library folder) from the location where downloaded>CLick Ok. 第一个文件>项目结构>单击加号按钮>导入Graddle项目>从下载的位置选择文件(库文件夹)> CLick Ok。
  2. Add this code to dependencies to that app module build.gradle file(remember there are two build.gradle files) : 将此代码添加到该app模块build.gradle文件的依赖项中(请记住有两个build.gradle文件):

    dependencies { compile 'com.google.maps.android:android-maps-utils:0.4+' } 依赖项{compile'c​​om.google.maps.android:android-maps-utils:0.4+'}

  3. Copy gradle.properties file contents of that Android-maps-util Library project app(found inside that project library folder) TO gradle.properties file of your project(Simple copy and paste of content to the editor). 将app-maps-util库项目应用程序(在项目库文件夹中找到)的gradle.properties文件内容复制到项目的gradle.properties文件中(将简单的内容复制并粘贴到编辑器中)。

  4. Click Sync Project with gradle files button. 单击“使用gradle文件同步项目”按钮。 And you must be fine! 你必须没事!

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

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