I have created a simple app which shows a Google Map. I am testing it on a HTC Desire S and I am using only WiFi network behind a proxy. But it is not showing anything, only map tile are shown in the screen. Even the default map application is not working. It shows the error message that
"Network Failure : wrong remote string version.GMM server must be hosting:/ string_remote_no-remote-strings."
My Map API key is correct and I have added the following permissions in the manifest file:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
How do I solve this problem?
Are you sure
you extended MapActivity?
your API Key is correct?
Apparently if you are using a proxy, and have set that in your APN, then your AVD cannot load any application that is using the map, neither the pre-installed one, nor any created by you.
Check http://code.google.com/p/android/issues/detail?id=3764#makechanges
Related
I am trying to show a live preview of the rear facing camera in Codename One. I use for that the native interface (I am targetting Android first).
To allow my app to use the camera without messing up with build hints, I added these lines in my Main Form :
if (Capture.hasCamera()){
Dialog.show("Appareil photo détecté", "Votre matériel est bien équipé d'un appareil photo!", "OK", null);
}
I did that because Codename One blog stated
android.hardware.camera & android.permission.RECORD_AUDIO - are triggered by com.codename1.Capture
However while debugging the app with the sources I got from CN1 under Android Studio on a real device (API LEVEL 19 aka Kit Kat) I always got a java.lang.RuntimeException: Fail to connect to camera service.
After a while I realized that the exception was due to the lack of the following permission in manifest.xml :
<uses-permission android:name="android.permission.CAMERA" android:required="false"/>
Please note that as stated in CN1 blog the line <uses-feature android:name="android.hardware.camera" android:required="false" /> was already added by CN1.
Now that I've added this line the live preview is well shown.
Why is this permission not automatically added in the manifest, should I really add it to the build hint ?
Moreover I have another project that uses the Camera to take photo and save them on the phone and the Camera permission is neither shown (in Android Application Info) nor requested during app installation whereas it works perfectly well. Please note that e.g. Twitter App shows "Take photos and record videos" in the app permissions so it does not seem to be a problem with my phone hiding camera permission.
EDIT November 20th 2016 :
Indeed Android Developer's guide states that
Note: If you are using the camera by invoking an existing camera app, your application does not need to request this permission.
That's why CN1 does not require this permission!
Thanks for helping me getting the permission management with CN1 right.
You need to add the following build hint:
android.xpermissions=<uses-permission android:name="android.permission.CAMERA" android:required="false"/>
You can also add this to the cn1lib so it is injected automatically.
In the past, you add the permission you want to your manifest and then it is requested when your user attempts to install your app. As of Android 6.0+, this has changed. Now you can just request a permission when your app needs it for the first time. After the user grants you permission, you don't need to ask again next time. Some benefits of this include keeping your user aware of why you need specific permissions and not requesting permissions that you don't actually need.
You can read more about how to implement it here: https://developer.android.com/training/permissions/requesting.html
There is no way to use a phones camera without asking for permission at some point.
I cannot get Google Maps to work on my app.
I see a blank screen; no grids show, only the google logo and the +/- zoom buttons.
What I have done:
I have the "Google Maps Android API v2" API enabled
I have added my project along with the demo project to the API credential list on Google console
I've also added the required permissions for Internet, location, com.google.android.providers.gsf.permission.READ_GSERVICES.
Even added the "MAPS_RECEIVE" permission as some posts suggested
Also added the 'meta-data' google_play_services_version
Since the demos are working, I literally copied MultiMapDemoActivity and its files into my project and tried opening map, to no avail.
The problem may be linked to this issue. However, it seems like they can't get map to work at all.
Here is the interesting bit that I noticed, I usually get this:
10-02 12:29:20.376: D/REQUEST(5826): Connection opened to:https://clients4.google.com/glm/mmap/api
10-02 12:29:20.376: D/REQUEST(5826): Open Connection
Followed by this:
10-02 12:21:45.361: D/REQUEST(5826): DRD(80): 62|132
10-02 12:21:45.361: D/REQUEST(5826): Close
10-02 12:21:45.361: D/REQUEST(5826): Error processing: com.google.maps.api.android.lib6.b.d#42caa7b8 not retrying
10-02 12:21:45.361: D/REQUEST(5826): Retrying: com.google.maps.api.android.lib6.gmm6.c.a#4296a530
Also, not sure if this is relevant, but as soon as I click to open the map, or click on the map after it has opened and is showing a blank view, I see this:
10-02 13:03:32.978: E/DatabaseUtils(15468): Writing exception to parcel
10-02 13:03:32.978:/DatabaseUtils(15468): java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this
requires android.permission.INTERACT_ACROSS_USERS_FULL
EDIT #1
<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.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
EDIT #2
Also, the declared package name was com.A.B.C (the manifest); whereas the activities of my project had the structure of com.A.B..
I have since updated my project structure to match that of the manifest, but I still see the same errors as before, nothing changes. I'm really at sea here, since I cannot understand what could be going wrong here.
Some help to resolve this will be appreciated, thanks!
It turns out that I had read n-1 questions regarding this issue here. Finally, after continuous searching everywhere, I stumbled upon the answer here by #Jack.
Basically the line:"HttpsURLConnection.setDefaultSSLSocketFactory(...)" was the culprit in my code. I commented it out and everything worked fine.
NOTE: I have not tried to keep the line of code and modify it to make maps work yet. If I need/do it, I'll post a comment.
You need to add your SHA1 fingerprint to the public API access.
Go to eclipse > preferences. Android > build and copy your default eclipse SHA1 fingerprint.
Now go to https://console.developers.google.com select your app, 'APIs and auth' > 'credentials' > and click on 'Edit allowed android applications' put your SHA1 figerfirnt like that:
XX:XX:XX:XX:XX...XX;com.your.pakage.app
What about your google key? This line in the Manifest file:
<meta-data android:name="com.google.android.maps.v2.API_KEY"
....
I am also struggling with such behavior constantly. The first thing you want to verify in such situations is that your key from debug.keystore file is indeed the one that you registered with Google. This key will be used when you are debugging your application locally.
Note, however, you will need another keystore file when you release your application. At the time of signing, you should create another keystore, and register it too with Google.
I had this problem too and it took me so much hours to resolve it, at last I've done these steps and it worked finally!
Do the same steps as it followed here https://developers.google.com/maps/documentation/android/start
Use the debug certificate fingerprint if you're testing your project instead of the release certificate which you use when you install your app in the play store.
Don't forget to add the value of the Google API and replace the "API_VALUE" with it.
Change your project build target into Google APIs: Project>properties>android>target.
Hope this helps..
These are the permissions you need according to Google documentation:
<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"/>
<!-- 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"/>
I recommend you to include this too:
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
Add those in your manifest file
<permission
android:name="xxx.xxxx.xxxx.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="xxx.xxxx.xxxx.permission.MAPS_RECEIVE" />
<uses-permission android:name="xxx.xxxx.xxxx.permission.READ_GSERVICES" />
replace xxx.xxxx.xxxx with your package name
I’m using the osmdroid library to use openstreetmaps in my android application, but I’m unable to load the maps on-line, using wifi.
If I make de manual download of the maps (mbtiles file) and place it in the osmdroid filder in the device it works fine and they are loaded by my application, but if I want that my application loads the maps from the web in real time it doesn´t work and the maps are not loaded.
In Logcat I get the following warning:
"Problem downloading Maptile: /4/8/8 HTTP/1.1 403 Forbiden"
I have the following permissions in Manifest:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
This is the code I use to load the maps with the osmdoid:
myOpenMapView = (MapView)findViewById(R.id.openmapview);
myOpenMapView.setBuiltInZoomControls(true);
myMapController = myOpenMapView.getController();
myMapController.setZoom(4);
Can anyone help me?
Thanks
The issue mentionned by LordRaydenMK has been fixed in osmdroid 4.1.
So if this is the issue you have, you just have to update your osmdroid lib to the latest version.
The default Apache HttpClient user-agent was recently banned from accessing tile.openstreetmap.org (server returns 403). As a result,
the Mapnik provider is no longer serving any tiles for osmdroid.
OpenStreetMap's tile usage policy (
http://wiki.openstreetmap.org/wiki/Tile_usage_policy ) says that a
"Valid User-Agent identifying application" must be sent. The current
user-agent osmdroid sends when it downloads a tile is
"Apache-HttpClient/UNAVAILABLE (java 1.4)" which is pretty generic.
I've created a patch that will send a user-agent that is more
compliant with OSM's tile usage policy. The new user-agent is
"osmdroid ([package name])" where [package name] is the package name
of the application using osmdroid.
The patch can be found here: http://pastebin.com/kxBh1gQ5
The patch is not very pretty, but it does its job.
Source: https://code.google.com/p/osmdroid/issues/detail?id=515
I want to display three pin points in the mapview and i had checked the internet connections in the emulator and even i had used the key for displaying mapview but it's showing error couldn't get connection factory client.
Basic info for displaying map in your Android Application.
1. Your application build platform is Google-Api not Android-Api.
2. put <uses-library android:name="com.google.android.maps" /> in Application tag in
Android manifest file.
3. Your mapview activity must extend MapActivity.
4. You have a your system specific map-key for debug version of application.
Try to add these two Permissions also.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
It can be because of Map getting Zoom it. And you can refer to this LINK.
i'm very new to android devolopment
i tried to run the sample project given in this example
http://code.google.com/p/google-api-java-client/source/browse/tasks-android-sample/src/main/java/com/google/api/services/samples/tasks/android/TasksSample.java?repo=samples
but when i run it, it gives a force close error. after a messing around i figure that it has only list activity not activity class as others. why? how to fix it?
. my idea is to create a android software which i can push tasks from the server to the app then the app will add those as tasks in the phone? any sample apps like that?
Maybe you forgot to set the permission for Oauth?
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
New Task sample required Google Play Service Library to run you need to set up it and added into build path of your application.