android application crashes with no errors - android

i am trying out an android map application, when i run it there are no errors or problems in the code, i use my samsung galaxy s3 to test it but it keeps on displaying >"Unfortunately, maps has stopped".
Here's my java file
package com.maps;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
public class Main extends MapActivity {
MapView map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = (MapView) findViewById(R.id.mvMain);
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Here is my xml code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="AIzaSyAfv657yXaBMlBLAe2pw0VyJiPLiczDG7E"
android:id="#+id/mvMain"/>
</LinearLayout>
Here is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.maps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
/>
<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.maps.Main"
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>

A crash when using maps is often due to a bad API key. Double check that the key you are using is valid

Try to use Google Maps v2 for Android.
Here you have a good tutorial.
Anyway, your problem seems to be with the API key.

If GOOGLE API is not valid it will not show map that's it .
Why don't you attach your manifest.xml file so that we can rectify your error.
Otherwise check manifest file whether it contains reference of GOOGLEapi or not.

Related

How to embed map into our android application?

I was tried to embed google map into my android application. When I executed the application it display as below
could anyone help with this?. and my source code .
public class MainActivity extends MapActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
protected boolean isRouteDisplayed() {
return false;
}
}
Here is my Manifest.xml file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<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.mapp.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>
You have just tried to develop with deprecated Google Maps Android API v1. This will not work for any new project since March.
Delete all the maps related code (seriously, this is the easiest path) and follow this https://developers.google.com/maps/documentation/android/start to use new Google Maps Android API v2.

when app is run on phone (installed from bin folder's .apk file), grey tiled screen is displayed

I installed apk on my android phone using the apk from bin folder, when i run the app on eclipse(phone is connected) it runs on phone but only grey tiles are displayed. wht to do?
MainActivity.java
package com.example.lbs;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import com.google.android.maps.MapActivity;
public class MainActivity extends MapActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#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;
}
}
LBS manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lbs"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<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.lbs.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCROYDMk81v3LCsQShUnMjnezyshJAvJdY"/>
</application>
<permission
android:name="com.example.lbs.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>"
</manifest>
activity_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" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<com.google.android.maps.MapView
android:id="#+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="AIzaSyCROYDMk81v3LCsQShUnMjnezyshJAvJdY" />
</RelativeLayout>
What certificate was used to sign the APK? Make sure you've added the fingerprint for your debug certificate as well as your release certificate when generating your API key. See more instructions here:
https://developers.google.com/maps/documentation/android/start
Ok...so i had made the following mistakes:
1) I had used Mapview, which I then Changed to fragment view. Thanx to #Gabe Sechan for informing that
an example is Simple android program using GOOGLE MAP API
2)When i was importing google play services, I didnt import it into my workspace, which led to error
to fix such error:- Google Maps Can't add reference to Play Services
Best Link for newbies using google maps api v2: http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/

Android app not starting, probably the android manifest

i want to make my own app, and i just very simply want to start it up. but for some reason i cant make it work on my emulator. I have no error messages so i don't know what is wrong :S Sorry im a novic in programming and i could not find anything that would help me. Thanks !
here are my codes:
xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="#+id/BBG"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Big Bang Theory" />
<Button
android:id="#+id/HIMYM"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="How I Met Your Mother" />
</LinearLayout>
android manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.watchserie"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Menu"
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>
menu java file:
package watchserie.niels;
import com.example.watchserie.R;
import android.app.Activity;
import android.os.Bundle;
public class Menu extends Activity {
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
}
}
Your package names don't match. You Java file is in the watchserie.niels package, while your manifest uses com.example.watchserie. As you're using a dot before the Activity name, it instructs that the package name be automatically added to it. Due to this, you're telling Android that your Activity is: com.example.watchserie.Menu, while in reality it is watchserie.niels.Menu
To fix it, change:
package="com.example.watchserie"
to
package="watchserie.niels"
And remove the following line from your Java file:
import com.example.watchserie.R;
EDIT You could change it the other way around too, but Google Play (and other app stores too I guess) will not allow you to upload any app using the com.example.* namespace. Because of this, I suggested you choose the package without com.example in it.

Android google maps get error Couldn't get connection factory client

Android google maps get error Couldn't get connection factory client, I have get apikey from here, this is my code:
MainActivity.java
package com.haichal.map;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
public class MainActivity extends MapActivity
{
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
#Override
protected boolean isRouteDisplayed() {
return false;
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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:enabled="true"
android:clickable="true"
android:apiKey="0IbdGeqd17e6zbTdNfSze2pEt1jJzEEPoOM0jZw"
/>
</RelativeLayout>
Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.haichal.map"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
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=".MainActivity"
android:label="#string/title_app" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And in android project target, I using Google Apis, platform 4.1.2, Api level 16.
In my eclipse project no get error(no red ballon), I debug and install success, but when I run apps, maps just get blank grid, not get maps, if I look in log cat I get message error Couldn't get connection factory client.
How to solved my problem?
when i run apps, maps just get blank grid, not get maps
Either your device does not have Internet access (at least to the Google Maps server), or your API key is wrong. Another possibility would be that you lack the INTERNET permission, but it appears that you have that already.
if i look in log cat i get message error Couldn't get connection factory client
That message happens all of the time, even when your app works.

Google Maps API in Android--using a proxy server

I am trying to develop a simple app using Google maps.
While running the app i can see only the grid and the map controls.
I did obtain an API key and included it into main.xml file.
The permissions for the internet was also granted in the androidmanifest.xml.
My browser in avd is connecting to internet and when i run the native map app in the avd, it shows the following error.
**Network Failure ... Wrong remote strings version.GMM Server must be hosting:/strings_remote_533149424.dat**
GoogleMapActivity.java
package com.example.googlemap;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class GoogleMapActivity extends MapActivity
{
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}
#Override
protected boolean isRouteDisplayed()
{
return false;
}
}
main.xml
<?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="0kuSQz9hsxal-_JpKGJbFp__zLqhl5d4gG3ohDg"
/>
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlemap"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".GoogleMapActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</application>
</manifest>
I'm using a proxy to connect to the internet.
Can anyone plz help me out with this..plz help me!!
As far as I know about GoogleMaps, there are no indications in manuals if the proxy could matter in displaying maps. If you got the map controls and the GoogleMap grid, this means that you have been connected to the map server but map tiles permissions were denied to you. What to do:
1. Check it if you got the DEBUG key or the Release key
2. Use the Debug key if you are testing locally with the "apk" downloaded from your PC
3. Use the Release key if you are debugging your "apk" downloaded from the Android market
It looks like you are stumbling upon one of the upper bottle-necks.
If these indications did not work, show your settings and source code on this forum for others to react appropriately.
Did you set this permision in manifest: android.permission.ACCESS_FINE_LOCATION, android.permission.ACCESS_COARSE_LOCATION and in aplication ???
I revisited your question and found 2 possible flaws.
Rewrite your manifest file as follows. USES-PERMISSION tags should be out of the APPLICATION tags.
Possibly, you may have been using a wrong debug-key. Please, generate an new debug-key according to manuals to use with this application on development PC.
If the problem persists, please update your development environment to the latest and test again.
Your rewritten manifest.xml should look like the following:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlemap"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".GoogleMapActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Categories

Resources