Question

I am making a simple map application but on running it, errors are displayed which i don't understand....

my project min SDK is android 2.2(Froyo) API 8 , target SDK is android 4.4(kitkat) API 19 and app is compiled with Google API 2 rev 8.....

I really don't know what should be the combinations of min, target and compiled apis in order to make my app run ....help me out with the proper combination.

following is my manifest file code

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.margallahillhikedroid"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <uses-library android:name="com.google.android.maps"/>"
    <activity
        android:name="com.example.margallahillhikedroid.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

// following is main java source

// package com.example.margallahillhikedroid;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

import android.os.Bundle;

import android.view.Menu;

public class MainActivity extends MapActivity {
MapView map;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    map=(MapView)findViewById(R.id.mymap);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}

}

following is main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<com.google.android.maps.MapView
      android:id="@+id/mymap"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:apiKey="AIzaSyBcTxeirTSzthVlMal5JDDC-SK-Mw7s_CE"/>

</RelativeLayout>

on running the app following errors in console section displayed;

[2014-04-14 07:37:14 - MargallahillHikedroid] Dx 
trouble writing output: already prepared
[2014-04-14 07:37:14 - Dex Loader] Unable to execute dex:     java.nio.BufferOverflowException. Check the Eclipse log for stack trace.
[2014-04-14 07:37:14 - MargallahillHikedroid] Conversion to Dalvik format failed:    Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack   trace.

in the problem section following error is displayed

Description Resource    Path    Location    Type
Conversion to Dalvik format failed: Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace. MargallahillHikedroid       Unknown Android Packaging Problem

I am making a map application but on running it above mentioned errors are displayed in the problem section as well as the console section.

Was it helpful?

Solution

Your problem is that you are trying to implement Google Maps API V1, probably using the Google Maps API V2 key. And That you can't do.

So what you should do is make the following changes in your code:

1. Remove: <uses-library android:name="com.google.android.maps"/>" from your manifest file, this a V1 permission.

2. If you want to support V8 API then you have to remove the implementation of you activity to MapActivity and change it to FragmentActivity. For supporting fragment on older systems.

3. Change you xml layout file from:

<com.google.android.maps.MapView
  android:id="@+id/mymap"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:apiKey="AIzaSyBcTxeirTSzthVlMal5JDDC-SK-Mw7s_CE"/>

To this:

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

4. Finally you have to add some staff in your manifest file:

Add those permissions:

<permission android:name="your.application.package.permission.MAPS_RECEIVE" 
android:protectionLevel="signature"/>
<uses-permission android:name="your.application.package.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>

change your.application.package to your actual application package name.

And add those:

<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="Your Google Maps API V2 Key" />

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

under the application hive.

You can also use this guide that I wrote on this topic to help you out:

Google Maps API V2

and go over the steps of producing the api key and make sure you haven't missed any thing:

Google Maps API V2 Key

OTHER TIPS

It sometimes appen with Eclipse. You just have to close Eclipse, relaunch it, clean your project, refresh it, and retry... It should do the trick... ;)

The min sdk forvmap v2 is 11 please change to that.And try

You need to implement Google Map V2. May be following line causing the problem in the manifest uses-library android:name="com.google.android.maps"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top