首页 > 解决方案 > 找不到 GeoApiContext 和 DirectionsApiRequest

问题描述

在我的 Android 应用程序中使用这两个类需要哪些依赖项?下面是我当前的 build.gradle 文件:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.volley:volley:1.1.0'
    //noinspection GradleCompatible
    implementation 'com.android.support:design:26.1.0'
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.maps.android:android-maps-utils:1.0.2'
    implementation 'androidx.legacy:legacy-support-v13:1.0.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'

    //UI Dependencies
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.navigation:navigation-fragment:2.2.2'
    implementation 'androidx.navigation:navigation-ui:2.2.2'

    //testing frameworks
    implementation 'junit:junit:4.13'
    testImplementation 'com.android.support.test:rules:1.0.2'
    androidTestImplementation 'com.android.support.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test:core:1.2.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    testImplementation "org.robolectric:robolectric:4.2.1"

    //API Dependencies
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'com.github.GrenderG:Toasty:1.4.2'
    implementation 'com.squareup.retrofit2:retrofit:2.8.1'
    implementation 'com.squareup.retrofit2:converter-gson:2.7.0'

    //Directions API
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
}

但是,我仍然收到“无法解析符号:GeoApiContext”和“无法解析符号:DirectionsApiRequest”。

我添加了 Google Maven 存储库,但没有运气:

repositories {
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }

谢谢你的热心帮助。

标签: androidgoogle-maps-android-api-2directionsgeoapi

解决方案


弄清楚了。

implementation 'com.google.maps:google-maps-services:0.1.3' 我的 build.gradle 文件中缺少依赖项


推荐阅读