android - java.lang.NoClassDefFoundError: rx.subjects.PublishSubject -
i've added adobe creative sdk project , im getting error when im trying move edit image function.
fatal exception: main java.lang.noclassdeffounderror: rx.subjects.publishsubject @ com.adobe.creativesdk.aviary.internal.account.adobeaccountconnection.<init>(adobeaccountconnection.java:45) @ com.adobe.creativesdk.aviary.adobeimageeditoractivity.oncreate(adobeimageeditoractivity.java:517) @ android.app.activity.performcreate(activity.java:5268) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1104) @ android.app.activitythread.performlaunchactivity(activitythread.java:2178) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2264) @ android.app.activitythread.access$600(activitythread.java:144) @ android.app.activitythread$h.handlemessage(activitythread.java:1259) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:5136) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:525) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:740) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:556) @ dalvik.system.nativestart.main(native method)
i went through documentations i've no idea why im getting error
i have attached code
package com.sliit.dailyselfie.camera; import android.app.dialog; import android.content.context; import android.content.intent; import android.content.res.configuration; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.graphics.matrix; import android.media.exifinterface; import android.net.uri; import android.os.bundle; import android.os.environment; import android.provider.mediastore; import android.support.annotation.idres; import android.support.design.widget.floatingactionbutton; import android.support.design.widget.snackbar; import android.support.v4.content.contextcompat; import android.support.v7.app.appcompatactivity; import android.support.v7.widget.toolbar; import android.util.log; import android.view.view; import android.view.menu; import android.view.menuitem; import android.view.window; import android.widget.button; import android.widget.imagebutton; import android.widget.imageview; import android.widget.textview; import android.widget.toast; import com.adobe.creativesdk.aviary.adobeimageintent; import com.bumptech.glide.glide; import com.roughike.bottombar.bottombar; import com.roughike.bottombar.onmenutabclicklistener; import com.sliit.dailyselfie.r; import java.io.file; import java.io.ioexception; import java.text.simpledateformat; import java.util.date; import rebus.bottomdialog.bottomdialog; public class cameraactivity extends appcompatactivity { private static final int activitystartcam=0; private final static int edit_image=1; private imageview iv; private string imagefileloaction=""; bottombar cambottombar; imagebutton bcan,bsnap,bdesc; dialog d; bottomdialog dialog; string challenge; bundle extras; boolean picpresent=false; uri imageuri; @override protected void oncreate(final bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_camera); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); iv = (imageview)findviewbyid(r.id.snap1); iv.setonlongclicklistener(new view.onlongclicklistener() { @override public boolean onlongclick(view v) { if (picpresent) { dialog = new bottomdialog(cameraactivity.this); dialog.title("options"); dialog.canceledontouchoutside(true); dialog.cancelable(true); dialog.inflatemenu(r.menu.camera_bottomsheet_menu); dialog.setonitemselectedlistener(new bottomdialog.onitemselectedlistener() { @override public boolean onitemselected(int id) { switch (id) { case r.id.addeffects: image(); return true; case r.id.crop: toast.maketext(getapplicationcontext(),"crop",toast.length_short).show(); return true; default: return false; } } }); dialog.show(); } return true; } }); extras = getintent().getextras(); if (extras != null) { challenge = extras.getstring("challenge"); } cambottombar = bottombar.attach(this, savedinstancestate); cambottombar.nonavbargoodness(); cambottombar.setitemsfrommenu(r.menu.camera_bottombar, new onmenutabclicklistener() { @override public void onmenutabselected(@idres int menuitemid) { if (menuitemid == r.id.nav_back) { iv.setimageresource(r.drawable.selfieimage); iv.setscaletype(imageview.scaletype.center_inside); picpresent = false; } else if (menuitemid == r.id.nav_takesnap) { intent camint= new intent(); camint.setaction(mediastore.action_image_capture); file photofile=null; try{ photofile=createimagefile(); }catch(ioexception e){ e.printstacktrace(); } camint.putextra(mediastore.extra_output, uri.fromfile(photofile)); startactivityforresult(camint, activitystartcam); } else if (menuitemid == r.id.nav_adddetails) { if (picpresent) { switch (challenge) { case "fitness": d = new dialog(cameraactivity.this); d.requestwindowfeature(window.feature_no_title); d.setcontentview(r.layout.fitnessdialog); imageview fitim = (imageview) d.findviewbyid(r.id.fitdialogimg); textview fittxt = (textview) d.findviewbyid(r.id.fitdialogdesc); d.show(); break; case "maternity": d = new dialog(cameraactivity.this); d.requestwindowfeature(window.feature_no_title); d.setcontentview(r.layout.maternitydialog); imageview matimg = (imageview) d.findviewbyid(r.id.matdialogimg); textview mattxt = (textview) d.findviewbyid(r.id.matdialogdesc); d.show(); break; case "child": d = new dialog(cameraactivity.this); d.requestwindowfeature(window.feature_no_title); d.setcontentview(r.layout.childdialog); imageview chilimg = (imageview) d.findviewbyid(r.id.childialogimg); textview chiltxt = (textview) d.findviewbyid(r.id.childialogdesc); d.show(); break; } }else{ toast.maketext(cameraactivity.this, "please select image", toast.length_short).show(); } } // // cambottombar.mapcolorfortab(0, contextcompat.getcolor(cameraactivity.this, r.color.bottomprimary)); // cambottombar.mapcolorfortab(1, contextcompat.getcolor(cameraactivity.this, r.color.bottomprimary)); // cambottombar.mapcolorfortab(2, contextcompat.getcolor(cameraactivity.this, r.color.bottomprimary)); } @override public void onmenutabreselected(@idres int menuitemid) { if (menuitemid == r.id.nav_back) { iv.setimageresource(r.drawable.selfieimage); iv.setscaletype(imageview.scaletype.center_inside); picpresent = false; } else if (menuitemid == r.id.nav_takesnap) { intent camint = new intent(); camint.setaction(mediastore.action_image_capture); file photofile = null; try { photofile = createimagefile(); } catch (ioexception e) { e.printstacktrace(); } camint.putextra(mediastore.extra_output, uri.fromfile(photofile)); startactivityforresult(camint, activitystartcam); } else if (menuitemid == r.id.nav_adddetails) { if (picpresent) { switch (challenge) { case "fitness": d = new dialog(cameraactivity.this); d.requestwindowfeature(window.feature_no_title); d.setcontentview(r.layout.fitnessdialog); imageview fitim = (imageview) d.findviewbyid(r.id.fitdialogimg); textview fittxt = (textview) d.findviewbyid(r.id.fitdialogdesc); d.show(); break; case "maternity": d = new dialog(cameraactivity.this); d.requestwindowfeature(window.feature_no_title); d.setcontentview(r.layout.maternitydialog); imageview matimg = (imageview) d.findviewbyid(r.id.matdialogimg); textview mattxt = (textview) d.findviewbyid(r.id.matdialogdesc); d.show(); break; case "child": d = new dialog(cameraactivity.this); d.requestwindowfeature(window.feature_no_title); d.setcontentview(r.layout.childdialog); imageview chilimg = (imageview) d.findviewbyid(r.id.childialogimg); textview chiltxt = (textview) d.findviewbyid(r.id.childialogdesc); d.show(); break; } }else{ toast.maketext(cameraactivity.this, "please select image", toast.length_short).show(); } } // // cambottombar.mapcolorfortab(0, contextcompat.getcolor(cameraactivity.this, r.color.bottomprimary)); // cambottombar.mapcolorfortab(1, contextcompat.getcolor(cameraactivity.this, r.color.bottomprimary)); // cambottombar.mapcolorfortab(2, contextcompat.getcolor(cameraactivity.this, r.color.bottomprimary)); } }); } @override public void onconfigurationchanged(configuration newconfig) { super.onconfigurationchanged(newconfig); rotateimage(setreducedimagesize()); iv.setscaletype(imageview.scaletype.center_crop); if(!picpresent){ iv.setimageresource(r.drawable.selfieimage); iv.setscaletype(imageview.scaletype.center_inside); } } public void takephoto(view v){ intent camint= new intent(); camint.setaction(mediastore.action_image_capture); file photofile=null; try{ photofile=createimagefile(); }catch(ioexception e){ e.printstacktrace(); } camint.putextra(mediastore.extra_output, uri.fromfile(photofile)); startactivityforresult(camint, activitystartcam); } protected void onactivityresult(int requestcode, int resultcode, intent data) { if(requestcode==activitystartcam && resultcode==result_ok){ rotateimage(setreducedimagesize()); imageuri = uri.parse(imagefileloaction); iv.setscaletype(imageview.scaletype.center_crop); picpresent=true; } if (resultcode == result_ok && requestcode==edit_image) { /* make case request code passed startactivityforresult() */ /* show image! */ uri editedimageuri = data.getdata(); imageuri=data.getdata(); glide.with(this).load(editedimageuri).into(iv); picpresent=true; } } file createimagefile()throws ioexception{ string timestamp= new simpledateformat("yyyymmdd_hhmmss").format(new date()); string imagefieldname="image "+timestamp+"_"; file storagedeirectory= environment.getexternalstoragepublicdirectory(environment.directory_pictures); file image=file.createtempfile(imagefieldname,".jpg",storagedeirectory); imagefileloaction=image.getabsolutepath(); return image; } private bitmap setreducedimagesize(){ int taretimagevieweidth=iv.getwidth(); int targetimageviewheight=iv.getheight(); bitmapfactory.options bmfop= new bitmapfactory.options(); bmfop.injustdecodebounds=true; bitmapfactory.decodefile(imagefileloaction,bmfop); int cameraheight=bmfop.outheight; int camerawidth=bmfop.outwidth; int scalefactor =math.min(camerawidth/taretimagevieweidth,cameraheight/targetimageviewheight); bmfop.insamplesize=scalefactor; bmfop.injustdecodebounds=false; return bitmapfactory.decodefile(imagefileloaction,bmfop); } private void rotateimage(bitmap bitmap){ exifinterface exifinterface = null; try{ exifinterface = new exifinterface(imagefileloaction); }catch(exception e){ e.printstacktrace(); } int orientation = exifinterface.getattributeint(exifinterface.tag_orientation,exifinterface.orientation_undefined); matrix matrix = new matrix(); switch (orientation){ case exifinterface.orientation_rotate_90: matrix.setrotate(90); break; case exifinterface.orientation_rotate_180: matrix.postrotate(180); break; default: } bitmap rotatedbitmap = bitmap.createbitmap(bitmap, 0, 0, bitmap.getwidth(), bitmap.getheight(), matrix, true); iv.setimagebitmap(rotatedbitmap); } public void image(){ /* 1) make new uri object (replace real image on device) */ uri imageuri = imageuri; /* 2) create new intent */ intent imageeditorintent = new adobeimageintent.builder(this) .setdata(imageuri) .build(); /* 3) start image editor request code 1 */ startactivityforresult(imageeditorintent,edit_image); } }
this because using version of android 4.x, , multidex not correctly implemented. solved problem following next steps:
add following lines in module.gradle
defaultconfig { multidexenabled true }
compile 'com.android.support:multidex:1.0.1'
extend class application multidexapplication
example:
public class globalapplication extends multidexapplication implements iaviaryclientcredentials {...}
- override
attachbasecontext
in previous class
example:
@override protected void attachbasecontext(context base) { multidex.install(this); super.attachbasecontext(base); }
for more information read: noclassdeffounderror android studio on android 4 https://developer.android.com/studio/build/multidex.html
Comments
Post a Comment