سؤال

In the previous question ive asked, ive put all the necessary catch statements to find the exception. here is another one. i am posting the questions with exceptions, because it is easy to find an error by looking at them. since i am new to android, i am posting this type of questions.please see the code below. its saying no class found exception. but i have loaded the jcifs package jcifs-1.3.17.jar. i am not getting why the exception is thrown. please see below:

code:

package com.android.accesspc;
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class userpassActivity extends Activity
{

    EditText userName,userPassword;
    String uName,uPassword,IP,MAC;
    void help(int x)
    {
        userName=(EditText)findViewById(R.id.userpassUsername);
        uName = userName.getText().toString();
        userPassword=(EditText)findViewById(R.id.userpassPassword);
        uPassword = userPassword.getText().toString();
        String url= "smb://" + IP + "/";
        NtlmPasswordAuthentication auth;
        auth= new NtlmPasswordAuthentication(null,uName, uPassword);
        try
        {
            SmbFile a[]=(new SmbFile(url, auth)).listFiles();
            switch(x)
            {
                case 0:
                            Intent intent=new Intent("com.android.accesspc.VIEW");
                            intent.putExtra("IP",IP);
                            intent.putExtra("USERNAME",uName);
                            intent.putExtra("PASSWORD",uPassword);
                            startActivity(intent);  
                            break;
                case 1:
                            //code to switch off the system by checking users log on
                            //need to communicate with darshan's program
                default:
                            finish();
            }
        }
        catch(Exception e)
        {
            Toast.makeText(this,"Username and password is invalid OR",Toast.LENGTH_SHORT).show();
            Toast.makeText(this,"Sytem may be busy OR",Toast.LENGTH_SHORT).show();
            Toast.makeText(this,"Network error",Toast.LENGTH_SHORT).show();
            Toast.makeText(this,"TRY AGAIN!!",Toast.LENGTH_SHORT).show();
        }
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.userpass);
        final Bundle extras = getIntent().getExtras(); 
        if(extras !=null)
        {
            //values from previous activity
            IP = extras.getString("IPfromMacIp");
            MAC = extras.getString("MACfromMacIp");
        }
        Button send=(Button)findViewById(R.id.userpassSendButton);
        send.setOnClickListener(new 
                View.OnClickListener()
        {
            public void onClick(View v) 
            {
                if(extras !=null)
                {
                    help(0);
                }
            }
        });
        Button end=(Button)findViewById(R.id.userpassEndButton);
        end.setOnClickListener(new 
                View.OnClickListener()
        {
            public void onClick(View v) 
            {
                if(extras !=null)
                {
                    help(1);
                }
            }
        });
    }
}

Exception:

05-08 17:17:42.905: E/AndroidRuntime(398): FATAL EXCEPTION: main
05-08 17:17:42.905: E/AndroidRuntime(398): java.lang.NoClassDefFoundError: jcifs.smb.NtlmPasswordAuthentication
05-08 17:17:42.905: E/AndroidRuntime(398):  at com.android.accesspc.userpassActivity.help(userpassActivity.java:25)
05-08 17:17:42.905: E/AndroidRuntime(398):  at com.android.accesspc.userpassActivity$1.onClick(userpassActivity.java:73)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.view.View.performClick(View.java:2485)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.view.View.onKeyUp(View.java:4257)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.widget.TextView.onKeyUp(TextView.java:4566)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.view.KeyEvent.dispatch(KeyEvent.java:1280)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.view.View.dispatchKeyEvent(View.java:3855)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
05-08 17:17:42.905: E/AndroidRuntime(398):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1687)
05-08 17:17:42.905: E/AndroidRuntime(398):  at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1120)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.app.Activity.dispatchKeyEvent(Activity.java:2073)
05-08 17:17:42.905: E/AndroidRuntime(398):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1663)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2560)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2535)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1867)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.os.Looper.loop(Looper.java:123)
05-08 17:17:42.905: E/AndroidRuntime(398):  at android.app.ActivityThread.main(ActivityThread.java:3683)
05-08 17:17:42.905: E/AndroidRuntime(398):  at java.lang.reflect.Method.invokeNative(Native Method)
05-08 17:17:42.905: E/AndroidRuntime(398):  at java.lang.reflect.Method.invoke(Method.java:507)
05-08 17:17:42.905: E/AndroidRuntime(398):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-08 17:17:42.905: E/AndroidRuntime(398):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-08 17:17:42.905: E/AndroidRuntime(398):  at dalvik.system.NativeStart.main(Native Method)
هل كانت مفيدة؟

المحلول 2

i removed the android dependencies folder. now its working

نصائح أخرى

put the jar file under libs, not lib (change the folder name if needed)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top