1

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)
vij
  • 143
  • 1
  • 2
  • 18
  • add your activity to manifest.xml – Deepak May 08 '12 at 12:04
  • this is not really an android question...but yeah...where is this file? NtlmPasswordAuthentication ? – Hades May 08 '12 at 12:09
  • must see this Que..http://stackoverflow.com/questions/10046298/android-update-17-seems-incompatible-with-external-jars/10046725#10046725 – MAC May 08 '12 at 12:10

2 Answers2

0

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

avimak
  • 1,628
  • 11
  • 18
  • sorry its of no use..same exception – vij May 08 '12 at 12:34
  • which ADT you are using? if it's up-to-date, make sure your jar appears under "Android Dependencies" (and also perform "clean" after changing the name to libs) – avimak May 08 '12 at 12:53
  • adt 17.0.0..now the latest adt version is 18.0.0...but when i run the same program in my another system which has adt 16.0.0.1, its working finely..and i have put all the jars into newly created libs folder in jdk..and in the libraries i can find jar..but i am not finding my jar file under android dependencies – vij May 08 '12 at 13:24
  • 1. remove the jar from libs 2. remove the jar from build path (you should see import errors in your code) 3. copy the jar to libs (must be located at the project's root) 4. Project -> clean Can you see the jar under android dependencies now? – avimak May 08 '12 at 13:38
0

i removed the android dependencies folder. now its working

vij
  • 143
  • 1
  • 2
  • 18