This issue is common BUT I didn't find a solution on google, or stackoverflow (4days of research...)
Here is the thing :
I need to display a full screen google map, which i ve already done several times in other application i've developped.
BUT here i can't get it to work for an unknow reason !
The warning and the error i get when i open the SherlockFragmentActivity which contains the map :
The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
Here i'll explain how i did things in detail and post some code :
LIBRARY IMPORT :
Last version of Google play services imported in eclipse as library (checked)
In the project the google play services are imported as library in properties (like ABS)
MANIFEST :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pck name"
android:versionCode="1"
android:versionName="1.0" >
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<permission
android:name="com.company.pckgname.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<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_NETWORK_STATE" />
<!-- LOCATION -->
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:name="app variable name"
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/Theme.Styleapp" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="api key" />
<activity
android:name=".ActivityLauncher"
android:configChanges="orientation|screenSize"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/Theme.Sherlock.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
... activities...
</application>
</manifest>
MAP LAYOUT :
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/map"
android:name="com.company.pckgname.TransparentSupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
ACTIVITY :
public class ActivityGoogleMap extends SherlockFragmentActivity implements OnInfoWindowClickListener {
GoogleMap _googleMap;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// ABS
ActionBar bar = getSupportActionBar();
bar.setTitle(R.string.tle_map);
bar.setDisplayHomeAsUpEnabled(true);
// MAP
_googleMap = ((TransparentSupportMapFragment) getSupportFragmentManager().findFragmentById((R.id.map))).getMap();
//the map should still display at this point
}
}
And so that's it, the main code is here
The map was working up until now, i didn't do nything with the code map related...
I tried to regenerate a debug key on the google console, change the permissions .. etc i am out of idea !!!!
After changing the API key in AndroidManifest.xml you must clear application data.
To clear application data do one of the following:
Go to Settings > Application Manager > Select Your Application > Clear Data
Uninstall the application before re-installing it.
<uses-feature android:glEsVersion="131072" android:required="true" />
Put this under your permissions in your manifest.
Related
i need some help, i was trying configuring the google account behind the android, the main idea is don't use the wizard to configure the google account, i need do this by code, i was searching, but don't successfully, the only way I was trying to do was the following, but I believe that this is merely a way to make my current application tivese access the account I'm trying to use, but still without success
#Override
public void onClick(View v) {
try{
AccountManager mgr = AccountManager.get(this);
Account acc = new Account("sexo#gmail.com", "com.google");
if(mgr.addAccountExplicitly(acc, "pass", new Bundle())) {
Toast.makeText(MainActivity.this, "Done", Toast.LENGTH_LONG);
}
}catch(Exception e){
Log.d("test", e.getMessage());
Log.d("test", e.toString());
e.getStackTrace();
e.printStackTrace();
}
And this is my manifest used
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.actteste"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permaission.INTERACT_ACROSS_USERS_FULL"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:installLocation="internalOnly">
<activity
android:name=".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="com.company.demo.account.AuthenticatorService" android:exported="false">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator"/>
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="#xml/authenticator"/>
</service>
</application>
</manifest>
I tried to create a service and also reference in my manifest
<?xml version="1.0" encoding="utf-8"?>
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="com.company.demo.account.DEMOACCOUNT"
android:icon="#drawable/ic_launcher"
android:smallIcon="#drawable/ic_launcher"
android:label="qualquer"/>
You cannot use the account manager to setup a new account on the Google server. It can only be used for login.
The Setup application in Android also has no API available for setting up a new account. The only real way would be to reverse engineer their application code and try to inject values. It not smart and here is why:
All of this is designed this way for customer safety and Google protection. When doing this in an automated way, the customer is not agreeing to the Terms and Conditions as well as creating an account with dangerous access to user information on the device or from the device itself.
If this is 100% required, I suggest that you have the device communicate to a server you own which handles the negotiations with Google and alerts the user accordingly. Its not what you may want to hear, but this is not an advisable route.
I would like to use a Google Map in my current application. Before integrate it to my app, I created a test project to understand the functionalities.
I read this : https://developers.google.com/maps/documentation/android/start#installing_the_google_maps_android_v2_api
and this :
http://developer.android.com/google/play-services/setup.html#
After a lot of problems with these errors :
didn't find class com.google.android.gms.maps.MapFragment
and
Found 2 versions of android-support-v4.jar in the dependency list,
but not all the versions are identical (check is based on SHA-1 only at this time)
When I run my project, Eclipse says "Launching Test:(99%)", then my computer temperature up to 100°C and Eclipse take 512% of my CPU ! So I'm obliged to force Eclipse to quit.
I spent a lot of time on stack overflow, rebuild, clean, add support library, delete project and recreate from the beginning etc.
Help me, I just want to create a basic app to test a GoogleMap !
My code :
MainActivity.java
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml
<?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"
android:name="com.google.android.gms.maps.MapFragment"/>
manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<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" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="***" />
</application>
</manifest>
Edit : I know now that the problem appears when I reference the google-play-services_lib to my project... Any ideas ?
public class YourActivity extends FragmentActivity {
GoogleMap map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_activity);
map =((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.iqamah_map)).getMap();
}
}
your xml :
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/iqamah_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment" />
Add this in your Manifest
<uses-permission android:name="com.example.test.permission.MAPS_RECEIVE" />
<uses-library android:name="com.google.android.maps" />
Even me having the same issue, then instead of getting API key from Google Map Android V2, i took the API key from Google Maps Embed API and included in the Manifest and solved my problem.
Proof:
1.API key i took for project
2.Used Key in Manifest.xml
I am trying to integrate Google Play Services into my application in order to enable achievements. Upon application launch, a login attempt is being made which results in one of the following errors:
There was a problem communicating with Google servers.
Failed to log in. Please check your network connection and try again later.
A̶p̶p̶l̶i̶c̶a̶t̶i̶o̶n̶ ̶c̶r̶a̶s̶h̶e̶s̶
The application is incorrectly configured. Check that the package name and signing certificate match the cliend ID created in Developer console. Also, if the application is not yer published, check that the account you are trying to sign in with is listed as a tester account. See logs for more information.
Logcat displays absolutely no data related to this problem so I don't even have a clue what could be wrong. The app is authenticated correctly, with the correct SHA1 certificate fingerprint and app id copied to manifest. Does anyone have any could what this could be?
Thanks.
EDIT: Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.*****.xxx"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.app.Main"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.app.GameAct"
android:label="#string/title_activity_game"
android:screenOrientation="portrait" >
</activity>
<meta-data
android:name="com.google.android.gms.games.APP_ID"
android:value="#string/app_id" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>
I resolved the issue I had by deleting Google+ data related to my previous game login and logging in again. I do not know what caused this error in the first place but it may be due to wrong settings in my Developer Console. I did change some things, like re-authenticated the app but the changes took effect only after deleting old data.
I want to display google maps in my android application. I tried with the google api, but it seems to have problems with API 12 and lower. So i used the example in this page (http://www.truiton.com/2013/05/android-supportmapfragment-example/), but it doesn't seem so work in my API 7 device (xperia 10 mini pro). I used the same code in that page and i get this error after the application starts:
10-18 18:04:55.481: E/AndroidRuntime(3980): Uncaught handler: thread main exiting due to uncaught exception
10-18 18:04:55.491: E/AndroidRuntime(3980): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.maps/com.example.maps.MainActivity}: java.lang.ClassNotFoundException: com.example.maps.MainActivity in loader dalvik.system.PathClassLoader#458fc8e0
I get this error even if i did the "Add support library" in the "Android tools" menu, but it doesn't work. I saw that using GM with a web view is not a great idea, so i wanted to fix this problem.
you need to use 2.2 (API 8) and up inorder to use google maps v2
See here,just change the api key with your key in manifest file and follow these steps:
and make sure that your google_play_services_lib project should be present in your project's work space only.
Manifest file:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<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="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.geeklabs.map.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="replace with your API key"/>
</application>
</manifest>
MainActivity.java:
package com.geeklabs.map;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml:
<?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"
android:name="com.google.android.gms.maps.MapFragment"/>
After got this let me know.
I'm trying to display the google map for an android project. I followed all the steps without any problems, but when i launch my application, the map simply doesn't show up, i just have a white screen.
This is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.map"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.map.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.map.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" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="MyKeyXXXXXXX" />
<activity
android:name="com.map.HomeActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.map.MapActivity"
android:label="#string/title_activity_map" >
</activity>
</application>
</manifest>
Does anyone see something wrong ?
thanks in advance
Here are the steps you should follow:
Grab the Google Play services SDK (It's where the Maps API is)
Get the API key
Set the key in the Application Manifest
Last but not least, don't forget that Google Maps will only show if your app is signed with the key you provided to get the Maps key.
For example, if you've used a production certificate and you're testing the app with the debug key, you won't be able to see the maps.
I had this problem too. Your API key is not the giant series of two characters. On the Google Maps API console, after you have created your project and enabled Google Maps, you need to go to the API Access page, and click on "Create a new Android Key" if you don't have one already.
Your API Key that you use in your app is the ~40 character string that appears on the new key. Paste that into the Manifest and it should work.