3

Androidアプリケーションでjcifs-1.3.17.jarライブラリを使用しています。

次のコードはAndroid1.6シミュレーターでは正常に機能しますが、2.3および3.0では失敗します。

アプリケーションの起動時に、2.3シミュレータのlogcatで次の警告が表示されます。

05-03 10:41:43.105: E/dalvikvm(338): Could not find class 'jcifs.smb.NtlmPasswordAuthentication', referenced from method myPackage.getFile

また、NtlmPasswordAuthenticationオブジェクトの作成中に次の例外が発生します。

05-03 10:49:59.765: E/AndroidRuntime(338): java.lang.NoClassDefFoundError: jcifs.smb.NtlmPasswordAuthentication

誰かが私が欠けているものを言うことができますか?

私の機能は

public boolean getFile(String url) 
    {
        try 
        {

            String  name="server1";//my windows username
            String  password="password1";//my windows password

            SmbFile dir=null;
            url = url.toLowerCase();

            if (!url.startsWith("smb://") )
                url = "smb://" + url;

            SmbFile file = null;
            try 
            {
                NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, name, password);
                file = new SmbFile(url, auth);
                SmbFileInputStream in = new SmbFileInputStream( file );

                File gpxfile = null;
                File root = Environment.getExternalStorageDirectory();
                gpxfile = new File(root, file.getName());
                gpxfile.delete();
                gpxfile.createNewFile();
                FileOutputStream out = new FileOutputStream(gpxfile);

                long t0 = System.currentTimeMillis();

                byte[] b = new byte[8192];
                int n, tot = 0;
                long t1 = t0;
                while(( n = in.read( b )) > 0 ) {
                    out.write( b, 0, n );
                    tot += n;
                }


            } 
            catch (Exception e1) 
            {

            }


            return true;
        } 
        catch (Exception e) 
        {
            return false;
        }
    }
4

1 に答える 1

4

プロジェクトにフォルダーlibsを追加し、その中にすべてのjarファイルをコピーします。

これらの指示に従ってください

プロジェクトを右クリックして、libsという名前のフォルダを作成します

この手順に従ってください

 right click (on libs folder) -->import-->File System-->browse to select your jar file and hit finish and run you project.

その後

 right click on the project --> Built Path-->java built path-->add jars select your jar file from your libs folder
于 2012-05-03T05:53:45.867 に答える