google-play-services.jar和Google + ...它不起作用

时间:2014-02-09 02:53:58

标签: java android

我正在使用此google-play-services.jar文件,其大小为371.9KB。当我将它用于我的Google+按钮时,当我点击G +按钮时,我会在下面的屏幕截图中看到错误。我在两部不同的手机上试过了。我将在下面粘贴我的java代码。但是,当我尝试使用我的SDK / extras / google / google_play_services /文件夹中的google-play-services.jar文件(大小为1.2MB)时,我的mPlusOneMediumButton.initialize代码行出现错误,在下面的日志文件中显示。任何人都可以告诉我这是什么问题或者指向一些有用的.jar文件的方向吗?

enter image description here

public class Plusone extends Activity implements ConnectionCallbacks, OnConnectionFailedListener {

    Intent intent;
    TextView licznik,title;
    PendingIntent pintent;
    int state;
    private static final int PLUS_ONE_REQUEST_CODE = 0;
    private static final int REQUEST_CODE_RESOLVE_ERR = 9000;
    private ProgressDialog mConnectionProgressDialog;
    private PlusClient mPlusClient;
    private ConnectionResult mConnectionResult;
    private PlusOneButton mPlusOneMediumButton;
    int sec;
    LinearLayout lay2;
    Handler han2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         mPlusClient = new PlusClient.Builder(this, this, this)
            .clearScopes()
            .build();
        setContentView(R.layout.plusone);
          mPlusOneMediumButton = (PlusOneButton) findViewById(R.id.plus_one_button);

        state=0;

         sec=15;
         licznik=(TextView)findViewById(R.id.textView1);
            lay2=(LinearLayout)findViewById(R.id.la2);
            title=(TextView)findViewById(R.id.textView2);

            if(state==1)
            {

                 lay2.setVisibility(View.GONE);
            }
            else
            {
                han2 = new Handler();
                han2.post(mUpdate);
            }
             mPlusOneMediumButton.initialize("https://market.android.com/details?id=us.mypackagename",new OnPlusOneClickListener() {
                   @Override
                   public void onPlusOneClick(Intent intent) {
                   // TODO Auto-generated method stub

                       state=1;
                      mPlusOneMediumButton.setVisibility(View.INVISIBLE);
                      title.setVisibility(View.GONE);
                       title.setVisibility(View.GONE);

                   startActivityForResult(intent, PLUS_ONE_REQUEST_CODE);
                   }
                   });

    }

             public void onConnectionFailed(ConnectionResult result) {
                 if (mConnectionProgressDialog.isShowing()) {
                         // The user clicked the sign-in button already. Start to resolve
                         // connection errors. Wait until onConnected() to dismiss the
                         // connection dialog.
                         if (result.hasResolution()) {
                                 try {
                                         result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
                                 } catch (SendIntentException e) {
                                         mPlusClient.connect();
                                 }
                         }
                 }

                 // Save the intent so that we can start an activity when the user clicks
                 // the sign-in button.
                 mConnectionResult = result;
          }


         @Override
         public void onDisconnected() {
            // TODO Auto-generated method stub

         }
         @Override
         protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
            if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
                mConnectionResult = null;
                mPlusClient.connect();
            }

         }
         @Override
            protected void onStart() {
                super.onStart();
                mPlusClient.connect();
            }

            @Override
            protected void onStop() {
                super.onStop();
                mPlusClient.disconnect();
            }
            private Runnable mUpdate = new Runnable() {
                   public void run() {




                       han2.postDelayed(this, 1000);
                       sec=sec-1;
                       licznik.setText("Or wait: "+ Integer.toString(sec)+" seconds");
                    if (sec<=0)
                    {
                    han2.removeCallbacks(mUpdate);

                 lay2.setVisibility(View.GONE);

                 startActivity(new Intent("us.mypackagename.MENU"));
                 finish();

                    }
                    }

                };

            public void onConnected() {
                String accountName = mPlusClient.getAccountName();
                  //  Toast.makeText(this, accountName + " is connected.", Toast.LENGTH_LONG).show();

            }

            @Override
            public void onConnected(Bundle arg0) {
                // TODO Auto-generated method stub

            }
}

logcat的:

02-09 03:45:39.145: E/AndroidRuntime(15681): FATAL EXCEPTION: main
02-09 03:45:39.145: E/AndroidRuntime(15681): Process: us.mypackagename, PID: 15681
02-09 03:45:39.145: E/AndroidRuntime(15681): java.lang.NoSuchMethodError: No virtual method initialize(Ljava/lang/String;Lcom/google/android/gms/plus/PlusOneButton$OnPlusOneClickListener;)V in class Lcom/google/android/gms/plus/PlusOneButton; or its super classes (declaration of 'com.google.android.gms.plus.PlusOneButton' appears in /data/app/us.mypackagename-1.apk)
02-09 03:45:39.145: E/AndroidRuntime(15681):    at us.mypackagename.Plusone.onCreate(Plusone.java:62)
02-09 03:45:39.145: E/AndroidRuntime(15681):    at android.app.Activity.performCreate(Activity.java:5241)
02-09 03:45:39.145: E/AndroidRuntime(15681):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-09 03:45:39.145: E/AndroidRuntime(15681):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
02-09 03:45:39.145: E/AndroidRuntime(15681):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2248)
02-09 03:45:39.145: E/AndroidRuntime(15681):    at android.app.ActivityThread.access$800(ActivityThread.java:138)
02-09 03:45:39.145: E/AndroidRuntime(15681):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1199)
02-09 03:45:39.145: E/AndroidRuntime(15681):    at android.os.Handler.dispatchMessage(Handler.java:102)
02-09 03:45:39.145: E/AndroidRuntime(15681):    at android.os.Looper.loop(Looper.java:136)
02-09 03:45:39.145: E/AndroidRuntime(15681):    at android.app.ActivityThread.main(ActivityThread.java:5050)
02-09 03:45:39.145: E/AndroidRuntime(15681):    at java.lang.reflect.Method.invoke(Native Method)
02-09 03:45:39.145: E/AndroidRuntime(15681):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
02-09 03:45:39.145: E/AndroidRuntime(15681):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)

0 个答案:

没有答案