简体   繁体   English

运行quickblox应用程序时出现NoClassDefFound错误

[英]NoClassDefFound error on running the quickblox app

I wrote this small code to check the quickblox. 我写了这个小代码来检查quickblox。 Which just registers a user on pressing register button. 只需按注册按钮即可注册用户。 But when I run this code, i get an error in logcat saying NoClassDefFound for QBSettings and hence the application crashes. 但是,当我运行此代码时,我在logcat中收到一条错误消息,说QBSettings为NoClassDefFound,因此应用程序崩溃了。 I've already added the jar file provided by quickblox as an external jar. 我已经添加了quickblox提供的jar文件作为外部jar。 So, i cant figure out why is this happening? 所以,我不知道为什么会这样? Need Help! 需要帮忙!

import com.quickblox.core.QBCallbackImpl;
import com.quickblox.core.QBSettings;
import com.quickblox.core.result.Result;
import com.quickblox.module.users.QBUsers;
import com.quickblox.module.users.model.QBUser;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends ActionBarActivity {

Button login,register;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    QBSettings.getInstance().fastConfigInit(<app-id>, <authkey>, <authsecret>); // error here

    login = (Button) findViewById(R.id.login);
    register = (Button) findViewById(R.id.register);

    register.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            final QBUser user = new QBUser("something", "somepassword");

            // register user
            QBUsers.signUp(user, new QBCallbackImpl() {
                @Override
                public void onComplete(Result result) {
                    // result comes here
                    // check if result success
                    if (result.isSuccess()) {
                        // do stuff you need
                        Toast.makeText(getApplicationContext(), "Registered", Toast.LENGTH_SHORT).show();
                    }
                }
            });
        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

Problem isn't in your code, it is in your project configuration. 问题不在您的代码中,而是在您的项目配置中。 I suppose that you are using Eclipse IDE and you forgot to check quickblox-android.jar file to be included into apk file. 我想您正在使用Eclipse IDE,却忘记了检查要包含在apk文件中的quickblox-android.jar文件。 Look at step 5 in this tutorial . 请看本教程中的步骤5。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM