简体   繁体   English

找不到类的android致命异常错误

[英]android fatal exception for class not found errors

In the previous question ive asked, ive put all the necessary catch statements to find the exception. 在上一个问题ive提出的问题中,ive放置了所有必要的catch语句以查找异常。 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. 由于我是Android新手,所以我发布了这类问题。请查看下面的代码。 its saying no class found exception. 它的说法是没有班发现例外。 but i have loaded the jcifs package jcifs-1.3.17.jar. 但是我已经加载了jcifs软件包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)

jar文件放在libs而不是lib下(如果需要,请更改文件夹名称)

i removed the android dependencies folder. 我删除了android依赖文件夹。 now its working 现在它的工作

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

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