0

I have seen many reports from the field from one of my apps (~1% of users see it per day) of an error with not being able to unpack a fragment resource, with the ultimate reason being "Fragment ...MyRootFragment did not create a view". The fragment class in question has nothing but an onCreate method which inflates a simple LinearLayout.

Today I finally experienced the problem for myself, with a different product, and grabbed some logcat output, which is below.

It appears (at 09:46:13.776) that the problem is caused by Android trying to use the apk file from a different app in order to supply the resources for this app. Although I've named it unrelatedapp in the logcat, it is in fact derived from the same codebase (baseapp).

I haven't launched unrelatedapp in a couple of days. I installed myapp yesterday and ran it a couple of times, then left the device overnight. The crash happened the first time I tried to launch it this morning, and then I had several successful launches following that.

I unzipped myapp's APK, grepped for unrelatedapp and got no hits, so I'm fairly confident that it's not a built-in problem. In the original app in which I was seeing field reports of this problem, it's fairly unlikely that users would have 2 of my apps installed.

Has anyone seen this kind of problem before? Any idea how it might be resolved?

2020-01-31 09:46:13.581 769-28885/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.mycompany.myapp/com.mycompany.baseapp.activity.MainActivity (has extras)} from uid 10031
2020-01-31 09:46:13.583 567-8233/? D/audio_route: Apply path: speaker-protected
2020-01-31 09:46:13.586 567-8233/? D/audio_hw_primary: enable_snd_device: snd_device(95: vi-feedback)
2020-01-31 09:46:13.587 567-8233/? D/audio_route: Apply path: vi-feedback
2020-01-31 09:46:13.587 567-8233/? D/audio_hw_primary: enable_audio_route: usecase(24) apply and update mixer path: spkr-vi-record
2020-01-31 09:46:13.587 567-8233/? D/audio_route: Apply path: spkr-vi-record
2020-01-31 09:46:13.612 567-8233/? D/audio_hw_primary: enable_audio_route: usecase(1) apply and update mixer path: low-latency-playback
2020-01-31 09:46:13.612 567-8233/? D/audio_route: Apply path: low-latency-playback
2020-01-31 09:46:13.628 769-783/? W/BroadcastQueue: Permission Denial: receiving Intent { act=com.android.launcher3.action.LAUNCH flg=0x10 pkg=com.google.android.googlequicksearchbox (has extras) } to com.google.android.googlequicksearchbox/com.google.android.apps.gsa.reflection.ReflectionReceiver requires com.android.launcher3.permission.RECEIVE_LAUNCH_BROADCASTS due to sender com.google.android.googlequicksearchbox (uid 10031)
2020-01-31 09:46:13.634 769-783/? W/BroadcastQueue: Permission Denial: receiving Intent { act=com.android.launcher3.action.LAUNCH flg=0x10 pkg=com.google.android.gms (has extras) } to ProcessRecord{baebeb4 14853:com.google.android.gms.persistent/u0a13} (pid=14853, uid=10013) requires com.android.launcher3.permission.RECEIVE_LAUNCH_BROADCASTS due to sender com.google.android.googlequicksearchbox (uid 10031)
2020-01-31 09:46:13.634 769-783/? W/BroadcastQueue: Permission Denial: receiving Intent { act=com.android.launcher3.action.LAUNCH flg=0x10 pkg=com.google.android.gms (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$GmsExternalReceiver requires com.android.launcher3.permission.RECEIVE_LAUNCH_BROADCASTS due to sender com.google.android.googlequicksearchbox (uid 10031)
2020-01-31 09:46:13.651 567-8233/? E/msm8974_platform: ramp_speaker_gain: Could not get ctl for mixer cmd - Left Speaker Gain or Right Speaker Gain, not applying speaker gain ramp
2020-01-31 09:46:13.651 567-8233/? D/audio_hw_primary: out_write: retry previous failed cal level set
2020-01-31 09:46:13.651 567-8233/? W/msm8974_platform: platform_send_gain_dep_cal: Usecase list is empty
2020-01-31 09:46:13.659 769-1268/? I/ActivityManager: Start proc 7608:com.mycompany.myapp/u0a1008 for activity com.mycompany.myapp/com.mycompany.baseapp.activity.MainActivity
2020-01-31 09:46:13.742 15263-7566/? I/PBSessionCacheImpl: Deleted sessionId[67128963592940959] from persistence.
2020-01-31 09:46:13.752 15263-15575/? W/SearchServiceCore: Abort, client detached.
2020-01-31 09:46:13.776 1279-1705/? W/asset: Asset path /data/app/com.mycompany.unrelatedapp-7FjAm9N4JRcpJvnxYymccg==/base.apk is neither a directory nor file (type=1).
2020-01-31 09:46:13.777 1279-1705/? E/ResourcesManager: failed to add asset path /data/app/com.mycompany.unrelatedapp-7FjAm9N4JRcpJvnxYymccg==/base.apk
2020-01-31 09:46:13.777 1279-1705/? W/PackageManager: Failure retrieving resources for com.mycompany.unrelatedapp
2020-01-31 09:46:13.778 1279-1705/? W/asset: Asset path /data/app/com.mycompany.unrelatedapp-7FjAm9N4JRcpJvnxYymccg==/base.apk is neither a directory nor file (type=1).
2020-01-31 09:46:13.778 1279-1705/? E/ResourcesManager: failed to add asset path /data/app/com.mycompany.unrelatedapp-7FjAm9N4JRcpJvnxYymccg==/base.apk
2020-01-31 09:46:13.778 1279-1705/? W/PackageManager: Failure retrieving resources for com.mycompany.unrelatedapp
2020-01-31 09:46:13.866 7608-7608/? I/MultiDex: VM with version 2.1.0 has multidex support
2020-01-31 09:46:13.866 7608-7608/? I/MultiDex: Installing application
2020-01-31 09:46:13.866 7608-7608/? I/MultiDex: VM has multidex support, MultiDex support library is disabled.
2020-01-31 09:46:13.938 7608-7608/? D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
2020-01-31 09:46:13.939 7608-7608/? D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
2020-01-31 09:46:13.940 7608-7608/? I/FirebaseInitProvider: FirebaseApp initialization successful
2020-01-31 09:46:13.954 7608-7608/? I/FacebookInitProvider: Failed to auto initialize the Facebook SDK
    A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk.
        at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:276)
        at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:232)
        at com.facebook.internal.FacebookInitProvider.onCreate(FacebookInitProvider.java:20)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1919)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1894)
        at android.app.ActivityThread.installProvider(ActivityThread.java:6239)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
        at android.app.ActivityThread.-wrap1(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
2020-01-31 09:46:13.965 7608-7608/? I/com.mycompany.myapp: Application [com.mycompany.myapp] starting
2020-01-31 09:46:13.970 7608-7608/? I/com.mycompany.myapp: Application commit id: 9ed3096
2020-01-31 09:46:13.970 7608-7608/? I/com.mycompany.myapp: Application build date: 2020-01-30 15:34:00 -0700
2020-01-31 09:46:13.970 7608-7608/? I/com.mycompany.myapp: Application build configuration: release
2020-01-31 09:46:13.971 7608-7608/? I/com.mycompany.myapp: Application version: 1.0-4 / 9ed3096 [R]
2020-01-31 09:46:13.971 7608-7608/? I/com.mycompany.myapp: System name: Android
2020-01-31 09:46:13.971 7608-7608/? I/com.mycompany.myapp: System version: 8.1.0
2020-01-31 09:46:13.972 7608-7608/? I/com.mycompany.myapp: Device model: Nexus 5X
2020-01-31 09:46:13.973 7608-7608/? I/com.mycompany.myapp: Device interface idiom: 0
2020-01-31 09:46:13.974 7608-7608/? I/com.mycompany.myapp: Device vendor identifier: B26A1A6A-75B3-19F8-B26A-1A6A58DC1AA4
2020-01-31 09:46:13.977 7608-7608/? I/com.mycompany.myapp: Device id is: B26A1A6A-75B3-19F8-B26A-1A6A58DC1AA4
2020-01-31 09:46:14.049 7608-7627/? I/FA: App measurement is starting up, version: 15300
2020-01-31 09:46:14.049 7608-7627/? I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
2020-01-31 09:46:14.049 7608-7627/? I/FA: To enable faster debug mode event logging run:
      adb shell setprop debug.firebase.analytics.app com.mycompany.myapp
2020-01-31 09:46:14.058 7608-7608/? V/File read doc: /data/user/0/com.mycompany.myapp/cache/com.mycompany.myapp/saved/readdocuments.json
2020-01-31 09:46:14.073 3647-3791/? I/Icing: IndexChimeraService.getServiceInterface callingPackage=com.android.chrome componentName=null serviceId=36
2020-01-31 09:46:14.087 3647-3791/? I/Icing: IndexChimeraService.getServiceInterface callingPackage=com.google.android.gms componentName=null serviceId=36
2020-01-31 09:46:14.100 7608-7632/? D/OpenGLRenderer: HWUI GL Pipeline
2020-01-31 09:46:14.132 3647-3791/? I/Icing: IndexChimeraService.getServiceInterface callingPackage=com.google.android.gms componentName=null serviceId=30
2020-01-31 09:46:14.137 567-722/? D/audio_hw_primary: disable_audio_route: usecase(1) reset and update mixer path: low-latency-playback
2020-01-31 09:46:14.143 7608-7608/? D/AndroidRuntime: Shutting down VM


    --------- beginning of crash
2020-01-31 09:46:14.148 7608-7608/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.mycompany.myapp, PID: 7608
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mycompany.myapp/com.mycompany.baseapp.activity.MainActivity}: android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class fragment
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class fragment
     Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
     Caused by: java.lang.IllegalStateException: Fragment com.mycompany.mylibrary.ui.MyRootFragment did not create a view.
        at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3706)

MainActivity layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

<fragment android:id="@+id/rootFragment"
          android:name="com.mycompany.mylibrary.ui.MyRootFragment"
          android:layout_width="match_parent"
          android:layout_height="match_parent" />

</LinearLayout>

MyRootFragment code:

  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
  {
    View view = inflater.inflate(R.layout.my_root_fragment, container, false);
    return view;
  }

my_root_fragment layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

</LinearLayout>
chrisbtoo
  • 1,572
  • 9
  • 13
  • 2
    so have you checked this line: A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk. – Elias Fazel Jan 31 '20 at 18:38
  • You know, I hadn't, even though it's staring me right in the face there. Seems a little unlikely that it would be the cause, given that it's logged after the resource / package stuff, but I will add that in to the live app and see if it helps. – chrisbtoo Jan 31 '20 at 18:46
  • Think that's a red herring on further evaluation — it's a numeric id rather than an android package id, so I can't see how it would have any effect on resource paths. – chrisbtoo Jan 31 '20 at 18:53
  • paste the layout code of activity and fragment. – Elias Fazel Jan 31 '20 at 18:57
  • I have edited the post with the layouts. – chrisbtoo Jan 31 '20 at 19:10
  • check this https://stackoverflow.com/questions/18307533/fragment-did-not-create-a-view – Elias Fazel Jan 31 '20 at 19:19

1 Answers1

0

I had the bright idea to run the app again while looking at logcat, and the reference to unrelatedapp was still there on successful launches (also deleted unrelatedapp and the message went away). Therefore I think it's a red herring, and this question is probably no different from the other instances of "Fragment did not create a view."

chrisbtoo
  • 1,572
  • 9
  • 13