android


Can't Initialize Google Play Services


This is my first time trying to use Google Play Services.
I added the libraries "google-play-services-lib" and "BaseGameUtils". I changed my class to extends "BaseGameActivity"
Here is the code :
public class MainActivity extends BaseGameActivity implements View.OnClickListener {
Button skipBut;
View signInBut;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
skipBut = (Button) findViewById(R.id.justPlay);
signInBut = (View) findViewById(R.id.sign_in_button);
skipBut.setOnClickListener(this);
signInBut.setOnClickListener(this);
}
#Override
public void onClick(View view) {
// TODO Auto-generated method stub
if(view.getId() == R.id.sign_in_button){
beginUserInitiatedSignIn();
}
else if(view.getId() == R.id.justPlay){
// play without sign in .... code ....
}
}
#Override
public void onSignInFailed() {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "fail", Toast.LENGTH_SHORT).show();
}
#Override
public void onSignInSucceeded() {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "success", Toast.LENGTH_SHORT).show();
}
}
But my Apps is crashing down. I can't find why.
Note: I also added the app ID to the Manifest and to the strings (as app_id).
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data android:name="com.google.android.gms.games.*****id****"
android:value="#string/app_id" />
Here is the logCat :
09-08 14:57:19.500: W/ActivityThread(18213): Application com.cdev.colormatch is waiting for the debugger on port 8100...
09-08 14:57:19.520: I/System.out(18213): Sending WAIT chunk
09-08 14:57:19.540: I/dalvikvm(18213): Debugger is active
09-08 14:57:19.720: I/System.out(18213): Debugger has connected
09-08 14:57:19.725: I/System.out(18213): waiting for debugger to settle...
09-08 14:57:19.925: I/System.out(18213): waiting for debugger to settle...
09-08 14:57:20.125: I/System.out(18213): waiting for debugger to settle...
09-08 14:57:20.325: I/System.out(18213): waiting for debugger to settle...
09-08 14:57:20.525: I/System.out(18213): waiting for debugger to settle...
09-08 14:57:20.725: I/System.out(18213): waiting for debugger to settle...
09-08 14:57:20.925: I/System.out(18213): waiting for debugger to settle...
09-08 14:57:21.125: I/System.out(18213): debugger has settled (1465)
09-08 14:57:21.505: W/PopupManager(18213): You have not specified a View to use as content view for popups. Falling back to the Activity content view which may not work properly in future versions of the API. Use setViewForPopups() to set your content view.
09-08 14:57:22.225: D/dalvikvm(18213): threadid=1: still suspended after undo (sc=1 dc=1)
Update
I have tried using game helper without extending to GameBaseActivity ( as explained in https://developers.google.com/games/services/android/init#using_gamehelper_without_basegameactivity)
public class MainActivity extends ActionBarActivity implements View.OnClickListener {
Button skipBut;
View signInBut;
GameHelper mHelper;
boolean mExplicitSignOut = false;
boolean mInSignInFlow = false;
GoogleApiClient mClient;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setContentView(R.layout.activity_main);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
skipBut = (Button) findViewById(R.id.justPlay);
signInBut = (View) findViewById(R.id.sign_in_button);
skipBut.setOnClickListener(this);
signInBut.setOnClickListener(this);
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this);
builder.addApi(Games.API)
.addApi(Plus.API)
.addApi(AppStateManager.API)
.addScope(Games.SCOPE_GAMES)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.addScope(AppStateManager.SCOPE_APP_STATE);
mClient = builder.build();
mHelper = new GameHelper(this, GameHelper.CLIENT_ALL);
GameHelperListener listener = new GameHelper.GameHelperListener() {
#Override
public void onSignInSucceeded() {
// handle sign-in succeess
}
#Override
public void onSignInFailed() {
// handle sign-in failure (e.g. show Sign In button)
}
};
mHelper.setup(listener);
}
#Override
public void onClick(View view) {
// TODO Auto-generated method stub
if(view.getId() == R.id.sign_in_button){
mHelper.beginUserInitiatedSignIn();
}
else if(view.getId() == R.id.justPlay){
// skipp sign in
}
}
}
But still crashes down :(
Follow this link
you will need to add some java code to your onCreate() also try to follow the steps one by one in the right column
// Java code required.
// testDevices and loadAdOnCreate attributes are
// no longer available.
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("TEST_DEVICE_ID")
.build();
adView.loadAd(adRequest);

Related Links

RecyclerView dependency causing Floating Action Button null pointer
determine possion StaggeredGridLayoutManager in recycleview please giude me?
Need a Android Studio/OSMDroid Guide for a school project
How to keep same image size on different devices in android
How to map device co-ordinate system to world co-ordinate system in android
colors code in android are different
Polymer via Cordova on Android: Access to native Back and Menu buttons?
ListActivity or AppCompatActivity for displaying a list?
CheckedTextView with ListView
How to calculate the size of libraries that is added as a dependency in the Android project
Show the ListView and my bar together doesn't work
Toggle Inside Fragment
How to do a scroll animation in Android?
Remove Marker Google Map api v2 - Android
Android: How to call non static method of an activity from AsyncTask (via doInBackground)
Android Unable to instantiate receiver [duplicate]

Categories

HOME
azure-stream-analytics
gridview
api
ggplot2
saml-2.0
pyqt4
limit
zip
title
elasticsearch-5
little-proxy
commonjs
renjin
package-managers
easyphp
asp.net-core-webapi
database-connection
articulate-storyline
jquery-ias
dpdk
ember-cli
scriptella
jboss6.x
moses
slidetoggle
android-sharedpreferences
motion-detection
outliers
openmdao
left-join
deltaspike
wacom
card.io
vue-chartjs
openerp-7
magento-1.9.2.4
parse-tree
google-earth-engine
ideascript
filesystemwatcher
odroid
demo
skylink
glm-math
xmldocument
uiimage
flask-restful
builder
sonarlint-eclipse
vugen
launchctl
corruption
payara-micro
appdomain
oracleclient
flyout
structuremap4
rmongo
pure-css
parfor
preprocessor
google-cloud-console
myspace
flex4.6
scaffolding
yajsw
fuzzywuzzy
cycle2
linklabel
java-money
file-move
forwarding
fits
openbabel
execve
formview
build-script
dsym
android-usb
time.h
preload
joomla3.1
dopostback
tree-balancing
subgraph
floating-point-exceptions
luabind
mysql-error-1205
twitterizer
metaweblog
maven-1
openfaces
request-headers
web-application-project
wysiwym
cardspace
netbeans6.1

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App