Skip to content

You have to set namespace to your app package name (context.packageName) in your Application subclass #510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
theshethmilan opened this issue Jul 1, 2020 · 12 comments
Assignees
Labels
support Issue which has become more of a StackOverflow or a blog post

Comments

@theshethmilan
Copy link

theshethmilan commented Jul 1, 2020

After writing this line in Application subclass oncreate a very first line

UploadServiceConfig.initialize(this, CHANNEL, BuildConfig.DEBUG);

Application gets keep crashing saying

You have to set namespace to your app package name (context.packageName) in your Application subclass

I am using implementation 'net.gotev:uploadservice:4.3.1'

My suggestion if you need a namespace to run this library then why you're not directly asking namespace instead of context in UploadServiceConfig.initialize(this.getPackageName(), CHANNEL, BuildConfig.DEBUG) something like this.

Please help me what I'm doing wrong. For your reference I am sharing exception stack trace for you:

net.gotev.uploadservice.UploadServiceConfig.getNamespace (UploadServiceConfig.kt:74)
net.gotev.uploadservice.UploadServiceConfig.getBroadcastStatusAction (UploadServiceConfig.kt:230)
net.gotev.uploadservice.UploadServiceConfig.getBroadcastStatusIntentFilter (UploadServiceConfig.kt:241)
net.gotev.uploadservice.observer.request.BaseRequestObserver.register (BaseRequestObserver.kt:36)
net.gotev.uploadservice.observer.request.RequestObserver.register (RequestObserver.kt:30)
net.gotev.uploadservice.observer.request.RequestObserver_LifecycleAdapter.callMethods (RequestObserver_LifecycleAdapter.java:25)
androidx.lifecycle.SingleGeneratedAdapterObserver.onStateChanged (SingleGeneratedAdapterObserver.java:31)
androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent (LifecycleRegistry.java:361)
androidx.lifecycle.LifecycleRegistry.forwardPass (LifecycleRegistry.java:300)
androidx.lifecycle.LifecycleRegistry.sync (LifecycleRegistry.java:339)
androidx.lifecycle.LifecycleRegistry.moveToState (LifecycleRegistry.java:145)
androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent (LifecycleRegistry.java:131)
androidx.lifecycle.ReportFragment.dispatch (ReportFragment.java:68)
androidx.lifecycle.ReportFragment.dispatch (ReportFragment.java:144)
androidx.lifecycle.ReportFragment.onResume (ReportFragment.java:116)
android.app.Fragment.performResume (Fragment.java:2568)
android.app.FragmentManagerImpl.moveToState (FragmentManager.java:1341)
android.app.FragmentManagerImpl.moveFragmentToExpectedState (FragmentManager.java:1576)
android.app.FragmentManagerImpl.moveToState (FragmentManager.java:1637)
android.app.FragmentManagerImpl.dispatchMoveToState (FragmentManager.java:3050)
android.app.FragmentManagerImpl.dispatchResume (FragmentManager.java:3012)
android.app.FragmentController.dispatchResume (FragmentController.java:205)
android.app.Activity.performResume (Activity.java:7652)
android.app.ActivityThread.performResumeActivity (ActivityThread.java:4054)
android.app.ActivityThread.handleResumeActivity (ActivityThread.java:4094)
android.app.servertransaction.ResumeActivityItem.execute (ResumeActivityItem.java:51)
android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:145)
android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:70)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1993)
android.os.Handler.dispatchMessage (Handler.java:106)
android.os.Looper.loop (Looper.java:216)
android.app.ActivityThread.main (ActivityThread.java:7266)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:975)

@gotev
Copy link
Owner

gotev commented Jul 1, 2020

this is how it's done in all my apps:

in your case the app context is returning a null package name. Compare also your code with this (check application subclass is registered in the manifest): https://github.com/gotev/android-upload-service/wiki/Getting-Started-with-4.x

Passing Application instance is most straightforward and less error prone instead of setting a string.

@gotev gotev added the support Issue which has become more of a StackOverflow or a blog post label Jul 1, 2020
@gotev gotev self-assigned this Jul 1, 2020
@theshethmilan
Copy link
Author

theshethmilan commented Jul 1, 2020

When I run my app in debug mode it works smoothly without any crashes. As soon as I make a release app it started crashing.
Also I have compare my code I am passing my Application instance directly.

Check this below screen shot for your reference
UploadServiceConfig

Also this same class has been register with AndroidManifest.xml file
UploadServiceConfig_1

@gotev
Copy link
Owner

gotev commented Jul 1, 2020

Are you using code obfuscation, Proguard, R8, Minification? The problem is some setting in production mode.

@theshethmilan
Copy link
Author

theshethmilan commented Jul 1, 2020

No I'm not using anything above. My project is simple Java based with androidx

@gotev
Copy link
Owner

gotev commented Jul 1, 2020

A little demo project will help to spot what the problem is

@theshethmilan
Copy link
Author

You can create a simple Java based small demo and then make a release apk and run your app it will crash. If you still need me to share a demo share your thoughts immediately. I will make it within half an hour.

@gotev
Copy link
Owner

gotev commented Jul 1, 2020

@theshethmilan just updated the demo app of this project with a release config and it works: https://github.com/gotev/android-upload-service/tree/master/examples/app

You can also try it and see if it works. If you make a minimal demo project we can compare the two.

@theshethmilan
Copy link
Author

Ok sure.

@theshethmilan
Copy link
Author

theshethmilan commented Jul 3, 2020

I have tried as you said but its keep crashing when release apk. Now getting another error "invalid channel for service notification startforeground" from this below line

return new UploadNotificationConfig(App.CHANNEL, ringToneEnabled, progress, success, error, cancelled);

in android 10 devices even though I already register
uses-permission android:name="android.permission.FOREGROUND_SERVICE"
above permission in AndroidManifest.xml

I think you should allow developer to pass their own notification instead of creating of your own.

@gotev
Copy link
Owner

gotev commented Jul 4, 2020

@theshethmilan invalid channel for service notification startForeground was caused by createNotificationChannel which was not called in the example demo app (d27b2a9). Pull & try again and it will work. Tested on Android 10 with release config.

I think you should allow developer to pass their own notification instead of creating of your own.

You have full control if the default does not suit your needs: https://github.com/gotev/android-upload-service/wiki/Configuration#notification-handler

@theshethmilan
Copy link
Author

Yes now after adding createNotificationChannel() in Application class it works fines. I have tested with Android 10 with release config. @gotev thanks and appreciate for your immediate help, action and support.

@gotev
Copy link
Owner

gotev commented Jul 6, 2020

You're welcome! Happy coding! 💪😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Issue which has become more of a StackOverflow or a blog post
Projects
None yet
Development

No branches or pull requests

2 participants