无法解析com.google.maps.android:android-maps-utils:0.5+

问题描述 投票:0回答:4

我在Android工作室3.看起来似乎无法通过我的gradle解决这个依赖。 `implementation'com.google.maps.android:android-maps-utils:0.5+'重要的是要注意当我更新我的gradle时,我被迫切换到使用'implementation'而不是'compile'的新格式版本4+。

Here's a screenshot of the error这是我的应用程序gradle:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "com.kenkarimi.dell.shift"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    implementation files('libs/CircleImageView-master/gradle/wrapper/gradle-wrapper.jar')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.android.gms:play-services-places:15.0.1'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.google.firebase:firebase-core:16.0.0'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.1'
    implementation 'com.google.firebase:firebase-storage:16.0.1'
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    implementation 'com.firebase:geofire-android:2.3.1'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.github.jd-alexander:library:1.1.0'
    implementation 'com.google.maps.android:android-maps-utils:0.5+'
}

apply plugin: 'com.google.gms.google-services'

这是我的项目gradle gradle文件:

buildscript {
repositories {
    jcenter()
    google()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'
    classpath 'com.google.gms:google-services:3.2.0'
}

}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
android google-maps android-gradle google-direction google-maps-direction-api
4个回答
0
投票

尝试删除maven存储库的覆盖

buildscript {
repositories {
    jcenter()
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'
    classpath 'com.google.gms:google-services:3.2.0'
}
allprojects {
    repositories {
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

0
投票

更新:

将插件更改为当前使用错误插件的apply plugin: 'com.android.library'

清除Android工作室缓存菜单 - >文件 - >使缓存无效/重新启动。

并清除gradle缓存在Windows上:%USER_HOME%\.gradle/caches/

在Mac / Unix上:$HOME/.gradle/caches/


0
投票

删除gradle文件夹并生成文件夹,然后重建它!


0
投票

我没有使用com.google.maps.android:android-maps-utils:0.5+作为依赖项,而是在我的项目中创建了一个类并粘贴了所述依赖项的内容。

所以类名是'PolyUtil.class'。其中唯一的方法是decode(final String encodedPath)

我是如何使用它的。例如我调用PolyUtil.decode(polylines [i])将编码的路径字符串解码为一系列LatLng

这是班级

import com.google.android.gms.maps.model.LatLng;

import java.util.List;
import java.util.ArrayList;

public class PolyUtil {
/**
 * Decodes an encoded path string into a sequence of LatLngs.
 */
public static List<LatLng> decode(final String encodedPath) {
    int len = encodedPath.length();

    // For speed we preallocate to an upper bound on the final length, then
    // truncate the array before returning.
    final List<LatLng> path = new ArrayList<LatLng>();
    int index = 0;
    int lat = 0;
    int lng = 0;

    while (index < len) {
        int result = 1;
        int shift = 0;
        int b;
        do {
            b = encodedPath.charAt(index++) - 63 - 1;
            result += b << shift;
            shift += 5;
        } while (b >= 0x1f);
        lat += (result & 1) != 0 ? ~(result >> 1) : (result >> 1);

        result = 1;
        shift = 0;
        do {
            b = encodedPath.charAt(index++) - 63 - 1;
            result += b << shift;
            shift += 5;
        } while (b >= 0x1f);
        lng += (result & 1) != 0 ? ~(result >> 1) : (result >> 1);

        path.add(new LatLng(lat * 1e-5, lng * 1e-5));
    }

    return path;
    }
}

在我的代码中使用它的示例:

for(int i = 0; i < count; i++){
    options.addAll(PolyUtil.decode(polylines[i])); //decode returns List<LatLng>
}
© www.soinside.com 2019 - 2024. All rights reserved.