Eclipse Problem

I am using your registration module in my eclipse but, everything works fine till i add Backendless initApp(…).

I am attaching my code any tll me if there is any problem with it. Please solve this problem.

Name- Fagun Shah
Email- shahfagunandroid@gmail.com
Thanks in advance for support

Regi.zip (2.52MB)

Hi Fagun,

We do not review complete projects as a part of support, but will be happy to assist if you post specific error you’re receiving and possible some code snippets if you believe they are relevant.

Regards,
Mark

http://support.backendless.com/public/attachments/faa9b344b810f2864f537381b052bd0c.png</img>

It is the error i get in my RegistrationActivity in line 25 which contains initApp(…) method.
I am also giving you code of RegistrationActivity code.Thanks for support


package com.backendless.samples.restaurant;


import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.backendless.Backendless;
import com.backendless.BackendlessUser;
import com.backendless.async.callback.AsyncCallback;


/**
 * Handles registration flow.
 */
public class RegistrationActivity extends Activity
{
  @Override
  protected void onCreate( Bundle savedInstanceState )
  {
    super.onCreate( savedInstanceState );
    setContentView( R.layout.activity_registration );


    Backendless.initApp( this, BackendSettings.APPLICATION_ID, BackendSettings.ANDROID_SECRET_KEY, BackendSettings.VERSION );


    Button registerButton = (Button) findViewById( R.id.registerButton );


    View.OnClickListener registerButtonClickListener = createRegisterButtonClickListener();


    registerButton.setOnClickListener( registerButtonClickListener );
  }


  /**
   * Validates the values, which user entered on registration screen.
   * Shows Toast with a warning if something is wrong.
   *
   * @param name            user's name
   * @param email           user's email
   * @param password        user's password
   * @param passwordConfirm user's password confirmation
   * @return true if all values are OK, false if something is wrong
   */
  public boolean isRegistrationValuesValid( CharSequence name, CharSequence email, CharSequence password,
                                            CharSequence passwordConfirm )
  {
    return Validator.isNameValid( this, name )
            && Validator.isEmailValid( this, email )
            && Validator.isPasswordValid( this, password )
            && isPasswordsMatch( password, passwordConfirm );
  }


  /**
   * Determines whether password and password confirmation are the same.
   * Displays Toast with a warning if not.
   *
   * @param password        password
   * @param passwordConfirm password confirmation
   * @return true if password and password confirmation match, else false
   */
  public boolean isPasswordsMatch( CharSequence password, CharSequence passwordConfirm )
  {
    if( !TextUtils.equals( password, passwordConfirm ) )
    {
      Toast.makeText( this, getString( R.string.warning_passwords_do_not_match ), Toast.LENGTH_LONG ).show();
      return false;
    }


    return true;
  }


  /**
   * Sends a request to Backendless to register user.
   *
   * @param name                 user's name
   * @param email                user's email
   * @param password             user's password
   * @param registrationCallback a callback, containing actions to be executed on request result
   */
  public void registerUser( String name, String email, String password,
                            AsyncCallback<BackendlessUser> registrationCallback )
  {
    BackendlessUser user = new BackendlessUser();
    user.setEmail( email );
    user.setPassword( password );
    user.setProperty( "name", name );


    //Backendless handles password hashing by itself, so we don't need to send hash instead of plain text
    Backendless.UserService.register( user, registrationCallback );
  }


  /**
   * Creates a callback, containing actions to be executed on registration request result.
   * Shows a Toast with BackendlessUser's objectId on success,
   * show a dialog with an error message on failure.
   *
   * @return a callback, containing actions to be executed on registration request result
   */
  public LoadingCallback<BackendlessUser> createRegistrationCallback()
  {
    return new LoadingCallback<BackendlessUser>( this, getString( R.string.loading_register ) )
    {
      @Override
      public void handleResponse( BackendlessUser registeredUser )
      {
        super.handleResponse( registeredUser );
        Toast.makeText( RegistrationActivity.this, String.format( getString( R.string.info_registered ), registeredUser.getObjectId() ), Toast.LENGTH_LONG ).show();
      }
    };
  }


  /**
   * Creates a listener, which proceeds with registration on button click.
   *
   * @return a listener, handling registration button click
   */
  public View.OnClickListener createRegisterButtonClickListener()
  {
    return new View.OnClickListener()
    {
      @Override
      public void onClick( View v )
      {
        EditText nameField = (EditText) findViewById( R.id.nameField );
        EditText emailField = (EditText) findViewById( R.id.emailField );
        EditText passwordField = (EditText) findViewById( R.id.passwordField );
        EditText passwordConfirmField = (EditText) findViewById( R.id.passwordConfirmField );


        CharSequence name = nameField.getText();
        CharSequence email = emailField.getText();
        CharSequence password = passwordField.getText();
        CharSequence passwordConfirmation = passwordConfirmField.getText();


        if( isRegistrationValuesValid( name, email, password, passwordConfirmation ) )
        {
          LoadingCallback<BackendlessUser> registrationCallback = createRegistrationCallback();


          registrationCallback.showLoading();
          registerUser( name.toString(), email.toString(), password.toString(), registrationCallback );
        }
      }
    };
  }
}

How did you import the backendless library into your project?

i copy pasted backendless jar file in my lib folder…then refreshed project from eclipse.

then select proj …righ click…build path…configure…add external jar…
same error is happening if i run code of code generator for registration - login - password revovery

At the top of the LogCat window it shows “NoClassDefFoundError: com.backendless.Backendless.”

It means that backendless.jar is not included into the deployment of the app. That’s the problem you need to solve.

Any particular reason you’re not using Android Studio??

Hii Sir…

I have intel Core2 Duo cpu with 2 gb RAM…Android studio not works properly with it…
And how can i include backendless.jar into the deployment of the app???
Regard,
Fagun

Sorry, I am not familiar with Eclipse. I am surprised someone is actually still using it.

I am pretty sure if you ask on stackoverflow “how to include a jar dependency into Android project?”, there will be people familiar with Eclipse who would help you.

Regards,
Mark

Stackoverflow shows it is correct how i imported backendless.jar.

Then why it is not included in my deployment sir?

Fagun,

If I knew anything about Eclipse, I’d love help you. Unfortunately, I know nothing about that environment. Just by looking at the error, I see that the class is not found, which means the jar is not available.

Regards,
Mark

ok mark…problem will be solved if i use anroid studAny way thanks for prompt support…
i will try it for android studio
Thanks you sir

http://support.backendless.com/public/attachments/15cb76cd1e0708e3b2293dc769e00e3a.png</img>

hello sir… i have solved that error you pointed…now i am getting this error…can u help me??

Looks like it cannot find your own classes…

If your computer can run Eclipse, surely it can run Android Studio… I suggest you switch to it and save yourself a bunch of headache…

ok sir…i am changing to android studio…but can i take my whole project from eclipse to studio?