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

AlarmManager doesn't wake up device
Get weight in android
Removing fragments from FragmentStatePagerAdapter
how to add zero on multiple places in string android
Send String from Activity to BroadcastReceiver
check if /dev/input/eventX obey Multi-touch protocol or single-touch protocol
installing ia32-libs package
Displaying multiple images on social feed in grid style
Android: When resuming app after pressing home, app always starts at root Activity
Documentation for CardView and RecyclerView
Android UI DPI Issue - is xxxhdpi resources needed?
How to set a default value to SharedPreferences programmatically?
sqlite search use uppercase and lower case
Cannot Change Width of TextView in Code
Remove magnifier icon in searchfield
How to play Video after some interval of time, when app is exit in Android

Categories

HOME
phantom-dsl
oracle12c
ggplot2
apache-flink
pda
zend-framework
yahoo-finance
socket.io
graphics
dojo
nested-if
jtextpane
character
joomla3.0
rcloud
qpython
syntaxnet
watson-conversation
gource
docx
package-managers
entitymanager
package.json
powershell-v5.0
mathprog
digital-signature
database-connection
undertow
dpdk
pchart
perlbrew
mount
dapper-extensions
maze
interbase
custom-post-type
angularjs-components
outliers
anki
left-join
hibernate-validator
code-snippets
processwire
latitude-longitude
wurfl
openalpr
timing
railstutorial.org
metawidget
trigonometry
visa
attributeerror
branching-and-merging
getchar
automapper-5
dotnet-httpclient
manova
x-ray
java-bytecode-asm
boo
gpg-signature
flac
cpu-cache
objectscript
jtree
filenet
rsa-archer-grc
simevents
observablecollection
android-wake-lock
kiosk
halcon
invoke-sqlcmd
false-sharing
qbxml
phpgrid
sciruby
computer-architecture
visual-sourcesafe-2005
slash
zscript
uncompress
branch-and-bound
nsurlsessiondatatask
snackbar
node-serialport
structuremap3
machine-instruction
human-computer-interface
universal-image-loader
winginx
getopt
inappsettingskit
composite-component
virtual-pc
android-sdk-2.3
idn
mkv
flex-mobile
automationelement
umra
unattended-processing
dot-emacs
binomial-heap
blind

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