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

Fragment is crashing on large screens - tablets and foldables #143

Open
koncinar opened this issue Feb 12, 2024 · 1 comment
Open

Fragment is crashing on large screens - tablets and foldables #143

koncinar opened this issue Feb 12, 2024 · 1 comment

Comments

@koncinar
Copy link

Our app is crashing on large devices (tablets and foldable) with the following stack trace:

Exception java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.LinearLayout.setVisibility(int)' on a null object reference
  at com.wootric.androidsdk.views.SurveyFragment.onCreateView (SurveyFragment.java:161)
  at android.app.Fragment.performCreateView (Fragment.java:2505)
  at android.app.FragmentManagerImpl.moveToState (FragmentManager.java:1303)
  at android.app.FragmentManagerImpl.addAddedFragments (FragmentManager.java:2463)
  at android.app.FragmentManagerImpl.executeOpsTogether (FragmentManager.java:2234)
  at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute (FragmentManager.java:2190)
  at android.app.FragmentManagerImpl.execPendingActions (FragmentManager.java:2091)
  at android.app.FragmentManagerImpl$1.run (FragmentManager.java:742)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:223)
  at android.app.ActivityThread.main (ActivityThread.java:7943)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:603)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:947)

The crash happens as soon as the survey is started.

We configure Wootric in the following way:

Wootric.init(
  activity,
  "...",
  "..."
).apply {
  setScoreColor(com.wootric.androidsdk.R.color.wootric_score_color)
  setSurveyColor(our.R.color.wootrick_survey)
  setLanguageCode(Locale.getDefault().language)
  setProductName(activity.getString(R.string.wootric_productName))
  setRecommendTarget(activity.getString(R.string.wootric_recommendAudience))
  setCustomMessage(
    WootricCustomMessage().apply {
      this.followupQuestion = activity.getString(R.string.wootric_followUp)
    }
  )
  setSurveyCallback(object : WootricSurveyCallback {
    ...
  })

  setEndUserEmail(session.user.email)
  setEndUserExternalId(session.user.id.toString())
  setEndUserCreatedAt(getFirstUsageDate())
  setProperties(hashMapOf(...))
}
@koncinar
Copy link
Author

Inspecting the stack trace and your code it seems that the SurveyFragment is expecting the LinearLayout with id
In the layout/wootric_footer.xml:36 it's present:
<LinearLayout android:id="@+id/wootric_powered_by" ...
While in the same file for large devices layout-sw600dp/wootric_footer.xml:10 the same layout has a different id:
<LinearLayout android:id="@+id/wootric_layout_powered_by" ...

Which then causes this code in the SurveyFragment.java:148 to return null and later cause a NPE.
mPoweredBy = (LinearLayout) view.findViewById(R.id.wootric_powered_by);

Note that wootric_layout_powered_by is being used in SurveyLayoutTablet.java:261, so it can't simply be removed.
mPoweredByLayout = (LinearLayout) findViewById(R.id.wootric_layout_powered_by);

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

1 participant