WebDAV客户端在Android上的实现
我正在使用 jakarta/slide 项目在我的 Android 设备上实现 webDAV 客户端。 我将所有必需的 jar 文件放入外部库中, 我的代码:
package com.android.webdav;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import org.apache.commons.httpclient.HttpException;
import org.apache.util.HttpURL;
import org.apache.webdav.lib.WebdavResource;
import android.app.Activity;
import android.os.Bundle;
public class Webdav extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
HttpURL hrl = new HttpURL("serverUrl");
hrl.setUserInfo("username", "password");
WebdavResource wdr = new WebdavResource(hrl);
File fn = new File("remote-file");
wdr.getMethod(fn);
File LocFile = new File("mnt/sdcard/test/");
wdr.putMethod(LocFile);
wdr.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
但我收到错误,
java.lang.NoClassDefFoundError: org.apache.webdav.lib.WebdavResource
上面的类已添加到 jar 中。 需要帮助。
谢谢
I am using jakarta/slide project for implementing webDAV client on my android device.
I got the all necessary jar files into external library,
my code:
package com.android.webdav;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import org.apache.commons.httpclient.HttpException;
import org.apache.util.HttpURL;
import org.apache.webdav.lib.WebdavResource;
import android.app.Activity;
import android.os.Bundle;
public class Webdav extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
HttpURL hrl = new HttpURL("serverUrl");
hrl.setUserInfo("username", "password");
WebdavResource wdr = new WebdavResource(hrl);
File fn = new File("remote-file");
wdr.getMethod(fn);
File LocFile = new File("mnt/sdcard/test/");
wdr.putMethod(LocFile);
wdr.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
but I am getting error,
java.lang.NoClassDefFoundError: org.apache.webdav.lib.WebdavResource
above class already added in jar.
Required help.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
沙丁鱼 + http://code.google.com/p/httpclientandroidlib/ 会 不起作用,因为 httpclientandroidlib 已重命名所有包名称。请参阅 android sardine + httpclientandroidlib ->新的包名称
Sardine + http://code.google.com/p/httpclientandroidlib/ does not work, because httpclientandroidlib has renamed all package names. See android sardine + httpclientandroidlib -> new package names
沙丁鱼 + http://code.google.com/p/httpclientandroidlib/
http://sardine.googlecode.com/
Sardine + http://code.google.com/p/httpclientandroidlib/
http://sardine.googlecode.com/
您可以使用https://github.com/yeonsh/Sardine-Android。
You can use https://github.com/yeonsh/Sardine-Android.