2017-01-27 4 views
2

Ich verwende Google Karte, sondern eine issue.I bekommen haben auch Berechtigungen und Schlüssel in einem offenkundigen hinzugefügt bitte unten für Details siehe:Runtime Problem, wenn Karte Erstellen

Ausgabe:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

Main Activity Code:

 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)); 
    } 

XML-Datei Code:

<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.admin.maptest.MapsActivity" /> 

build.gradle Datei Code:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
    applicationId "com.admin.maptest" 
    minSdkVersion 15 
    targetSdkVersion 25 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    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.1.0' 
    compile 'com.google.android.gms:play-services:10.0.1' 
    testCompile 'junit:junit:4.12' 
} 

Antwort

2

versuchen Sie dies in Ihrem gradle

android { 

    compileSdkVersion .. 
    buildToolsVersion '...' 

    defaultConfig { 
     ... 
     targetSdkVersion .. 
     multiDexEnabled true //multidex set true 
    } 
} 

Auch dies zu vermeiden thread

+0

Danke für die Antwort. Es funktioniert. –

+0

Sie können wählen und die Antwort annehmen, wenn es funktioniert @Anjali :) –

+0

Ja, es ist fertig :) –

1

überprüfen multidex in gradle ermöglichen.

Verwenden Sie die erforderliche Bibliothek in Ihrer Größe anstelle aller Wiedergabedienste.

z.B. Wenn Sie Karten verwenden, dann kompilieren 'com.google.android.gms: Play-Dienste-Karten: 10.0.1'

0
defaultConfig { 
    ... 
    targetSdkVersion .. 
    multiDexEnabled true 
    } 

in gradle App und nutzen diese Abhängigkeit
Kompilierung ‚com.android.support: multidex: 1.0.1 '