0

Eclipse を使用してデバイスでこのアプリをテストすると、すべて問題ありませんが、Google Play ストアでこのアプリを公開すると、Facebook のログインに失敗しました!! なぜ?お願い助けて!!それは単純なアプリです(市場の「コーヒーブレイク」)。

  public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main );

            elementoInserito=(EditText)findViewById(R.id.editTextElementoInserito);
            elementoEstratto=(TextView)findViewById(R.id.textViewElementoEstratto);
            inserisci=(Button)findViewById(R.id.buttonInserisci);
            stampa=(Button)findViewById(R.id.buttonStampa);  

            facebookLogin=(Button)findViewById(R.id.facebookLogin);
            Session session = Session.getActiveSession();
             if (session == null) {
                    if (savedInstanceState != null) {
                        session =Session.restoreSession(this,null,statusCallback,savedInstanceState);
                    }
                    if (session == null) {
                        session = new Session(this);
                    }
                    Session.setActiveSession(session);
                    if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
                       session.openForRead(newSession.OpenRequest(this).setCallback(statusCallback));
                    }
                }

                inserisci.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        inizializza_array(elementoInserito);
                        elementoInserito.setText("");
                    }
                });
                updateView();
        } 
        private void updateView() {
              Session session = Session.getActiveSession();
              if (session.isOpened()) {
                facebookLogin.setOnClickListener(new OnClickListener() {
                    public void onClick(View view) { 
                        onClickLogout(); }
                });

              }
             else {
                facebookLogin.setOnClickListener(new OnClickListener() {
                    public void onClick(View view) { 
                        onClickLogin(); }
                });
            }
        } 
        private void onClickLogin() {
            Session session = Session.getActiveSession();
            if (!session.isOpened() && !session.isClosed()) {
                session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
            } else {
                Session.openActiveSession(this, true, statusCallback);
            }
            Bundle bundle=new Bundle();
           Session.saveSession(session,bundle);
           Toast.makeText(getApplicationContext(), 
                   "sto salvando la sessione   "+session.getState(),
                     Toast.LENGTH_LONG).show();
        }
        private void onClickLogout() {
            Session session = Session.getActiveSession();
            if (!session.isClosed()) {
                session.closeAndClearTokenInformation();
            } 
        }
        private class SessionStatusCallback implements Session.StatusCallback {
            @Override
            public void call(Session session, SessionState state, Exception exception) {
                onSessionStateChange(session, state, exception);    
                updateView();
            }
        }
        private void onSessionStateChange(Session session, SessionState state, Exception exception) {
            if (state.isOpened()) {
                Log.i(TAG, "Logged in...");
            } else if (state.isClosed()) {
                Log.i(TAG, "Logged out...");
            }
        }
        public void inizializza_array(EditText n){
            this.ins=""+n.getText();
            if(ins==""){
                 Toast.makeText(getApplicationContext(), 
                         "errore: campo vuoto",
                           Toast.LENGTH_LONG).show();
            }
            else{
                lista.add(ins);
            }
        }
        public void stampa(View v){
            if(lista.size()==0){
                elementoEstratto.setText("Inserire elementi");
            }
            else{
            Random random = new Random();
            String x = lista.get(random.nextInt(lista.size()));
                elementoEstratto.setText(x);
                lista.clear();
               try {
                  publishStory(x);
            } catch (Exception e) {
            } 
            }
        }
         public void onStart() {
                super.onStart(); 
                Session.getActiveSession().addCallback(statusCallback);
            }  
            @Override
            public void onStop() {
                super.onStop();
                Session.getActiveSession().removeCallback(statusCallback);
            }
            @Override
            protected void onSaveInstanceState(Bundle outState) {
                super.onSaveInstanceState(outState);
                Session session = Session.getActiveSession();
                Session.saveSession(session, outState);
            }
            public void publishStory(String sorteggiato) {
                Session session = Session.getActiveSession();
                try {       
                if (session != null){  
                    List<String> permissions = session.getPermissions();
                    if (!isSubsetOf(PERMISSIONS, permissions)) {
                        pendingPublishReauthorization = true;
                        Session.NewPermissionsRequest newPermissionsRequest = new Session
                                .NewPermissionsRequest(this, PERMISSIONS);
                    session.requestNewPublishPermissions(newPermissionsRequest);
                        return;
                    }
                    Bundle postParams = new Bundle();
                    postParams.putString("name",""));
                    postParams.putString("caption","");
                    postParams.putString("description","");
                    Request.Callback callback= new Request.Callback() {
                        public void onCompleted(Response response) {
                            JSONObject graphResponse = response
                                                       .getGraphObject()
                                                       .getInnerJSONObject();
                            String postId = null;
                            try {
                                postId = graphResponse.getString("id");
                            } catch (JSONException e) {
                                Log.i(TAG,
                                    "JSON error "+ e.getMessage());
                            }
                            FacebookRequestError error = response.getError();
                            if (error != null) {
                                Toast.makeText(getApplicationContext(),
                                     error.getErrorMessage(),
                                     Toast.LENGTH_SHORT).show();
                                } else {
                                    Toast.makeText(getApplicationContext(), 
                                       "shared",//postId
                                         Toast.LENGTH_LONG).show();
                            }
                        }
                    };

                    Request request = new Request(session, "me/feed", postParams, 
                                          HttpMethod.POST, callback);
                    RequestAsyncTask task = new RequestAsyncTask(request);
                    task.execute();
                    }
                else{
                    Toast.makeText(getApplicationContext(), 
                            "effettua il Login su Facebook per condividere con i tuo amici",
                              Toast.LENGTH_LONG).show();
                }
                } catch (Exception e) {
                    // TODO: handle exception
                }
                }
                private boolean isSubsetOf(Collection<String> subset, Collection<String> superset) {
                    for (String string : subset) {
                        if (!superset.contains(string)) {
                            return false;
                        }
                    }
                    return true;
                }
                @Override
                public void onActivityResult(int requestCode, int resultCode, Intent data) {
                    super.onActivityResult(requestCode, resultCode, data);
                    Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
                }    
                @Override 
                        public boolean onCreateOptionsMenu(Menu menu) {
                            Intent intent = new Intent (MainActivity.this,Info.class); 
                            //Intent intent2 = new Intent(MainActivity.this,Caffe.class);
                            menu.add("About Coffee Break").setIntent(intent);
                            //menu.add("Il caffè").setIcon(R.drawable.caffe).setIntent(intent2);
                           return true; 
                        }       
    }

なぜ私がこの問題を抱えているのか理解できません

4

1 に答える 1

0

私は問題を自己解決しました。私はこのコードを理解していない正しい方法で relese.k​​eystore を読んでいませんでした:

keytool -exportcert -alias myAlias -keystore ~/.your/path/release.keystore | openssl sha1 -binary | openssl base64

コードを認識したとき、正しいキーを取得しました

myAlias = プロジェクトをエクスポートするときに使用されるエイリアス

~/.your/path/release.keystore = Eclipse から生成されたキーが配置されているパスとファイルの名前

よくできた

于 2013-04-03T14:50:01.287 に答える