Accessing google maps in android emulator - java

i am developing an android application using google maps data.I can access google maps in emulator but when i try the same in my application the google maps is not opening .What is the problem?Help

Sounds like your not using the Google API in the emulator:
http://code.google.com/android/add-ons/google-apis/
You need to create an Android Virtual Device (AVD) with the google API:
In the above screenshot you can see that 'test_avd' does not use the google API.
Also you can see 'test_maps_avd' does use the google API.

First of all I would try doing this example.
Check that your manifest has:
<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.INTERNET" />
Also remember that your view should have something like this:
<com.google.android.maps.MapView
android:id="#+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="Your Maps API Key"
/>
You can get your map key from here.

Related

Google Play Services Library Error in OneSignal, why?

i did add OneSignal based on the documentation in my application.
Everything works for me.
However, I can't send notifications to some devices because it says: Google Play Services Library Error (image included)
What I've already tried:
I created a new project in OneSignal (new app id)
the AndroidManifest.xml file contains:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<meta-data android:name="com.onesignal.NotificationOpened.DEFAULT" android:value="DISABLE" />
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
I don't know what to do now.... :(
Google Play Services Library Error
UPDATE:
only appears on some devices, on first start-up.
Error message:
E / OneSignal: Error Getting FCM Tokenjava.io.IOException: AUTHENTICATION_FAILED
If you reopen the application, the error will disappear.
Try removing and recompiling the application

Cannot detect location on emulator, Android Studios

I have forked an Android application on Github (https://github.com/android/location-samples/tree/master/BasicLocation) which demonstrates use of Google Play services Location API to get the last known location for a device.
However, when I try and run the application, I receive a Toast message that states "No location detected. Make sure location is enabled on the device."
I have added the following permissions to the Manifest:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
In addition, the Extended controls of the emulator reads my current lat/long coordinates
I was wondering how I can resolve this issue.
Run the google map app and give it all the permissions and after the map show start your app.
check this one for more inf.
Emulator's Location simulation not working

Android Google Maps authorization failure

I have reviewed all similar questions regarding Google Maps authorization failure but it did not help.
Google Maps Api v2 is enabled and correct.
Android Keys for Debug and Release builds are correct and their corresponding validation Package Names and Fingerprints are correct.
Now, the first strange thing is that Google Maps had been working perfectly for 1 and a half years and we did not register any errors until 23 May 2016.
We did not change anything in Google Dev Console or in Application that would be a threat to Google Maps functionality.
The second strange thing is that this error only occurs on Release builds and Debug builds are working fine. With this in mind I tried to generate another Android Key for maps (without package/fingerprint validation) but it did not help.
Android Manifest contains these permissions:
com.google.android.providers.gsf.permission.READ_GSERVICES
ACCESS_COARSE_LOCATION
ACCESS_FINE_LOCATION
INTERNET
ACCESS_NETWORK_STATE
WRITE_EXTERNAL_STORAGE
We also use:
<uses-feature
android:glEsVersion="0x00020000"
android:required="false" />
Play Services Maps API:
compile 'com.google.android.gms:play-services-maps:6.5.87'
Yes, this API is quite old but updating it to 8.4.0 did not help either.
Google Maps authorization failure we're getting:
E/Google Maps Android API﹕ Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
07-27 14:52:37.551 25002-25035/com.package.name E/Google Maps Android API﹕ In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: ******************************
Android Application (<cert_fingerprint>;<package_name>): finger:print;com.package.name
If someone had any ideas on where or why such a problem could suddenly happen I would be more than happy with any help.
Thank you.
Try to use updated google map api
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
and check whether you had used these permission in app
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="com.example.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
and used these meta tag within application
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/application_id" />
// as unauthorized occurs just because of invalid app id which created on google developer console

java.lang.SecurityException: BLUETOOTH permission crash. (Samsung devices only)

I'm getting the following crash, but this only occurs on some Samsung devices (not all, we develop/test on Samsung devices)
Crash log:
java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10025 nor current process has android.permission.BLUETOOTH.
at android.os.Parcel.readException(Parcel.java:1540)
at android.os.Parcel.readException(Parcel.java:1493)
at android.bluetooth.IBluetooth$Stub$Proxy.isEnabled(IBluetooth.java:1156)
at android.bluetooth.BluetoothAdapter.isEnabled(BluetoothAdapter.java:697)
at org.altbeacon.beacon.service.scanner.CycledLeScanner.finishScanCycle(CycledLeScanner.java:245)
at org.altbeacon.beacon.service.scanner.CycledLeScanner.scheduleScanCycleStop(CycledLeScanner.java:234)
at org.altbeacon.beacon.service.scanner.CycledLeScanner$1.run(CycledLeScanner.java:230)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5972)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Here's my AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.myapp" >
<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="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<!--
The following two permissions are not required to use Google Maps Android API v2,
but are recommended. We also require them for location updates.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<permission
android:name=".permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name=".permission.C2D_MESSAGE" />
<application
android:name=".myapp"
android:allowBackup="true"
android:icon="#drawable/appicon"
android:label="#string/app_name"
android:logo="#drawable/action_bar_pinwheel_back"
android:theme="#style/AppTheme" >
<activity
android:name=".activities.VerifyPinActivity"
android:label="#string/title_activity_verify_pin"
android:screenOrientation="portrait"
android:theme="#style/NoActionBarDark"
android:windowSoftInputMode="stateVisible|adjustPan" >
</activity>
...(more activities here removed)
</application>
</manifest>
I really have no idea why it only occurs on a few devices; my initial guess is it has something to do with Samsung KNOX, and the (few) users that are crashing are KNOX users with a phone policy to disable Bluetooth.
Has anyone else run into this? Or does anyone have any idea what this might be?
If you are sure the users met this problems only on Samsung KNOX,the following answer maybe will help you.
Thinking step by step is the way to solve your problem.
1.This only occurs on some Samsung devices.
So, it has nothing to do with your code,also the permission.There is
something wrong with the Samsung devices.
2.Check the crash log:
java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10025 nor current process has android.permission.BLUETOOTH.
According to the experience,if you have met the log like "Neither user
**** nor current process has *** permission.",this means that your app doesn't have the permission to do something in the system.This occurs
often on that you do something need the system level permission.
If you are installed as system level app together with customized Android ROM,or you signed your app with the platform.x509.pem and platform.pk8 file of the customized Android ROM,and then you can have the permission.
Now check what is Samsung KNOX:
Samsung Knox (stylized Samsung KNOX) is an enterprise mobile security solution.
Bluetooth is one kind of data transmission way to the other's
device.This will cause the security problem.
Check the offical website:
https://www.samsungknox.com
Search the key words 'Bluetooth',and we found this:
https://www.samsungknox.com/en/faq/are-bluetooth-bluetooth-low-energy-and-nfc-available-inside-knox-container
KNOX 2.4+ — Bluetooth, Bluetooth Low Energy (GATT), and NFC are supported inside the KNOX container.
KNOX 2.3 or below — Bluetooth, Bluetooth GATT, and NFC aren't supported inside the KNOX container. If the device is connected to a peripheral (e.g. headphones) in the personal space, Bluetooth will remain connected, even if the user enters the KNOX container. Apps inside the KNOX container can't initiate a Bluetooth connection.
1.If your users are using KNOX 2.3 or below,and they can update their OS of device to KNOX 2.4+.tell your users who use Samsung
KNOX update their OS of device.
2.If your users are using KNOX 2.3 or below,and they can't update their OS of device to KNOX 2.4+.your app will not work under this
situation,the problem is not the problem,what you can do is only tell
uses that:the OS of your device doesn't support Bluetooth,so it's not
working.
3.If the above will not help you, you can contact with Samsung KNOX Official
Another tip:
To improve your user experience of your app, you need to prevent your app to be crashed.
Crashed is the worst user experience.
If you can not solve the problem,you can do this:
try{
You code related with Bluetooth.
}catch (Exception e)
{
}
Remember:The offical always helps you to solve the problems better!
You can look here. I'd guess this is your problem.
Are Bluetooth, Bluetooth Low Energy, and NFC available inside the KNOX container?
KNOX 2.4+ — Bluetooth, Bluetooth Low Energy (GATT), and NFC are supported inside the KNOX container.
KNOX 2.3 or below — Bluetooth, Bluetooth GATT, and NFC aren't supported inside the KNOX container. If the device is connected to a peripheral (e.g. headphones) in the personal space, Bluetooth will remain connected, even if the user enters the KNOX container. Apps inside the KNOX container can't initiate a Bluetooth connection.
I never had any hands-on experience with this, but I hope this helps.
try to add below to your manifest
<uses-feature android:name="android.hardware.bluetooth" android:required="true" />
From SDK 23 onward you need to check the permission for bluetooth in case required.
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (mContext.checkSelfPermission(Manifest.permission.BLUETOOTH) == PackageManager.PERMISSION_GRANTED) {
//TODO - Do the work
}
}
From KNOX Premium v1.1 onwards, Samsung no longer needs to sign third-party app (APK) files so that they can run inside KNOX containers. Instead, the appropriate permissions are granted at runtime, after an app activates its ELM and KLM licenses successfully. for more info see this

Google Maps won't appear on Android Device

So I was trying to implements make a simple Google Map application for Android and the maps didn't show. All I see is grey screen. And I get these error message from LogCat
05-27 22:04:24.569: E/dalvikvm(12361): No free temp registers
05-27 22:04:24.569: E/dalvikvm(12361): Jit: aborting trace compilation, reverting to interpreter
05-27 22:04:32.869: E/AndroidRuntime(7051): /system/csc/feature.xml ==> cannot open file
05-27 22:04:33.699: E/AndroidRuntime(7064): /system/csc/feature.xml ==> cannot open file
05-27 22:04:34.369: E/AxT9IME(12326): setEditorType() - restarting : false
05-27 22:04:34.369: E/AxT9IME(12326): mRestartRequested : false
05-27 22:04:34.369: E/AxT9IME(12326): mIsScreenLocked : false
05-27 22:04:34.369: E/Vivek(12326): mInputLanguage = 429
thanks in advance :)
This problem is usually derived from a problem in referencing google-play-service library.
Take a look at this blog post I wrote on how to integrate Google Maps in your application, especially the first 3 steps:
Google Maps API V2
another cause of this could be that you haven't configured the Google API Console properly, so I suggest you to take a look at this guide as well:
Google Maps API V2 Key
another reason that may cause this is if you have some kind of problem in your permissions in the manifest file. You can look at the first guide for the needed permissions as well.
Did you have this in your AndroidManifest.xml
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="<key here>" />
About the value, I think you can have quick search on google and you can know it.
Normally, if you are developing, it'll use the debug.keystore
%USERPROFILE%\.android\debug.keystore
Please also check if in your AndroidManifest have this:
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="<your_package>.permission.MAPS_RECEIVE" />
And this:
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />

Categories