2016-05-17 3 views

Ich arbeite derzeit an Android-Projekt, die mich erfordern, Google Maps zu implementieren. Ich habe bereits einige Tutorials gemacht, um es zu tun, aber immer noch einen Fehler. Unten ist mein Fehler:Android - Google Maps Implementierung

Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources] 
Warning:Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android. 
    In case of problem, please repackage it with jarjar to change the class packages 
Warning:Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for release as it may be conflicting with the internal version provided by Android. 
    In case of problem, please repackage it with jarjar to change the class packages 
:app:preBuild UP-TO-DATE 
:app:preDebugBuild UP-TO-DATE 
:app:preReleaseBuild UP-TO-DATE 

Unten ist mein AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?> 

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

    <activity android:name=".MainActivity"> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     The API key for Google Maps-based APIs is defined as a string resource. 
     (See the file "res/values/google_maps_api.xml"). 
     Note that the API key is linked to the encryption key used to sign the APK. 
     You need a different API key for each encryption key, including the release key that is used to 
     sign the APK for publishing. 
     You can define the keys for the debug and release targets in src/debug/ and src/release/. 
     android:value="@string/google_maps_key" /> 


Im Folgenden meine build.gradle ist

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 23 
buildToolsVersion "23.0.1" 
useLibrary 'org.apache.http.legacy' 

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

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
testCompile 'junit:junit:4.12' 
compile 'com.google.http-client:google-http-client-android:+' 
compile 'com.google.api-client:google-api-client-android:+' 
compile 'com.google.api-client:google-api-client-gson:+' 
compile 'com.google.code.gson:gson:2.2.4' 
compile 'com.android.support:appcompat-v7:23.1.1' 
compile 'com.google.android.gms:play-services:8.3.0' 

Und hier ist mein MapsActivity.java

package com.example...; 

import android.support.v4.app.FragmentActivity; 
import android.os.Bundle; 

import com.google.android.gms.maps.CameraUpdateFactory; 
import com.google.android.gms.maps.GoogleMap; 
import com.google.android.gms.maps.OnMapReadyCallback; 
import com.google.android.gms.maps.SupportMapFragment; 
import com.google.android.gms.maps.model.LatLng; 
import com.google.android.gms.maps.model.MarkerOptions; 

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { 

private GoogleMap mMap; 

protected void onCreate(Bundle savedInstanceState) { 
    // Obtain the SupportMapFragment and get notified when the map is ready to be used. 
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() 

* Manipulates the map once available. 
* This callback is triggered when the map is ready to be used. 
* This is where we can add markers or lines, add listeners or move the camera. In this case, 
* we just add a marker near Sydney, Australia. 
* If Google Play services is not installed on the device, the user will be prompted to install 
* it inside the SupportMapFragment. This method will only be triggered once the user has 
* installed Google Play services and returned to the app. 
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")); 

ich mehrere Möglichkeiten, bereits versucht, aber es für mich nicht funktioniert. Hoffentlich kann mir jemand helfen, mein Problem zu lösen.

Vielen Dank im Voraus. versuchen



Fügen Sie diese auf Ihrem Manifest dann ..

    android:protectionLevel="signature" /> 

Ersetzen "com.example.yourprojectname" mit Ihrem Paketnamen.