I'm triying to show a map in my app with the new api but all what i get is:
"Uknown issue with Google Play Services"
This is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.monitoringsensors"
android:versionCode="1"
android:versionName="1.0"
>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16"/>
<uses-permission android:name="android.permission.INTERNET"/>
<permission
android:name="com.example.monitoringsensors.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.monitoringsensors.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"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<activity
android:name="com.example.monitoringsensors.Title"
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="com.example.monitoringsensors.HttpExample"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.HTTPEXAMPLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.monitoringsensors.TakeSomeData"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog">
<intent-filter>
<action android:name="android.intent.action.TAKESOMEDATA" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCW3iv83siHrkWM6Q2qV4YcXk27CZWwmqc"></meta-data>
</application>
</manifest>
And this is the XML file:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
And the class is called like this:
public class HttpExample extends android.support.v4.app.FragmentActivity {...}
Thank you mates!
you need to verify map availability
Before you can interact with a GoogleMap object, you will need to confirm that an object can be instantiated, and that the Google Play services components are correctly installed on the target device. You can verify that the GoogleMap is available by calling the MapFragment.getMap() orMapView.getMap() methods and checking that the returned object is not null.
https://developers.google.com/maps/documentation/android/map#verify_map_availability
I personally use this code to check for Google Play Services, I test on both a real device running 2.3.3 and emulators on various versions of the OS, it prevents the emulators from breaking since they don't come with the updated Google Play Services that enables v2 of the Android Google Maps.
protected boolean readyToGo() {
String TAG_ERROR_DIALOG_FRAGMENT="errorDialog";
int status= GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (status == ConnectionResult.SUCCESS) {
return(true);
}
else if (GooglePlayServicesUtil.isUserRecoverableError(status)) {
ErrorDialogFragment.newInstance(status)
.show(getSupportFragmentManager(),
TAG_ERROR_DIALOG_FRAGMENT);
}
else {
Toast.makeText(this, "no maps", Toast.LENGTH_LONG).show();
finish();
}
return(false);
}
It returns true if it's able to display the map, meaning the device has the required Google Play Services, or false if it does not, which is the case for the standard emulators in Eclipse and such right now.
Related
I have a tts & gps application with google api, display a map and markers on map.
when i run this app on emulator, the app works as expected but not works well in my phone with apk
I think there's a problem with the api version, but I don't know what to do.
here's my code and i attached this image which not working on my phone
if press the button the marker show my location
enter image description here
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.codingflow.texttospeechexample"
>
<permission android:name="wonpa.alwaysweb.com.myloctest.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="wonpa.alwaysweb.com.myloctest.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
enter code here
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.TextToSpeech">
<uses-library android:name="com.google.android.maps" />
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my api key" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<queries>
<intent>
<action android:name="android.intent.action.TTS_SERVICE" />
</intent>
</queries>
</manifest>
I'm sorry if i show unnessary code
Is there a problem if you install the application on your device directly from Android Studio via a USB Debugging mode? If not, then the problem is with generating a signed APK for your device.
Also you need to secure your API key first: Using API Keys.
Take out the API KEY in string resources like that
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
I know this topics already have posted. But I am not success for this work.I can not run google map v2 in emulator. Now I am trying BlueStack. When I run BlueStack then it show Get Google Play Service. What I do please tell me.How I can run google map v2 successfully.
My AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.gmapdemon"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="17" />
<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"/>
<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"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="MY_KEYandroid"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"
/>
<activity
android:name="com.example.gmapdemon.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>
Create an emulator from genymotion that supports google map api. You can look this up.
Find a download for the app store that will run on your emulator. I found mine here: http://wiki.rootzwiki.com/Google_Apps#Universal_Packages_2... I was using the 4.2.2 version.
Drag and drop that into your emulator. I am using google nexus.
Say ok to the prompts.
Once everything is installed close down the emulator and restart.
sign up with a good account.
Voilà
Is it possible to run the android map activity on the emulator? because I'm getting the error "this app won't run unless you update the Google play services"
My code is as follows :
MainActivity.java
package com.example.googlev2map;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle arg0) {
// TODO Auto-generated method stub
super.onCreate(arg0);
setContentView(R.layout.activity_main);
} }
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"
tools:context=".MainActivity" >
<fragment
android:id="#+id/fragment1"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
Androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlev2map"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.example.googlev2map.permission.MAPS_RECEIVE"
android:protectionLevel="signature"></permission>
<uses-permission
android:name="com.example.googlev2map.permission.MAPS_RECEIVE"/>
<uses-permission
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission
android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.googlev2map.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="AIzaSyAy2ThskwG3Q9ArpZR_GvJP5_5IWfcEJhU"/>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version">
</meta-data>
<uses-library
android:name="com.google.android.maps"
android:required="true" />
</application>
</manifest>
this app wont run unless you update the Google play services
Google map requires google play services.
To test your app when using the Google Play services SDK, you must use either:
A compatible Android device that runs Android 2.3 or higher and includes Google Play Store.
The Android emulator with an AVD that runs the Google APIs platform based on Android 4.2.2 or higher.
So if you still get the message "this app wont run unless you update the Google play services" it is clear that the device on which you are trying to run does not have google play services installed. So you need to test on a real device that has google play servies installed
I have a "little" app on market, and uploaded a new version of it, but when I upload the apk this message appears:
This setting can not be published for the following reasons:
The version 2 is not available on any device configuration: every device that can receive version 2 receives version 3.
and the state of the 3rd version is "draft in final phase"
How can i fix it?
I put the Manifest if can be helpfull
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.shudy.lightson"
android:versionCode="3"
android:versionName="1.1.1" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:debuggable="false"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.shudy.lightson.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>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize">
<meta-data android:value="aXXXXXXXXXXX2" android:name="ADMOB_PUBLISHER_ID" />
</activity>
</application>
</manifest>
It's all good. This is how Google Play works. It's just saying that the new version will work for all the devices that are support by older versions. So the old version is obsolete and should be deactivated.
Deactivate the old version and all will be fine.
When Im starting my AVD emulator from within Android studio the list of devices in the emuator shows that some of my devices are not compatible with the current project.
It doesn´t show what is not compatible. Is there any way to get to know that?
My first guess was conflicting API versions. But that seems not to be the case sice several AVD:s have the same api settings and some are compatible and others not.
This is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example"
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" >
<activity
android:name="com.example.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>
<service
android:name=".SetLocation"
android:label="SetLocation"/>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
</manifest>
And a screenshot of the list:
maybe if your applications are written for lover API version that device that you will use for testing. Can you run the application in emulator?