【问题标题】:Google Map is stop showing After upgrade gradle version升级 gradle 版本后,谷歌地图停止显示
【发布时间】:2017-08-21 07:24:49
【问题描述】:

下面是我的清单文件元数据

 <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="HERE IS MY API KEY" />

这是我的 Gradle 文件

 compileSdkVersion 24
buildToolsVersion "24.0.0"


dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':DatePicker')
compile project(':agendacalendarview')
compile files('libs/acra-4.5.0.jar')
compile project(':MaterialCalenderView')
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'com.sothree.slidinguppanel:library:3.3.0'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'com.sothree.slidinguppanel:library:3.3.0'
compile 'com.android.support:design:24.2.1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.hbb20:ccp:1.4'
compile 'com.github.scottyab:showhidepasswordedittext:0.8'
compile 'com.vistrav:ask:2.4'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.android.volley:volley:1.0.0'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.apache.httpcomponents:httpmime:4.2.3'

compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.okio:okio:1.7.0'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.google.code.gson:gson:2.7'
compile 'org.apmem.tools:layouts:1.10@aar'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.mani:ThinDownloadManager:1.2.4'
compile 'com.jakewharton:butterknife:7.0.0'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.github.lzyzsd:circleprogress:1.1.0@aar'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
compile 'com.tbuonomo:slidingpuzzleloading:1.0.1'
testCompile 'junit:junit:4.12'

}

应用插件:'com.google.gms.google-services'

这是我的项目 Gradle

dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
    classpath 'com.google.gms:google-services:3.0.0'
    classpath 'me.tatarka:gradle-retrolambda:3.1.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

我已尝试从MAP API升级所有最新代码

但它现在不起作用。我也用过android studio 2.3版

这是我仅适用于 MAP 的应用代码

公共类 MapsActivity 扩展 FragmentActivity 实现 OnMapReadyCallback {

private GoogleMap mMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}

@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    // Add a marker in Sydney and move the camera
    LatLng sydney = new LatLng(-34, 151);
    mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}

}

用于 MAP 视图的 XML

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.squincy.inhup.Activity.MapsActivity" />

【问题讨论】:

  • 添加显示地图的代码。
  • 我想你换了电脑吧?
  • 添加您的谷歌地图代码。
  • 你现在可以检查我帖子中的代码吗@VinodPattanshetti
  • 请从问题中删除您的 Google Maps API 密钥并替换为“@string/google_maps_key”之类的内容。我们不需要知道。

标签: android google-maps android-studio gradle


【解决方案1】:

嗨@pmrajnai13,您的 AndroidManifest.xml 文件中缺少您的 google map api 密钥。添加该 google map api 密钥。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多