Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7068415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:19:16+00:00 2026-05-28T05:19:16+00:00

I have a problem, When I run the following program then I found the

  • 0

I have a problem, When I run the following program then I found the NoClassDefaunderError, But that class is exist on this program. I didn’t understand why this error through by the DVM:

The Program is:

package com.codecarpet.fbconnect.sample;

import java.util.Collections;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.codecarpet.fbconnect.FBDialog;
import com.codecarpet.fbconnect.FBDialog.FBDialogDelegate;
import com.codecarpet.fbconnect.FBFeedActivity;
import com.codecarpet.fbconnect.FBLoginButton;
import com.codecarpet.fbconnect.FBLoginButton.FBLoginButtonStyle;
import com.codecarpet.fbconnect.FBPermissionActivity;
import com.codecarpet.fbconnect.FBRequest;
import com.codecarpet.fbconnect.FBRequest.FBRequestDelegate;
import com.codecarpet.fbconnect.FBSession;
import com.codecarpet.fbconnect.FBSession.FBSessionDelegate;


public class MainActivity extends Activity {

    // /////////////////////////////////////////////////////////////////////////////////////////////////
    // This application will not work until you enter your Facebook application's API key here:

    private static final String kApiKey = "<YOUR API KEY>";

    // Enter either your API secret or a callback URL (as described in documentation):
    private static final String kApiSecret = "<YOUR SECRET KEY>";
    private static final String kGetSessionProxy = null; // "<YOUR SESSION CALLBACK)>";
    private static final int PERMISSIONREQUESTCODE = 1;
    private static final int MESSAGEPUBLISHED = 2;
    // /////////////////////////////////////////////////////////////////////////////////////////////////

    private FBSession _session;
    private FBLoginButton _loginButton;
    private TextView _label;
    private Button _permissionButton;
    private Button _feedButton;
    private Handler mHandler;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mHandler = new Handler();

        if (kGetSessionProxy != null) {
            _session = FBSession.getSessionForApplication_getSessionProxy(kApiKey, kGetSessionProxy, new FBSessionDelegateImpl());
        } else {
            _session = FBSession.getSessionForApplication_secret(kApiKey, kApiSecret, new FBSessionDelegateImpl());
        }

        setContentView(R.layout.main);

        _label = (TextView) findViewById(R.id.label);
        _permissionButton = (Button) findViewById(R.id.permissionButton);
        _permissionButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                askPermission();
            }
        });

        _feedButton = (Button) findViewById(R.id.feedButton);
        _feedButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                publishFeed();
            }
        });

        _loginButton = (FBLoginButton) findViewById(R.id.login);
        _loginButton.setStyle(FBLoginButtonStyle.FBLoginButtonStyleWide);
        _loginButton.setSession(_session);

        _session.resume(this);

    }

    // /////////////////////////////////////////////////////////////////////////////////////////////////

    private void askPermission() {
        Intent intent = new Intent(this, FBPermissionActivity.class);
        intent.putExtra("permissions", new String[]{"publish_stream"});
        this.startActivityForResult(intent, PERMISSIONREQUESTCODE );
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);

        switch (requestCode){
        case PERMISSIONREQUESTCODE:
            if (resultCode == 1) 
                _permissionButton.setVisibility(View.INVISIBLE);
        default:
            return;
        }

    }

    private void publishFeed() {
        Intent intent = new Intent(this, FBFeedActivity.class);
        intent.putExtra("userMessagePrompt", "Example prompt");
        intent.putExtra("attachment", "{\"name\":\"Facebook Connect for Android\",\"href\":\"http://code.google.com/p/fbconnect-android/\",\"caption\":\"Caption\",\"description\":\"Description\",\"media\":[{\"type\":\"image\",\"src\":\"http://img40.yfrog.com/img40/5914/iphoneconnectbtn.jpg\",\"href\":\"http://developers.facebook.com/connect.php?tab=iphone/\"}],\"properties\":{\"another link\":{\"text\":\"Facebook home page\",\"href\":\"http://www.facebook.com\"}}}");
        this.startActivityForResult(intent, MESSAGEPUBLISHED);
    }

    // /////////////////////////////////////////////////////////////////////////////////////////////////

    private class FBDialogDelegateImpl extends FBDialogDelegate {

        @Override
        public void didFailWithError(FBDialog dialog, Throwable error) {
            _label.setText(error.toString());
        }

    }

    private void checkPermission() {
        String fql = "select publish_stream from permissions where uid == " + String.valueOf(_session.getUid());
        Map<String, String> params = Collections.singletonMap("query", fql);
        FBRequest.requestWithDelegate(new FBHasPermissionRD()).call("facebook.fql.query", params);
    }    

    private class FBSessionDelegateImpl extends FBSessionDelegate {

        @Override
        public void session_didLogin(FBSession session, Long uid) {
            // we check if the user already has the permissions before displaying permission button
            checkPermission();

            mHandler.post(new Runnable() {
                public void run() {
                    _feedButton.setVisibility(View.VISIBLE);
                }
             });

            String fql = "select uid,name from user where uid == " + session.getUid();

            Map<String, String> params = Collections.singletonMap("query", fql);
            FBRequest.requestWithDelegate(new FBRequestDelegateImpl()).call("facebook.fql.query", params);
        }



        @Override
        public void sessionDidLogout(FBSession session) {
            mHandler.post(new Runnable() {
               public void run() {
                   _label.setText("");
                   _permissionButton.setVisibility(View.INVISIBLE);
                   _feedButton.setVisibility(View.INVISIBLE);
               }
            });
        }

    }

    private class FBRequestDelegateImpl extends FBRequestDelegate {

        @Override
        public void request_didLoad(FBRequest request, Object result) {

            String name = null;

            if (result instanceof JSONArray) {
                JSONArray jsonArray = (JSONArray) result;
                try {
                    JSONObject jo = jsonArray.getJSONObject(0);
                    name = jo.getString("name");
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            _label.setText("Logged in as " + name);
        }

        @Override
        public void request_didFailWithError(FBRequest request, Throwable error) {
            _label.setText(error.toString());
        }
    }

    private class FBHasPermissionRD extends FBRequestDelegate {

        @Override
        protected void request_didFailWithError(FBRequest request,
                Throwable error) {
            super.request_didFailWithError(request, error);
        }

        @Override
        public void request_didLoad(FBRequest request, Object result) {
            int hasPermission = 0;

            if (result instanceof JSONArray) {
                JSONArray jsonArray = (JSONArray) result;
                try {
                    JSONObject jo = jsonArray.getJSONObject(0);
                    hasPermission = jo.getInt("publish_stream");
                    if (hasPermission == 0)
                    {
                        mHandler.post(new Runnable() {
                            public void run() {
                                _permissionButton.setVisibility(View.VISIBLE);
                            }
                         });
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

And the Error is:

11-22 11:33:02.510: ERROR/AndroidRuntime(3213): java.lang.NoClassDefFoundError: com.codecarpet.fbconnect.sample.MainActivity$FBSessionDelegateImpl
11-22 11:33:02.510: ERROR/AndroidRuntime(3213):     at com.codecarpet.fbconnect.sample.MainActivity.onCreate(MainActivity.java:77)

Thanx in Advance…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:19:16+00:00Added an answer on May 28, 2026 at 5:19 am

    Give the absolute path in your project. If you are unable to do this, then add the all file of facebook api, in your current project. After that clean and run it…!!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code I want to run, but the problem is $this->type
NOTE: I have solved the majority of this problem but have run into a
I have run into this problem before but never quite solved it. I have
I have a problem.... I made a java program that does the following: BufferedReader
My program is seemingly having a deadlock problem. Basically I have a class that
I have a problem: if i run this test in NUnit ,it works Board
I have problem with fancybox. I want to write a function that will run
The problem: we have jobs that run from a few seconds to a few
I have actually figured this problem out, but it took me days, so I
I have been thinking about this problem for long enough but cannot come up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.