i am trying to use google maps in my application but its giving me an error in the xml file as
"error: No resource identifier found for attribute 'apikey' in package 'android'"

can i know how to solve this error
thanks in advance

Hi, Sharathg

Check for MapAPI key that you had registered for that application is perfect or not.

I think this link: Google Map View will help you to solve your error.

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="Your Maps API Key goes here"
/>

thanks for replying....
i did the process and got the apikey from the site but am getting error even after that..
please help me

Hello Sharathg,

You should check package name in xml file approx last line where :code.google.example is placed, will replace by your package name.

Still if you are not out from this problem then it is barred!

sorry to say this
i am a beginner to android and
please help me to find out the package..

do u say that where's the package means the name i gave at the beginning of the project??

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
	android:id="@+id/RelativeLayout01"
	android:layout_width="fill_parent" 
	android:layout_height="fill_parent" 
	xmlns:android="http://schemas.android.com/apk/res/android"
>
 
<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="07adJ8Tfsq4nsNqyaCMYlzsgbeccTIQxU46...."
	/>

</RelativeLayout>

and this is the code of xml file and my package name is
package com.tabex;

Let's create a your demo with scratch.

Using Eclipse, Follow this tutorial as it explained nice.

thank u
i will follow the tutorial and if in any case of difficulty i will post here again
thank u once again

thanks sir
i got the map deployed to my emulator

i have to get the map displayed on to the screen after a button is clicked
i tried to do it
but i am getting force close exception
please help me

this is the code from which i am calling the activity which displays the map

package com.tabex;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class maps extends Activity{
	
	Button bt1,bt2;
	EditText ed;
	SQLiteDatabase mydb;
	String rollno,details[];
	String loc="";
	String database="registration3";
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.view);
        /*mydb=openOrCreateDatabase("register", MODE_PRIVATE, null);
        Toast.makeText(getApplicationContext(), "database created", 70).show();
        mydb.execSQL("CREATE  TABLE IF NOT EXISTS "+database+" (roll varchar,name varchar,phno varchar,address varchar,gender varchar,dob varchar,place varchar)");
        Toast.makeText(getApplicationContext(), "Table created", 90).show();
       
       
        bt2=(Button)findViewById(R.id.Button02);
        ed=(EditText)findViewById(R.id.EditText01);*/
        bt1=(Button)findViewById(R.id.Button01);
        bt1.setOnClickListener(new OnClickListener(){

			public void onClick(View v) {
				// TODO Auto-generated method stub
				/*rollno=ed.getText().toString();
				Cursor c=mydb.rawQuery("SELECT place FROM  '"+database+"'  WHERE roll='"+rollno+"'",null);
				
		       if(c.moveToFirst())
		       {
		    	 do
		    	 {
		    		 loc=c.getString(0) ;
		    		 
		    			
		    		
		    		 
		    	 }while(c.moveToNext());
		    	 Toast.makeText(getApplicationContext(), loc+"",100).show();		   	
		    	  */
				   Intent it=new Intent(maps.this,displaymap.class);
				       it.putExtra("location", loc);
				       
				     startActivity(it);
		       }
		      /*else
		       {
		    	   Toast.makeText(getApplicationContext()," no record found  ",100).show();		   	
					
		       }
		    	
				
			}*/
        	
        	
        });
        
}

	 }

and the code for displaymap.java is

package com.tabex;

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

import android.app.Activity;
import android.os.Bundle;

public class displaymap extends MapActivity{
 MapView mapView;
MapController mc;
	public void onCreate(Bundle b)
	{
		super.onCreate(b);
		setContentView(R.layout.maps);
		String[] cordinates=new String[1];
		cordinates[0]="17.385044";
		cordinates[1]="17.385044";
		mapView=(MapView)findViewById(R.id.mapview);
		mapView.setBuiltInZoomControls(true);
		mc=mapView.getController();
		mc.setZoom(17);
		double lat=Double.parseDouble(cordinates[0]);
	 	double lon=Double.parseDouble(cordinates[1]);	
	     GeoPoint g=new GeoPoint((int)(lat*1E6), (int)(lon*1E6));
	     mc.animateTo(g);
	     mapView.setSatellite(true);
	     mc.setZoom(10);
	     mapView.invalidate();
	    
	}

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

}

help me to solve this problem please

and the error in logcat file is as below


08-30 17:02:34.703: ERROR/dalvikvm(540): Could not find class 'com.tabex.displaymap', referenced from method com.tabex.maps$1.onClick

08-30 17:03:05.244: ERROR/AndroidRuntime(540): java.lang.NoClassDefFoundError: com.tabex.displaymap


please help me

I had some funny issues with classes from same packages not being found. Try to add import com.tabex.displaymap; into class maps

PS: Would be nice if you also adhered naming convention like class name starting with upper letter "DisplayMap" or "Maps"

i imported the package u asked to
but even though i am getting error

" 08-30 21:41:59.973: ERROR/dalvikvm(309): Could not find class 'com.tabex.displaymap', referenced from method com.tabex.maps$1.onClick "
" 08-30 21:42:02.864: ERROR/AndroidRuntime(309): java.lang.NoClassDefFoundError: com.tabex.displaymap "

08-30 21:42:02.864: ERROR/AndroidRuntime(309): at com.tabex.maps$1.onClick(maps.java:53)

08-30 21:42:02.864: ERROR/AndroidRuntime(309): at android.view.View.performClick(View.java:2408)
and i wonder to the above error
i dont even have 200 lines in my file View.java and i am getting error at 2408th line
please help me..

I had some funny issues with classes from same packages not being found. Try to add import com.tabex.displaymap; into class maps

PS: Would be nice if you also adhered naming convention like class name starting with upper letter "DisplayMap" or "Maps"

Using the right letter case is the key to following a naming convention:

  • Lowercase is where all the letters in a word are written without any capitalization (e.g., while, if, mypackage).

  • Uppercase is where all the letters in a word are written in capitals. When there are more than two words in the name use underscores to separate them (e.g., MAX_HOURS, FIRST_DAY_OF_WEEK).

  • CamelCase (also known as Upper CamelCase) is where each new word begins with a capital letter (e.g., CamelCase, CustomerAccount, PlayingCard).

  • Mixed case (also known as Lower CamelCase) is the same as CamelCase except the first letter of the name is in lowercase (e.g., hasChildren, customerFirstName,customerLastName).

According to me we have to suffice all aspects that need in programming.

sorry for voilating the conventions..
and i would be happy if the problem is solved
please help me

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@android:id/tabhost"
   android:layout_width="fill_parent" android:layout_height="fill_parent">
   <LinearLayout android:orientation="vertical"
     android:layout_width="fill_parent" android:layout_height="fill_parent">
      <TabWidget android:id="@android:id/tabs"
         android:layout_width="fill_parent" android:layout_height="wrap_content"/>
      <FrameLayout android:id="@android:id/tabcontent"
         android:layout_width="fill_parent" android:layout_height="fill_parent">
          <RelativeLayout android:id="@+id/emptylayout1" android:orientation="vertical"
             android:layout_width="fill_parent" android:layout_height="fill_parent"/>
          <TextView android:id="@+id/textview2"
             android:layout_width="fill_parent"
               android:layout_height="fill_parent"
             android:text="Details Details Details Details"/>
      </FrameLayout>
   </LinearLayout>
</TabHost>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/maptablayout" android:orientation="vertical"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
    <com.google.android.maps.MapView android:id="@+id/mapview"
       android:layout_width="fill_parent" android:layout_height="fill_parent"
       android:clickable="true"
        android:apiKey="0pFtdSwta8EMTfArj32ycOw2kZg0LSEqa4fUGFA"/>
</RelativeLayout>

Check with this Code

thanks for the help sir
i am getting map in case of tabs but i am getting errors when i am using a button to display a map
i mean to say
i need to click a button to view the map
this is my requirement
please help
Thanks in advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.