android - java.lang.NoClassDefFoundError: org.apache.commons.net.ftp.FTPClient -
i'm trying upload image ftp server using asynctask:
import android.content.context; import android.os.asynctask; import org.apache.commons.net.ftp.ftp; import org.apache.commons.net.ftp.ftpclient; import org.apache.commons.net.ftp.ftpreply; import java.io.fileinputstream; public class my_ftp_uploader extends asynctask<string, void, string> { public string file_name; private context context; public ftpclient mftpclient = null; public my_ftp_uploader(context context) { this.context = context; } protected void onpreexecute() { } @override protected string doinbackground(string... arg0) { string filestouploadpath = arg0[0]; file_name = arg0[1]; try { mftpclient = new ftpclient(); mftpclient.connect("my_domain", 21); if (ftpreply.ispositivecompletion(mftpclient.getreplycode())) { boolean status = mftpclient.login("my_domain", "my_password"); mftpclient.setfiletype(ftp.binary_file_type); mftpclient.enterlocalpassivemode(); try { fileinputstream srcfilestream = new fileinputstream(filestouploadpath); try { mftpclient.changeworkingdirectory("myserver_path"); status = mftpclient.storefile(file_name + ".jpg", srcfilestream); try { mftpclient.logout(); mftpclient.disconnect(); } catch (exception e) { } } catch(exception e) { } srcfilestream.close(); } catch (exception e) { } } } catch(exception e) { } return "done"; } @override protected void onpostexecute(string result) { } }
however, receive topic error. here gradle:
apply plugin: 'com.android.application' android { configurations.all { resolutionstrategy { force 'com.android.support:support-v4:23.+' force 'com.android.support:appcompat-v7:23.+' force 'com.android.support:recyclerview-v7:23.+' } } compilesdkversion 23 buildtoolsversion "23.0.2" defaultconfig { applicationid "my_app_id" minsdkversion 15 targetsdkversion 15 versioncode 1 versionname "1.0" multidexenabled true } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile filetree(dir: 'libs', include: ['*.jar']) testcompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.android.support:support-v4:23.1.1' compile 'com.nononsenseapps:filepicker:3.0.0' compile 'com.google.android.gms:play-services:8.4.0' compile 'com.squareup.okhttp3:okhttp:3.4.1' compile 'com.daimajia.swipelayout:library:1.2.0@aar' compile 'net.gotev:uploadservice:3.0' compile 'com.jakewharton:butterknife:7.0.1' compile 'net.gotev:uploadservice-ftp:3.0' compile 'com.github.bumptech.glide:glide:3.7.0' } repositories { jcenter() }
logical points below line source of error:
mftpclient = new ftpclient();
p.s, asynctask worked before. stops working telling error. guess did conflicts else! problem since finished part, did many things on app , don't know 1 can cause it! had on similar topics did not me. hint appreciated.
i think missing in build file
compile group: 'commons-net', name: 'commons-net', version: '2.0'
to make apache commons included in project
Comments
Post a Comment