jdamcd / android-crop

Android library project for cropping images
4.54k stars 1.08k forks source link

Profile Image Pick Error #269

Closed cesariel closed 6 years ago

cesariel commented 6 years ago

When trying to change the Profile Picture I get this error:

java.lang.NoSuchMethodError: No direct method <init>(Landroid/net/Uri;)V in class Lcom/soundcloud/android/crop/Crop; or its super classes (declaration of 'com.soundcloud.android.crop.Crop' appears in /data/app/com.project-QBoWDSPJVdfZCSw5b9AGLw==/split_lib_dependencies_apk.apk:classes8.dex)
                                                                                         at com.braunster.chatsdk.object.Cropper.<init>(Cropper.java:0)
                                                                                         at com.braunster.chatsdk.Utils.helper.ChatSDKProfileHelper.handleResult(ChatSDKProfileHelper.java:482)
                                                                                         at com.braunster.chatsdk.fragments.abstracted.ChatSDKAbstractProfileFragment.onActivityResult(ChatSDKAbstractProfileFragment.java:105)
                                                                                         at android.app.Activity.dispatchActivityResult(Activity.java:7262)
                                                                                         at android.app.ActivityThread.deliverResults(ActivityThread.java:4320)
                                                                                         at android.app.ActivityThread.handleSendResult(ActivityThread.java:4367)
                                                                                         at android.app.ActivityThread.-wrap19(Unknown Source:0)
                                                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1649)
                                                                                         at android.os.Handler.dispatchMessage(Handler.java:105)
                                                                                         at android.os.Looper.loop(Looper.java:164)
                                                                                         at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                                         at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
cesariel commented 6 years ago

I change the Cropper Class to:


public class Cropper {

    private Uri source;
    private Uri destination;

    public Cropper(Uri source, Uri destination) {
        this.source = source;
        this.destination = destination;
    }

    public Crop Cropper (Uri source, Uri destination){

        return Crop.of(source, destination);

    }

    static interface Extra {
        String ASPECT_X = "aspect_x";
        String ASPECT_Y = "aspect_y";
    }

    /*
    public Cropper(Uri source) {
        super(source);
        this.source = source;

    }*/

    /**
     * @return Intent that will open the crop activity with an adjustable bounds for the cropping square.
     * * * */
    public Intent getIntent(Context context, Uri output){
        Intent cropIntent = new Intent();
        cropIntent.setData(source);
        cropIntent.setClass(context, CropImageActivity.class);
        cropIntent.putExtra(Extra.ASPECT_X, 1);
        cropIntent.putExtra(Extra.ASPECT_Y, 1);
        cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, output);

        return cropIntent;
    }

    /**
     * @return Intent that will open the crop activity with an adjustable bounds for the cropping quare.
     * * * */
    public Intent getAdjustIntent(Context context, Uri output){
        Intent cropIntent = new Intent();
        cropIntent.setData(source);
        cropIntent.setClass(context, CropImageActivity.class);
        cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, output);

        return cropIntent;
    }
}

To instantiate a new Cropper:

crop = new Cropper(uri, outputUri);