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

CTInAppNativeHalfInterstitialFragment: Resources$NotFoundException: Resource ID #0x7f0c0208 #116

Closed
bikranttripathi opened this issue Oct 28, 2020 · 7 comments
Labels
issue Acknowledge as issue

Comments

@bikranttripathi
Copy link

Hi CleverTap team, We are having issues with CleverTap InApp Notification and is preventing us from using the platform.

SDK version: v3.9.1

Crashing devices:
moto g(7): Android 10
meizu X8: Android 8.1.0
moto g power: Android 10
moto g stylus: Android 10
TCL 9029W: Android 9
TCL Alcatel 3X: Android 9
HUWEI MediaPad T3: Android 7

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{younow.live/com.clevertap.android.sdk.InAppNotificationActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f0c0208
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2944)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3079)
       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:1836)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:6718)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)

Caused by android.content.res.Resources$NotFoundException: Resource ID #0x7f0c0208
       at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:221)
       at android.content.res.Resources.loadXmlResourceParser(Resources.java:2155)
       at android.content.res.Resources.getLayout(Resources.java:1155)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
       at com.clevertap.android.sdk.CTInAppNativeHalfInterstitialFragment.onCreateView(CTInAppNativeHalfInterstitialFragment.java:40)
       at android.app.Fragment.performCreateView(Fragment.java:2522)
       at android.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1298)
       at android.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2426)
       at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:2205)
       at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:2161)
       at android.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:2062)
       at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManagerImpl.java:3051)
       at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2998)
       at android.app.FragmentController.dispatchActivityCreated(FragmentController.java:182)
       at android.app.Activity.performCreate(Activity.java:7243)
       at android.app.Activity.performCreate(Activity.java:7227)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2924)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3079)
       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:1836)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:6718)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)

We've had the same issue with an older version of the SDK and decided to upgrade to the latest(v3.9.1 at the time) as the Release Notes for v3.9.0 said that it contained fixes for InApp Notifications crashes and bugs.

This is a critical issue for us so, please let me know if there is something we can do to fix this or you are already working on a fix and the timeline for it.

Thank you in advance.

@piyush-kukadiya
Copy link
Contributor

@bikranttripathi moto g(7), moto g power, moto g stylus, TCL Alcatel 3X, meizu X8 all of them have diagonal below 7 inch. Also we have added diagonal>=7 condition in 3.9.0. You are getting Resources$NotFoundException because it's trying to pick tablet layout which is defined for diagonal>=7.
Now, since your most of the device doesn't have diagonal>=7 this code will not execute at all and exception won't occur in any way.

In such a case we will need some extra info from you like,
Are you able to reproduce it on same device?
If yes, then please try to add debug point at here and here and let us know below values:

  1. xInches
  2. yInches
  3. diagonalInches

@bikranttripathi
Copy link
Author

@piyush-kukadiya unfortunately, I don't have those devices. We are seeing these crashes for our users on Crashlytics and I haven't been able to reproduce this.

@bikranttripathi
Copy link
Author

@piyush-kukadiya We have been using smallestWidthDp on our project to identify if a running device is a tablet or not, instead of doing a manual calculation. Maybe that might be one fix for this crash?

We added isTablet -> false in values folder and isTablet -> true in values-sw600dp and up.

There is also a programmatic way of doing this:
https://github.com/react-native-device-info/react-native-device-info/blob/master/android/src/main/java/com/learnium/RNDeviceInfo/resolver/DeviceTypeResolver.java#L51

  // Use `smallestScreenWidthDp` to determine the screen size
  // https://android-developers.googleblog.com/2011/07/new-tools-for-managing-screen-sizes.html
  private DeviceType getDeviceTypeFromResourceConfiguration() {
    int smallestScreenWidthDp = context.getResources().getConfiguration().smallestScreenWidthDp;

    if (smallestScreenWidthDp == Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) {
      return DeviceType.UNKNOWN;
    }

    return smallestScreenWidthDp >= 600 ? DeviceType.TABLET : DeviceType.HANDSET;
  }

@piyush-kukadiya
Copy link
Contributor

@bikranttripathi We use multiple conditions to pick layout file not just isTablet(). I know android can pick automatically from resource buckets, but that approach is not feasible for us due to compound condition.

Are you using supports-screens in your manifest? If yes please post it here.

@bikranttripathi
Copy link
Author

Hi @piyush-kukadiya We are not using supports-screens in our app.

Also, I just got some data that you asked for. From this, it looks like the calculation is incorrectly flagging these devices as tablet.

device widthPixels heightPixels xdpi ydpi xInches yInches diagonalInches
Moto G Stylus 1080 2058 318.976 319.235 3.3858345 6.446662 7.281711809305508
Moto G Power 1080 2121 318.976 319.235 3.3858345 6.6440086 7.456991604219518
Motorola One Hyper 1080 2256 318.976 319.548 3.3858345 7.0599723 7.829883979337294

@piyush-kukadiya
Copy link
Contributor

@bikranttripathi Awesome job, this really helps.
We might have to modify logic for picking layout more accurately. We will try to fix this in next 1 or 2 release.
Will notify you once we fix it. Thanks for reporting.

@darshanclevertap
Copy link
Collaborator

This has been fixed in v4.0.1 but please move to v4.0.2 as it is the latest stable release.

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

No branches or pull requests

3 participants