-2

so i'm making an app which can upload an image to the server, the web service is good and running and tested with postman. on The application side, when i tried to add the implementation of the upload service 3.4.2 it's showing me an error, and the app is crashing at the moment of the upload. here is a screenshot i'm new and not allowed to add pictures,https://i.stack.imgur.com/s3s8x.png i need fast help please.

here is the run error:

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.simou.myapplication, PID: 5205
                  java.lang.RuntimeException: Unable to start service net.gotev.uploadservice.UploadService@c425f01 with Intent { act=net.gotev.uploadservice.action.upload cmp=com.simou.myapplication/net.gotev.uploadservice.UploadService (has extras) }: java.lang.IllegalArgumentException: Hey dude, please set the namespace for your app by following the setup instructions: https://github.com/gotev/android-upload-service/wiki/Setup
                      at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3314)
                      at android.app.ActivityThread.-wrap21(ActivityThread.java)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1565)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:154)
                      at android.app.ActivityThread.main(ActivityThread.java:6077)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
                   Caused by: java.lang.IllegalArgumentException: Hey dude, please set the namespace for your app by following the setup instructions: https://github.com/gotev/android-upload-service/wiki/Setup
                      at net.gotev.uploadservice.UploadService.onStartCommand(UploadService.java:257)
                      at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3297)
Simou
  • 682
  • 9
  • 28

1 Answers1

2

As mentioned in the error you need to set the namespace for your application as privided the library's wiki

public class Initializer extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        // setup the broadcast action namespace string which will
        // be used to notify upload status.
        // Gradle automatically generates proper variable as below.
        UploadService.NAMESPACE = BuildConfig.APPLICATION_ID;
        // Or, you can define it manually.
        UploadService.NAMESPACE = "com.yourcompany.yourapp";
    }
}

and register it to your manifest

<application
    android:name=".Initializer"
    ...
>
ColdFire
  • 6,764
  • 6
  • 35
  • 51
  • 1
    When upgrading the library to version 4.6.0 both NAMESPACE and HTTP_STACK are no longer properties. How should this be modified? – Raoul Oct 22 '21 at 09:59