Skip to content
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

Followup on SplitCompat.installActivity() or SplitCompat.install() #60

Open
bazinac opened this issue May 18, 2020 · 20 comments
Open

Followup on SplitCompat.installActivity() or SplitCompat.install() #60

bazinac opened this issue May 18, 2020 · 20 comments
Assignees

Comments

@bazinac
Copy link

bazinac commented May 18, 2020

Hi, sorry guys for an attempt to reopen on the recently closed issue (by @keyboardsurfer), by no means I want to be rude or offensive. I have also filled this as a potential bug for Play Core Library, but might be we did some mistake during implementation).

We are using an on-demand dynamic feature module just for the resources (some additional images used in our app.). There is no code at all, only resources. For the implementation, we have followed the tutorial described here. The basic workflow works just fine, the user installs the module, the module gets downloaded and the user can display images from it. We access them via ResourceManager. However, the issue is when the application gets killed. After next start, the module is still installed, which is confirmed through the call of getInstalledModules(). ResourceManager also properly provides IDs of the images, however, once we try to display them, they cannot be loaded with following Error:

No package ID 7e found for ID 0x7e010007.

This happens even though we have tried to call code below in all related activities

 super.attachBaseContext(context);
 SplitCompat.install(this);
 SplitCompat.installActivity(this);

In order to explain it better, I would be happy to connect via some Meets call to show details via commented screen sharing, or even provide the source code - however, issue is that our app is poorly written & documented (at best) and very complex.

So this issue reported by tprochazka (accidentally possibly also Czech guy, which is funny) has struck me because I believe this might be a related problem. Thank you for the support, we really think you guys are doing an incredible job providing us such a wonderful toolset to use in our apps.

@keyboardsurfer
Copy link
Member

No offence taken. I closed the issue as it was not directly related to the sample at hand. Can I ask you to add links to the issue you created? We don't generally offer 1:1 support for development outside of office hours at some conferences.
When you're using a module without code, make sure to set hasCode to false as described here and demonstrated here.

@bazinac
Copy link
Author

bazinac commented May 18, 2020

I fully understand that this is not some kind of a service desk :) - Link to the issue filled to the bug tracker. And also yes, we are having hasCode set to false.

There are probably a lot of different ways how to implement desired functionality (provide image resources as an add-on). Just wanted to understand whether there is a bug in Play Core Library, or whether we did something wrong during implementation after I have spent a couple of days with it, I am just curious. It could even be that I did not get the whole concept right and we are misusing the dynamic delivery modules for something they were not intended for. Honestly, I have not found many other apps using Dynamic Delivery Module to provide the same functionality, so might be that we are getting this completely wrong.

@keyboardsurfer
Copy link
Member

What you're describing is news to me. Does this occur on the assets module in the sample app as well?

@bazinac
Copy link
Author

bazinac commented May 18, 2020

Sorry for the delay, our app uses this and it is Java one, so I am currently kind of struggling with build Kotlin based code app bundle..

@bazinac
Copy link
Author

bazinac commented May 19, 2020

In the sample app, it does not happen, so I see I am barking up the wrong tree here. But I see this relies on the different feature (dynamic asset delivery), probably we are going to try to implement this and store our images in assets instead of drawable. Thanks for your support and time, I guess we can close this one.

@tprochazka
Copy link

It's even harder to found reason for such error because there is missing source code. It's open just stubs method during debugging and documentation is quite brief :-(

@bazinac
Copy link
Author

bazinac commented May 20, 2020

Yes, but I think Ben's point is that this is not an issue of this app bundle sample, but more probably a general bug in dynamic feature modules itself.

@tprochazka
Copy link

tprochazka commented May 20, 2020

Yes. It will be. Actually, the sample works even with bad SplitCompat.install()
used in activity. I originally started here because of this problem.

@bazinac
Copy link
Author

bazinac commented May 20, 2020

I eventually ended up getting the same error as you @tprochazka, just not for the string resource, but for the image. My use case:

In my main app module, I load a list of resources coming from the dynamic delivery module (com.xxxzzz.fg) like this:

int drawableResId = this.getResources().getIdentifier(String.format("%s_%s", basePictureName, i),"drawable","com.xxxzzz.fg");

Then, still in the main app module, I pass this drawableResId to popular 3rd party gallery (StfalconImageViewer). More precisely, I set it as imageView.setImageResource(drawableRes). This works perfectly, when install Bundle using ADB, however once trying this from Internal sharing/alfa build, I can get drawableResId, but I cannot load the image itself. However, I can load any resource located in the main app module this way with no problem. Strangely enough, if I do not use direct setImageResource and load image into ImageView using Picasso library, it works for the first time (until application gets killed at least once after installation of feature module) and then stops. Still, I can get drawableResId, but cannot access resource with the error shown in my first post. This gets only resolved by the manual calling of SplitInstallManager.deferredUninstall and later SplitInstallManager.startInstall again.

Seems like there is some difference between resources located in main app module and feature module, but I cannot find any mention of this in the documentation. Note that using Dynamic Assets is not a good option for us, as we need to work with image resources for various reasons...

@tprochazka
Copy link

Just after a module is installed I can access any resource which is directly in my module. But it always fails for a resource inside of any 3rd party library (which should be part of module too).
And yes after I kill the app and run it again it crashing also on my own resources ad you mentioned. I did not try this before. It looks that nobody from google test in on some more complex app that this sample app :-(

@keyboardsurfer
Copy link
Member

Thanks for the continued discussion on the topic.
If you believe this is an issue with PlayCore, you could help me to try and reproduce it within the sample in a PR. This way we can make sure we're all talking about the same thing and find a way to fix it faster.

@keyboardsurfer
Copy link
Member

Also, could you confirm that you're either extending from SplitCompatApplication or invoking SplitCompat.install in your base module's activities.

@bazinac
Copy link
Author

bazinac commented May 21, 2020

Thanks for being patient with us. Honestly, now I think that there might be some kind of issue in PlayCore. I have tried both SplitCompat.install and SplitCompat.installActivity in attachBaseContext of base module's activity that should use resources from the dynamic feature module. What does PR stand for? I can either give you access to our bitbucket repository to see the actual implementation, or I can try to extract related logic to some standalone project.

@keyboardsurfer
Copy link
Member

Thank you for confirming. Apologies, PR is short for Pull Request.
If you're able to reproduce the issue in this codebase we can take a closer look into how that happened.

@bazinac
Copy link
Author

bazinac commented May 21, 2020

Ok, as I work with GitLab normally, where there are MRs, PR did not rung the bell :). I will try to provide PR.

@tprochazka
Copy link

It works completely random. My app started working somehow. I just moved several 3rd party libraries to the main module instead of the feature module. But now I added some new dimension to my feature module and accessing it by getResources().getDimensionPixelSize(R.dimen.innert_touch_area); and it again crash all the time on it.

It is very sad, that the whole SplitCompat is the close source and even obfuscated. Is almost impossible to found why this happens. I would like at least to understand what SplitCompat.installActivity(this) does. I thought that it somehow injects resource management and when I call getResources() it will return some custom implementation instead of default one. But when it crashes, the stack trace looks completely normal:

    Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7e040028
        at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:228)
        at android.content.res.Resources.getDimensionPixelSize(Resources.java:742)
        at cz.tvprogram.lepsitv.PlayerActivity.onCreate(PlayerActivity.java:200)
        at android.app.Activity.performCreate(Activity.java:7327)
        at android.app.Activity.performCreate(Activity.java:7318)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3094)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3257) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1948) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:7050) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965) 

@tprochazka
Copy link

@bazinac Do you have WebView in your app? I just found that my problem is caused by WebView.

@tprochazka
Copy link

I created bug report for it here
https://issuetracker.google.com/issues/162779750

@keyboardsurfer
Copy link
Member

Thanks for reporting this issue. It sounds like you have a sample to reproduce this ready. Can you either attach it to the issue you created or open a PR on this repository? This way we can make sure that reproduction is possible.

@tprochazka
Copy link

Sample code is very easy, but I created it here:
https://github.com/tprochazka/app-bundle-samples/tree/bug-162779750

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants