Andorid之提示java.lang.RuntimeException: Unable to start service net.gotev.uploadservice.UploadService@

1 问题

用android-upload-service上传一个文件提示错误如下

04-15 17:46:33.245 24932 24932 E AndroidRuntime: Process: com.appsinnova.android.keepshare, PID: 24932
04-15 17:46:33.245 24932 24932 E AndroidRuntime: java.lang.RuntimeException: Unable to start service net.gotev.uploadservice.UploadService@ce7b171 with Intent { act=net.gotev.uploadservice.action.upload cmp=packageName/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
04-15 17:46:33.245 24932 24932 E AndroidRuntime:        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4013)
04-15 17:46:33.245 24932 24932 E AndroidRuntime:        at android.app.ActivityThread.access$1800(ActivityThread.java:229)
04-15 17:46:33.245 24932 24932 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1908)
04-15 17:46:33.245 24932 24932 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:106)
04-15 17:46:33.245 24932 24932 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:226)
04-15 17:46:33.245 24932 24932 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:7223)
04-15 17:46:33.245 24932 24932 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
04-15 17:46:33.245 24932 24932 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:576)
04-15 17:46:33.245 24932 24932 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:961)
04-15 17:46:33.245 24932 24932 E AndroidRuntime: 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
04-15 17:46:33.245 24932 24932 E AndroidRuntime:        at net.gotev.uploadservice.UploadService.onStartCommand(UploadService.java:257)
04-15 17:46:33.245 24932 24932 E AndroidRuntime:        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3980)
04-15 17:46:33.245 24932 24932 E AndroidRuntime:        ... 8 more
04-15 17:46:33.247   606   635 I [email protected]: notifyAppState_2_1 pack:com.appsinnova.android.keepshare, act:com.appsinnova.android.keepshare, pid:24932, uid:10293, state:3
04-15 17:46:33.263 24932 24932 I Process : Sending signal. PID: 24932 SIG: 9
04-15 17:46:33.350  1254  3575 D Dex2oatManagerService: Display listener for pid 24932 died.

2 原因

UploadService没有注册

3 解决办法

在继承的Application类里面的onCreate函数里面添加如下代码

    override fun onCreate() {
        super.onCreate()

        UploadService.NAMESPACE = packageName;
    }
发布了1091 篇原创文章 · 获赞 710 · 访问量 316万+

猜你喜欢

转载自blog.csdn.net/u011068702/article/details/105542430