NativeScript / nativescript-background-http

Background Upload plugin for the NativeScript framework
Apache License 2.0
102 stars 50 forks source link

[Android] Failed resolving constructor for class 'net.gotev.uploadservice.MultipartUploadRequest' with 3 parameters. #86

Closed NathanWalker closed 6 years ago

NathanWalker commented 6 years ago

This plugin works great on iOS, love it and thank you! However I'm running into an issue on Android:

Error: java.lang.Exception: Failed resolving constructor for class 'net.gotev.uploadservice.MultipartUploadRequest' with 3 parameters. Check the number and type of arguments.
JS: Primitive types need to be manually wrapped in their respective Object wrappers.
JS: If you are creating an instance of an inner class, make sure to always provide reference to the outer `this` as the first argument.
JS:     com.tns.Runtime.resolveConstructorSignature(Runtime.java:1030)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:957)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:941)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:933)

We use proguard in our app with the following specified:

-keep,includedescriptorclasses class net.gotev.uploadservice.**
-keep,includedescriptorclasses public interface net.gotev.uploadservice.**

Our tns info:

│ Component      │ Current version     │ Latest version │ Information    │
│ nativescript     │ 3.3.1        │ 3.3.1          │  Up to date │
│ tns-core-modules │ 3.3.0     │ 3.3.0          │  Up to date │
│ tns-android           │ 3.3.1       │ 3.3.1    │  Up to date │
│ tns-ios                 │ 3.3.0       │ 3.3.0          │ Up to date       │

Curious if anything jumps out we could try or if others have also run into this and some possible solutions?

/cc @vakrilov @NathanaelA @NickIliev @hdeshev

NathanWalker commented 6 years ago

Turns out this was simply related to Proguard setup. The entries needed to be like this instead:

-keep,includedescriptorclasses public class net.gotev.uploadservice.** { *; }
-keep,includedescriptorclasses public interface net.gotev.uploadservice.** { *; }
-keep,includedescriptorclasses public enum net.gotev.uploadservice.** { *; }

🎉