运行时出错如何解决这个问题PLZ帮助我,因为我被困在其中我是初学者
获取log cat错误 二进制XML文件行#41:错误膨胀类com.facebook.login.widget.LoginButton
<com.facebook.login.widget.LoginButton
android:id="@+id/login_button"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_below="@id/signInText"
android:background="@drawable/facebook_connect"
/>
家庭活动
package com.styllonz.activities;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.plus.Plus;
import com.google.android.gms.plus.model.people.Person;
import com.google.gson.Gson;
import com.styllonz.R;
import com.styllonz.fragments.ForgotPasswordFragment;
import com.styllonz.fragments.LandingFragment;
import com.styllonz.fragments.LoginFragment;
import com.styllonz.fragments.SignUpFragment;
import com.styllonz.models.Response;
import com.styllonz.network.BusNetworkCallback;
import com.styllonz.network.WebserviceApi;
import com.styllonz.utils.Constants;
import com.styllonz.utils.Utilities;
import retrofit.RetrofitError;
public class HomeActivity extends FragmentActivity implements LandingFragment.OnFragmentInteractionListener,SignUpFragment.OnFragmentInteractionListener,
LoginFragment.OnFragmentInteractionListener, ForgotPasswordFragment.OnFragmentInteractionListener,
GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener
{
/* Request code used to invoke sign in user interactions. */
private static final int RC_SIGN_IN = 0;
/* Client used to interact with Google APIs. */
private GoogleApiClient mGoogleApiClient;
/* A flag indicating that a PendingIntent is in progress and prevents
* us from starting further intents.
*/
private boolean mIntentInProgress, mSignInClicked;
ConnectionResult mConnectionResult;
ProgressDialog progress;
Context mContext;
SharedPreferences mSharedPreferences;
SharedPreferences.Editor mEditor;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_home);
if (savedInstanceState == null)
replaceFragment(LandingFragment.newInstance(), LandingFragment.TAG, false);
mSharedPreferences= PreferenceManager.getDefaultSharedPreferences(this);
mEditor=mSharedPreferences.edit();
mContext=this;
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.build();
}
public void replaceFragment(Fragment fragment, String fragmentTag, boolean addToBackstack) {
FragmentManager fragmentManager = getSupportFragmentManager();
if (addToBackstack)
fragmentManager.beginTransaction()
.replace(R.id.flFragmentHolder, fragment, fragmentTag).addToBackStack("")
.commit();
else
fragmentManager.beginTransaction()
.replace(R.id.flFragmentHolder, fragment, fragmentTag)
.commit();
}
@Override
public void onHomeFragmentInteraction(View view) {
int viewId = view.getId();
switch (viewId) {
case R.id.cfbSignUp:
replaceFragment(SignUpFragment.newInstance(), SignUpFragment.TAG, true);
break;
case R.id.cfbLogin:
replaceFragment(LoginFragment.newInstance(), LoginFragment.TAG, true);
break;
}
}
@Override
public void onSignUpFragmentInteraction(View view) {
int viewId = view.getId();
switch (viewId) {
case R.id.cftvSignUpTitle:
getSupportFragmentManager().popBackStackImmediate();
}
}
@Override
public void onLoginFragmentInteraction(View view) {
int viewId = view.getId();
switch (viewId) {
case R.id.cftvForgotPassword:
replaceFragment(ForgotPasswordFragment.newInstance(), ForgotPasswordFragment.TAG, true);
break;
case R.id.cfbLogin:
Intent mainActivityIntent = new Intent(this, MainActivity.class);
startActivity(mainActivityIntent);
finish();
break;
case R.id.cftvLoginTitle:
getSupportFragmentManager().popBackStackImmediate();
}
}
@Override
public void onBackPressed() {
if (!getSupportFragmentManager().popBackStackImmediate())
super.onBackPressed();
}
@Override
public void onForgotPasswordFragmentInteraction(View view) {
int viewId = view.getId();
switch (viewId) {
case R.id.cftvForgotPasswordTitle:
getSupportFragmentManager().popBackStackImmediate();
}
}
@Override
protected void onStart() {
super.onStart();
//
}
@Override
protected void onStop() {
super.onStop();
if (mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
}
}
@Override
public void onConnected(Bundle bundle) {
mSignInClicked = false;
// Toast.makeText(this, "User is connected!", Toast.LENGTH_LONG).show();
getProfileInformation();
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(ConnectionResult result) {
if (!result.hasResolution()) {
GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this,
0).show();
if(progress!=null&&progress.isShowing())
progress.dismiss();
return;
}
if (!mIntentInProgress) {
// Store the ConnectionResult for later usage
mConnectionResult = result;
resolveSignInError();
}
}
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
super.onActivityResult(requestCode,responseCode,intent);
if (requestCode == RC_SIGN_IN) {
if (responseCode != RESULT_OK) {
mSignInClicked = false;
}
mIntentInProgress = false;
if (!mGoogleApiClient.isConnecting()) {
mGoogleApiClient.connect();
}
}
}
/**
* Sign-in into google
*/
public void signInWithGplus() {
if(Utilities.isOnline(this)) {
progress = ProgressDialog.show(this, "",
"Loading...", true);
if (!mSharedPreferences.contains(Constants.SHARED_PREFS_B_GMAIL_SOURCE)||!mGoogleApiClient.isConnected()) {
mSignInClicked = true;
if(mConnectionResult!=null)
resolveSignInError();
else
mGoogleApiClient.connect();
} else if(mGoogleApiClient.isConnected()){
getProfileInformation();
}
else if (mSharedPreferences.getBoolean(Constants.SHARED_PREFS_B_GMAIL_SOURCE, false)) {
login();
}
else {
if(progress!=null)
{
progress.dismiss();
}
}
}
else
{
Toast.makeText(this,"Please connect to internet",Toast.LENGTH_SHORT).show();
}
}
/**
* Method to resolve any signin errors
*/
private void resolveSignInError() {
if (mConnectionResult.hasResolution()) {
try {
mIntentInProgress = true;
mConnectionResult.startResolutionForResult(this, RC_SIGN_IN);
} catch (IntentSender.SendIntentException e) {
mIntentInProgress = false;
mGoogleApiClient.connect();
}
}
}
/**
* Fetching user's information name, email, profile pic
*/
private void getProfileInformation() {
try {
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
final Person currentPerson = Plus.PeopleApi
.getCurrentPerson(mGoogleApiClient);
String personName = currentPerson.getDisplayName();
String personPhotoUrl = currentPerson.getImage().getUrl();
String personGooglePlusProfile = currentPerson.getUrl();
final String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
Log.e(getClass().getSimpleName(), "Name: " + personName + ", plusProfile: "
+ personGooglePlusProfile + ", email: " + email
+ ", Image: " + personPhotoUrl);
final WebserviceApi webserviceApi=Utilities.getWebservice(mContext);
if(webserviceApi!=null)
{
webserviceApi.signupFromSource(email, personName, 'c', "google", "gmail", new BusNetworkCallback<Response>() {
@Override
public void onSuccess(Response obj) {
if (progress != null & progress.isShowing())
progress.dismiss();
Log.d(getClass().getSimpleName(), " success");
if (obj.getResult() != null && obj.getResult().equals("success")) {// Utilities.showAlertDialog(mContext,"Alert","User registered successfully.");
mEditor.putBoolean(Constants.SHARED_PREFS_B_GMAIL_SOURCE, true);
mEditor.putString(Constants.SHARED_PREFS_S_GMAIL_EMAIL, email);
mEditor.putString(Constants.SHARED_PREFS_S_GMAIL_EMAIL, currentPerson.getId());
mEditor.commit();
login();
} else if (obj.getError() != null && obj.getError().length() > 0) {
if (obj.getError().contains("Email")) {
mEditor.putBoolean(Constants.SHARED_PREFS_B_GMAIL_SOURCE, true);
mEditor.putString(Constants.SHARED_PREFS_S_GMAIL_EMAIL, email);
mEditor.putString(Constants.SHARED_PREFS_S_GMAIL_EMAIL, currentPerson.getId());
mEditor.commit();
login();
} else {
Utilities.showAlertDialog(mContext, "Error", obj.getError());
{
if (progress != null & progress.isShowing())
progress.dismiss();
}
}
} else {
Utilities.showAlertDialog(mContext, "Error", "Some error occured please try later");
{
if (progress != null & progress.isShowing())
progress.dismiss();
}
}
}
@Override
public void onFailure(RetrofitError error) {
if (progress != null & progress.isShowing())
progress.dismiss();
super.onFailure(error);
}
});
}
else
{
if(progress!=null)
{
progress.dismiss();
}
}
} else {
Toast.makeText(getApplicationContext(),
"No information found from google", Toast.LENGTH_LONG).show();
if(progress!=null&progress.isShowing())
progress.dismiss();
}
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(),
"No information found from google", Toast.LENGTH_LONG).show();
if(progress!=null&progress.isShowing())
progress.dismiss();
}
}
private void login() {
WebserviceApi webserviceApi=Utilities.getWebservice(this);
if(webserviceApi!=null) {
if (mSharedPreferences.contains(Constants.SHARED_PREFS_S_GMAIL_EMAIL))
webserviceApi.loginFromSource(Constants.SHARED_PREFS_S_GMAIL_EMAIL , Constants.SHARED_PREFS_S_GMAIL_ID,
new BusNetworkCallback<Response>() {
@Override
public void onSuccess(Response obj) {
progress.dismiss();
Log.d(getClass().getSimpleName(), " success");
if (obj.getResult() != null && obj.getResult().equals("success")) {
Constants.userDetails = obj.getData();
Gson gson = new Gson();
mEditor.putString(Constants.SHARED_PREFS_S_USER_DETAILS, gson.toJson(Constants.userDetails));
mEditor.commit();
Intent mainActivityIntent = new Intent(mContext, MainActivity.class);
startActivity(mainActivityIntent);
finish();
} else if (obj.getError() != null && obj.getError().length() > 0)
Utilities.showAlertDialog(mContext, "Error", obj.getError());
else
Utilities.showAlertDialog(mContext, "Error", "Some error occurred. Please try again later.");
}
@Override
public void onFailure(RetrofitError error) {
if(progress!=null&progress.isShowing())
progress.dismiss();
super.onFailure(error);
Utilities.showAlertDialog(mContext, "Error", "Some error occurred. Please try again later.");
}
}
);
}
else
{
if(progress!=null&progress.isShowing())
progress.dismiss();
}
}
}