【问题标题】:Can't import 'com.google.android.maps'无法导入“com.google.android.maps”
【发布时间】:2017-11-10 08:39:24
【问题描述】:

我正在使用一个使用包“com.google.android.maps”的“MapActivity”的库,但无法解析该包。我使用安卓工作室。这是我的 build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
    applicationId "pl.llp.aircasting"
    minSdkVersion 15
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-maps:7_r1'
compile 'org.roboguice:roboguice:1.1'
compile 'com.google.inject:guice:2.0-no_aop'
compile "com.google.guava:guava:16+"
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.intellij:annotations:+@jar'
testCompile 'junit:junit:4.12'
compile 'com.google.code.findbugs:jsr305:2.0.1'
compile 'ch.acra:acra:4.2.3'
}

【问题讨论】:

  • 它在你的(类)路径上吗?
  • 我认为没有。我没有配置类路径
  • 但我已经在 build.gradle 中添加了 compile 'com.google.android.gms:play-services-maps:7_r1'
  • 如果您使用的是 Maven 或 Gradle,请检查是否将依赖项添加到类路径中,如果没有,则需要下载相应的 jar。
  • 好吧,这就是你的问题。您认为导入语句会在整个互联网上查找您请求的库吗?

标签: java android google-maps gradle


【解决方案1】:

您的 build.gradle 文件中是否存在这一行?

编译'com.google.android.gms:play-services-maps:9.8.+'

【讨论】:

  • 我把 compile 'com.google.android.gms:play-services-maps:7_r1'
  • 如果可能的话,分享你的 build.gradle 文件
  • 好的,我修改了帖子。请在帖子上查看 build.gradle
  • 你能把下面的块添加到你的 gradle 文件中吗,allprojects { repositories { jcenter() flatDir { dirs 'libs' } } }
  • 你能把 com.google.android.gms:play-services-maps:7_r1 改成 com.google.android.gms:play-services-maps:8.3.0
【解决方案2】:

更改您的地图依赖项

compile 'com.google.android.gms:play-services-maps:7_r1'

compile 'com.google.android.gms:play-services-maps:11.0.4'

【讨论】:

    猜你喜欢
    • 2012-04-25
    • 2016-06-09
    • 2021-11-20
    • 2017-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-03
    相关资源
    最近更新 更多