I am new to SW development with Android.
Trying to have a MapView object in my display. Code is straightforward below. But for some reason when i launch the application i do not see any map but rather the grey grid.
I have looked at many posts on the internet and i understand that it is either an INTERNET permission (which is included in my coe) or a wrong apiKey. I have gone through the apiKey several time.
Am not sure what can be wrong. Any help would be great. Thanks, Lebnen.
-----------------------------------------------
Manifest.xml
-----------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.testmap"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.INTERNET" />
<activity android:name=".TestMapActivity"
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>
-----------------------------------------------
main.xml
-----------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
androidrientation="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:enabled="true"
android:apiKey="0SA_n7tIj-klgGxARuFJgEos8FBGtEshpgmfogA"
/>
</LinearLayout>
-----------------------------------------------
testMapActivity.java
-----------------------------------------------
package com.test.testmap;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.LinearLayout;
import com.google.android.maps.MapView;
import com.google.android.maps.MapController;
import com.google.android.maps.MapActivity;
import com.google.android.maps.GeoPoint;
public class TestMapActivity extends MapActivity {
private MapView mapView;
LinearLayout linearLayout;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
mapView = (MapView) this.findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapView.setSatellite(true);
}
@Override
public boolean isRouteDisplayed() { return false; }
}
Dont see your manifest. Is it a dev map key ? Is the application debuggable in the manifest ?
Sent from my Nexus One using XDA App
1. What do you mean by dev map key? Am using the debug.keystory MD5 hash that I feed into the google page http://code.google.com/android/add-ons/google-apis/maps-api-signup.html to get the apiKey.
2. The application is debbugable in the manifest.
Ok i see your files on computer now (not on android application on my nexus one)
replace com.google.android.maps.MapView by com.test.testmap.testMapActivity
If I replace it in main.xml the application crashes; in the manifest it does not compile
Help!
the:
<uses-permission android:name="android.permission.INTERNET" />
you have to put on <manifest>, not on <application>
like
<manifest ...>
<application ...>
<uses-library android:name="com.google.android.maps" />
.
.
.
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Other thing that I'm not totally right if it's correct:
I don't know if this is correct, but for me, only worked when I create a new Android Project with Target on Google API's. Didn't work with Android 2.2 + map.jar.
Did you create with Android X.X or Google API ?
I have tried to put the INTERNET permission inside and outside the application. It does not make a difference.
I am building a Google API application.
It worked.
Weird. I had to add
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
in <manifest> outside of <application> and did it through the "Permissions" tab in Eclipse.
Thanks.
Interesting, because I thought that the "ACCESS_FINE_LOCAT ION" is used only when you try to use something with location, such as get location, distance between locations, etc..., I thought that it's not necessary when you only want to show the map
Good to know, thank you
Related
Hi all,
I am trying to get map in android Emulator, But I have error message when i run the application.How to rectify this error?
My Code:
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.googlemapsandroid"
android:versionCode="1"
android:versionName="1.0">
<uses-library android:name="com.google.android.maps.map" />
<application android:icon="@drawable/worldmap" android:label="@string/app_name">
<activity android:name=".GoogelMapsAndroid"
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>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
androidrientation="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="0ubDx0zU6vaeSSZoV0oyPB4zi7y8T2hKSZfAyZw"
/>
</RelativeLayout>
GoogleMapsAndroid.java
package com.android.googlemapsandroid;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class GoogleMapsAndroid extends MapActivity
{
MapView mapview;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapview=(MapView)findViewById(R.id.mapview);
mapview.setSatellite(true);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
I have error message:
java lang Runtime Exception Unable to instantiate ComponentInfo{com.android.googlemapsandroid/com.android.googlemapsandroid.MapsActivity}java.lang.RuntimeException: stub
Do you use Google APIs target in an emulator?
No. How to use Google api.
dineshsubramanian said:
No. How to use Google api.
Click to expand...
Click to collapse
This is what I mean:
http://img40.imageshack.us/f/screenshotcreatenewandr.png/
Thanks for your reply.
I will try in Google Api.
Now i ran in google api. but i have error message
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.googlemapdemo/com.googledemo.GoogleMapDemo}: android.view.InflateException: Binary XML file line #6: Error inflating class com.google.android.maps.MapView.
Hi,
I am new to android development. I am facing problem in switching between activities. I am attaching the code files ... Please help me solve this problem
Being a new user the Forum doesn't allow me to write atTheRateSign in my message ... I am replacing it with % sign. Please don't confuse it.
Main Activity:
Code:
package swz.pkg;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class SWMainActivity extends Activity {
/** Called when the activity is first created. */
%Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btnMSrch = (Button) findViewById(R.id.btnClosetSearch);
try{
btnMSrch.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(v.getContext(),ClosetSearchAct.class);
startActivityForResult(myIntent,0);
}
});
}
catch (Exception ex)
{
System.out.println("---------------------******------------------------");
ex.printStackTrace();
System.out.println();
System.out.println("---------------------******------------------------");
}
}
}
main.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="%+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="ht ... android"
>
<Button
android:id="%+id/btnMeasurementSearch"
android:layout_width="fill_parent"
android:layout_height="150px"
android:background="#ffffffff"
android:text="Measurement Search"
android:textSize="26sp"
android:typeface="serif"
android:textStyle="bold"
android:textColor="#ff8c2528"
android:layout_x="0px"
android:layout_y="47px"
>
</Button>
<Button
android:id="%+id/btnClosetSearch"
android:layout_width="fill_parent"
android:layout_height="150px"
android:text="Closet Search"
android:textSize="26sp"
android:typeface="serif"
android:textStyle="bold"
android:textColor="#ff462556"
android:layout_x="0px"
android:layout_y="213px"
>
</Button>
</AbsoluteLayout>
closetSearch activity(The next activity I want to move to):
Code:
package swz.pkg;
import android.app.Activity;
import android.os.Bundle;
public class ClosetSearchAct extends Activity {
public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.closetsearchact);
}
}
closetsearchact.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="%+id/widget1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="ht .... android"
>
<Spinner
android:id="%+id/spinner1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="0px"
android:layout_y="33px"
>
</Spinner>
<Spinner
android:id="%+id/spinner2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="0px"
android:layout_y="101px"
>
</Spinner>
<Spinner
android:id="%+id/spinner3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="0px"
android:layout_y="173px"
>
</Spinner>
<ImageButton
android:id="%+id/btnReg"
android:layout_width="128px"
android:layout_height="wrap_content"
android:src="%drawable/reg"
android:layout_x="151px"
android:layout_y="279px"
>
</ImageButton>
<ImageButton
android:id="%+id/btnSearch"
android:layout_width="114px"
android:layout_height="49px"
android:src="%drawable/search"
android:layout_x="37px"
android:layout_y="279px"
>
</ImageButton>
</AbsoluteLayout>
AndroidManifest.xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="ht ... android"
package="swz.pkg"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="%drawable/icon" android:label="%string/app_name">
<activity android:name=".SWMainActivity"
android:label="%string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ClosetSearchAct" android:label="%string/app_name"> </activity>
</application>
</manifest>
What does that mean ?! Here is the full error I get when submitting my proggy to the market;
ERRORS;
error#1- Market requires versionCode to be set to a positive 32-bit integer in AndroidManifest.xml
error#2- Market requires versionName to be set in AndroidManifest.xml
<><><><><><><><>
My Manifest; ( I replaced my app info with gen info for the forum)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mydomain.myapp"
android:versionCode="1"
android:versionName="1">
<uses-sdk android:minSdkVersion="7" />
<uses-sdk android:targetSdkVersion="8" />
<uses-sdk android:maxSdkVersion="9" />
<activity android:name=".myapp"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape">
<application android:label="@string/myapp" android:icon="@drawable/myicon">
<uses-feature android:name="android.hardware.touchscreen" android:required="true"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.wifi" android:required="false"/>
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="false"/>
<uses-feature android:name="android.hardware.location.gps" android:required="false"/>
<uses-feature android:name="android.hardware.bluetooth" android:required="false"/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</application>
</activity>
</manifest>
<><><><><>
Any help would be wonderful, thanks taking the time to read this post
hey,
i'm trying to make an app in android studio and get some errors in my androidmanifest.xml when using inspect code.
This is my first app and i'm sure i missed something essential...pls help
My xml file looks like this:
<manifest xmlns:android="...."
android:versionCode="1"
android:versionName="1.0"
package="com.standby.custom">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18"/>
<supports-screens
android:anyDensity="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:resizeable="true"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.BROADCAST_STICKY"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<application
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity" android:launchMode="singleInstance" android:hardwareAccelerated="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".DeviceStateReceiver" />
<service android:name="com.standby.custom.services.ReceiverRegisterService" />
<receiver android:name=".PackageChangeReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" androidath="com.standby.custom" />
</intent-filter>
</receiver>
<receiver android:name=".BootUpReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
and i get this error messages:
Cannot resolve symbol '.MainActivity' (at line 34)
Cannot resolve symbol '.DeviceStateReceiver' (at line 40)
Cannot resolve symbol 'com.standby.custom.services.ReceiverRegisterService' (at line 41)
Cannot resolve symbol '.PackageChangeReceiver' (at line 42)
Cannot resolve symbol '.BootUpReceiver' (at line 50)
Does anyone know what I missed?
Tks
First of all, please use
Code:
tags for your code.
Is this the right package all of your classes can be found in?
[CODE]package="com.standby.custom"
Try to enter the full package name for all android:name attributes. Like this:
Code:
android:name="my.package.name.MainActivity"
(replace my.package.name by the package MainActivity is in.)
Hi, I am new in xda-developers forum. I have written my first simple application which uses GPS. Now I want to use Google Maps. Is problem because it want apiKey. My apiKey is in Google Code Api's Console. There is Android apps:
8A5:....:72:88:AE;com.borneq.heregpslocation and ApiKey : AIzaSyCh0XWRIXaTizxYcnWO8K7eFLZEysfGJvM (it is public or private?)
I modified three file to do with maps:
* AndroidManifest.xml:
Code:
<permission
android:name="com.borneq.heregpslocation.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.borneq.heregpslocation.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" />
Code:
<uses-library android:name="com.google.android.maps" />
Code:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCh0XWRIXaTizxYcnWO8K7eFLZEysfGJvM" />
Second file is activity_main.xml :
Code:
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="AIzaSyCh0XWRIXaTizxYcnWO8K7eFLZEysfGJvM"
android:clickable="true" />
Third is .MainActivity.java :
import com.google.android.maps.MapActivity;
public class MainActivity extends MapActivity implements OnClickListener {
Click to expand...
Click to collapse
Previously used controls I commnted
Project compiles but application breaks at start. I attach source: zipped program and logCat
Thanks!
The app crashs in line 77 of MainActivity. It's a NullPointerException.
Code:
boolean isGps = locationManager.isProviderEnabled("gps");
The reason for the crash is that in onCreate you commented this line out:
Code:
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Due to this the variable locationManager is null and it crashes later because it cannot handle a null value. Just uncomment the line from onCreate which I pasted above. That's it.
How did I know that? It's in the logcat:
Code:
Caused by: java.lang.[B]NullPointerException[/B]
at com.borneq.heregpslocation.MainActivity.setButtonState([B]MainActivity.java:77[/B])
This guide might help you understand logcats (focus on that part of the guide): [GUIDE] Debugging apps You'll definitely need that knowledge if you want to do serious Android development. The earlier you learn it the better. Good luck.
nikwen said:
The app crashs in line 77 of MainActivity. It's a NullPointerException.
Code:
boolean isGps = locationManager.isProviderEnabled("gps");
The reason for the crash is that in onCreate you commented this line out:
Code:
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Click to expand...
Click to collapse
Thanks, I remove by comment old controls and not noticed that comment also locationManager (!)
I correct; removed reference to commented controls and I don't have error but I can't see maps
Is "class MainActivity extends MapActivity" but np map, only lattice