Bellow是我的清单文件元数据
<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'
}
应用插件:&#39; com.google.gms.google-services&#39;
这是我的Project 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 version 2.3
以下是我的仅适用于MAP的应用代码
public class MapsActivity extends 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" />
答案 0 :(得分:0)
您好@pmrajnai13您的AndroidManifest.xml文件中缺少您的google地图api密钥。添加google map api密钥。