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

java.lang.Error #5

Open
dsdebastiani opened this issue Apr 3, 2018 · 3 comments
Open

java.lang.Error #5

dsdebastiani opened this issue Apr 3, 2018 · 3 comments

Comments

@dsdebastiani
Copy link

My app is reporting this error.

I have a lot of values but only in this case the problem occur.

Could someone help me? Thsnks.

java.lang.Error: 
  at com.marcinmoskala.kotlinpreferences.PreferenceHolder$Companion.getPreferencesOrThrowError$preferenceholder_release (PreferenceHolder.kt:86)
  at com.marcinmoskala.kotlinpreferences.bindings.PreferenceFieldBinder.readValue (PreferenceFieldBinder.kt:39)
  at com.marcinmoskala.kotlinpreferences.bindings.PreferenceFieldBinder.getValue (PreferenceFieldBinder.kt:22)
  at com.marcinmoskala.kotlinpreferences.bindings.PreferenceFieldBinder.getValue (PreferenceFieldBinder.kt:12)
  at app.package.utils.helpers.ApplicationPreference.getHomeGridElements (PreferencesHelper.kt)
  at app.package.modules.home.HomeFragment.onCreate (HomeFragment.kt:62)
  at android.support.v4.app.Fragment.performCreate (Fragment.java:2328)
  at android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1379)
  at android.support.v4.app.FragmentTransition.addToFirstInLastOut (FragmentTransition.java:1188)
  at android.support.v4.app.FragmentTransition.calculateFragments (FragmentTransition.java:1071)
  at android.support.v4.app.FragmentTransition.startTransitions (FragmentTransition.java:115)
  at android.support.v4.app.FragmentManagerImpl.executeOpsTogether (FragmentManager.java:2379)
  at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute (FragmentManager.java:2337)
  at android.support.v4.app.FragmentManagerImpl.execPendingActions (FragmentManager.java:2244)
  at android.support.v4.app.FragmentManagerImpl.dispatchStateChange (FragmentManager.java:3255)
  at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManager.java:3205)
  at android.support.v4.app.FragmentController.dispatchActivityCreated (FragmentController.java:195)
  at android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java:597)
  at android.support.v7.app.AppCompatActivity.onStart (AppCompatActivity.java:177)
  at app.package.modules.base.BaseActivity.onStart (BaseActivity.kt:25)
  at android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1270)
  at android.app.Activity.performStart (Activity.java:6689)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2622)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2724)
  at android.app.ActivityThread.-wrap12 (ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1473)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:154)
  at android.app.ActivityThread.main (ActivityThread.java:6123)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:867)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:757)

PreferenceHelper.kt:

object ApplicationPreference : PreferenceHolder() {
    var homeGridElements: Int by bindToPreferenceField(2)
}

HomeFragment.kt

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
       ...
        gridItemDecoration = GridSpacingItemDecoration(ApplicationPreference.homeGridElements, getActivityContext()?.resources?.getDimensionPixelSize(R.dimen.dm_grid_margin) ?: 0, false)
    }
@MarcinMoskala
Copy link
Owner

Are you sure that you've set context before this usage? Like this:

PreferenceHolder.setContext(applicationContext)

A good place is on Application onCreate. Because this error looks like lack of preferences set (although it is wired that message that explains that is not displayed)

@dsdebastiani
Copy link
Author

Yes, I'm sure.
My Application class starts others libs like Realm and Fabric the same way.

I've been running the app in production by more than 30 days. The error was reported by Playstore 5k times in this period and 99,6% of them occour with Android 7.0, others 0,4% with 7.1 an 8.0. There't reports for Android version below 7.0.

I think that issue has some rlation with the signature mode used to build the APK in the fist versions. I was building with Android Stuidio -> Build Signed APK assistant and using only V1 Signature version.

In my last build I changed the compilation mode to use the new APK Signature Scheme v2 - https://developer.android.com/about/versions/nougat/android-7.0.html#apk_signature_v2 - This build have been running in production by 5 days and the error did not occour anymore.

@MarcinMoskala
Copy link
Owner

That's strange. This subject needs to be investigated.

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

2 participants