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

mobile-install does not work with custom AppComponentFactory #17481

Open
vgrec opened this issue Feb 13, 2023 · 2 comments
Open

mobile-install does not work with custom AppComponentFactory #17481

vgrec opened this issue Feb 13, 2023 · 2 comments
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Android Issues for Android team type: bug

Comments

@vgrec
Copy link

vgrec commented Feb 13, 2023

Description of the bug:

In our project we are using a custom AppComponentFactory for a particular use case. When we use bazel build to build the app, the custom AppComponentFactory is properly taken into account. However, when we build using bazel mobile-install, a ClassNotFoundException is thrown at application startup.

The ClassNotFoundException tells that the custom AppComponentFactory could not be found. What is worth mentioning though, is that we decompiled the apk and verified that the custom AppComponentFactory is present.

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  1. Checkout this POC project: https://github.com/vgrec/bazel-appcomponentfactory-issue
  2. Build the project with bazel mobile-install //src/main:app
  3. Open the app
  4. Check the error logs

Logs:

java.lang.ClassNotFoundException: Didn't find class "com.example.bazel.MainAppComponentFactory" on path ...

Which operating system are you running Bazel on?

macOS Ventura 13.2

What is the output of bazel info release?

release 6.0.0

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

git@github.com:vgrec/bazel-appcomponentfactory-issue.git
9051c1c47b34af64c590bab53a419c405bbbda8d
9051c1c47b34af64c590bab53a419c405bbbda8d

Any other information, logs, or outputs that you want to share?

java.lang.ClassNotFoundException: Didn't find class "com.example.bazel.MainAppComponentFactory" on path: DexPathList[[zip file "/data/app/~~4OHgelH7C25AIUt3-0fsWA==/com.example.bazel-Hwab-Fhy4ZtyrRAQZxq4vA==/base.apk"],nativeLibraryDirectories=[/data/app/~~4OHgelH7C25AIUt3-0fsWA==/com.example.bazel-Hwab-Fhy4ZtyrRAQZxq4vA==/lib/arm64, /system/lib64, /system/system_ext/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.app.LoadedApk.createAppFactory(LoadedApk.java:285)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:1017)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:1104)
        at android.app.LoadedApk.getResources(LoadedApk.java:1398)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:3158)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:3150)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7389)
        at android.app.ActivityThread.access$1700(ActivityThread.java:310)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2281)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.app.ActivityThread.main(ActivityThread.java:8669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
@vgrec
Copy link
Author

vgrec commented Jul 18, 2023

Any updates on this issue?

@oliviernotteghem
Copy link

We're hitting the same issue with Bazel 6.2.0

D/nativeloader: Configuring classloader-namespace for other apk /data/app/~~9V4yTxQxD9H8aMIqAVmG_A==/com.ubercab.fleet-xE5xE1ZKCpVvVeBW-pjhOw==/base.apk. target_sdk_version=33, uses_libraries=, library_path=/data/app/~~9V4yTxQxD9H8aMIqAVmG_A==/com.ubercab.fleet-xE5xE1ZKCpVvVeBW-pjhOw==/lib/arm64:/data/app/~~9V4yTxQxD9H8aMIqAVmG_A==/com.ubercab.fleet-xE5xE1ZKCpVvVeBW-pjhOw==/base.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand:/data/user/0/com.ubercab.fleet
E/LoadedApk: Unable to instantiate appComponentFactory
    java.lang.ClassNotFoundException: Didn't find class "androidx.core.app.CoreComponentFactory" on path: DexPathList[[zip file "/data/app/~~9V4yTxQxD9H8aMIqAVmG_A==/com.ubercab.fleet-xE5xE1ZKCpVvVeBW-pjhOw==/base.apk"],nativeLibraryDirectories=[/data/app/~~9V4yTxQxD9H8aMIqAVmG_A==/com.ubercab.fleet-xE5xE1ZKCpVvVeBW-pjhOw==/lib/arm64, /data/app/~~9V4yTxQxD9H8aMIqAVmG_A==/com.ubercab.fleet-xE5xE1ZKCpVvVeBW-pjhOw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.app.LoadedApk.createAppFactory(LoadedApk.java:273)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:1039)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:1126)
        at android.app.LoadedApk.getResources(LoadedApk.java:1374)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:3090)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:3082)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6650)
        at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7872)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

@ahumesky : I know the focus is currently on mobile-install V3, but is there a known workaround for this?

@ahumesky ahumesky added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Android Issues for Android team type: bug
Projects
None yet
Development

No branches or pull requests

4 participants