1. Are you ready for the Galaxy S20? Here is everything we know so far!

How to import a class SavedStateHandle

Discussion in 'Android Development' started by mcpixel, Jul 28, 2019.

  1. mcpixel

    mcpixel Newbie
    Thread Starter

    I have another big problem. I dial the SavedStateHandle and press alt+enter, I see only one useless item and nothing more!
    I registered it in dependencies and synchronized gradle:
    Code (Text):
    1. def lifecycle_version = "2.0.0"
    2.  
    3.     // ViewModel and LiveData
    4.     implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
    5.     // alternatively - just ViewModel
    6.     implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version" // For Kotlin use lifecycle-viewmodel-ktx
    7.     // alternatively - just LiveData
    8.     implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
    9.     // alternatively - Lifecycles only (no ViewModel or LiveData). Some UI
    10.     //     AndroidX libraries use this lightweight import for Lifecycle
    11.     implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"
    12.  
    13.     annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" // For Kotlin use kapt instead of annotationProcessor
    14.     // alternately - if using Java8, use the following instead of lifecycle-compiler
    15.     implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
    16.  
    17.     // optional - ReactiveStreams support for LiveData
    18.     implementation "androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version" // For Kotlin use lifecycle-reactivestreams-ktx
    19.  
    20.     // optional - Test helpers for LiveData
    21.     testImplementation "androidx.arch.core:core-testing:$lifecycle_version"
    Code (Text):
    1. def lifecycle_version = "2.0.0"
    2.  
    3.     // ViewModel and LiveData
    4.     implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
    5.     // alternatively - just ViewModel
    6.     implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version" // For Kotlin use lifecycle-viewmodel-ktx
    7.     // alternatively - just LiveData
    8.     implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
    9.     // alternatively - Lifecycles only (no ViewModel or LiveData). Some UI
    10.     //     AndroidX libraries use this lightweight import for Lifecycle
    11.     implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"
    12.  
    13.     annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" // For Kotlin use kapt instead of annotationProcessor
    14.     // alternately - if using Java8, use the following instead of lifecycle-compiler
    15.     implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
    16.  
    17.     // optional - ReactiveStreams support for LiveData
    18.     implementation "androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version" // For Kotlin use lifecycle-reactivestreams-ktx
    19.  
    20.     // optional - Test helpers for LiveData
    21.     testImplementation "androidx.arch.core:core-testing:$lifecycle_version"
    But it did not help. In general, nothing helps as if this class does not exist at all! Help

     

    Advertisement

  2. Best Answer:
    Post #6 by wseng92, Jul 30, 2019 (1 points)
  3. wseng92

    wseng92 Android Enthusiast

    Please explain more
     
  4. mcpixel

    mcpixel Newbie
    Thread Starter

    What do you need?
    Here is a screenshot which shows that the required class is not in the library
     

    Attached Files:

  5. mcpixel

    mcpixel Newbie
    Thread Starter

    Attached Files:

  6. wseng92

    wseng92 Android Enthusiast

    Make sure you have this line in gradle file.

    Code (Java):
    1. implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-alpha01'
     
  7. wseng92

    wseng92 Android Enthusiast

    Add this in your gradle file and sync

    Code (Java):
    1. implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-alpha01'
     
Loading...
Similar Threads - import class SavedStateHandle
  1. vigmo10
    Replies:
    1
    Views:
    239
  2. Gary Johnsonn
    Replies:
    14
    Views:
    3,167
  3. Cyberdev
    Replies:
    2
    Views:
    300
  4. MoodyBlues
    Replies:
    5
    Views:
    459
  5. MoodyBlues
    Replies:
    4
    Views:
    193
  6. kedward777
    Replies:
    2
    Views:
    1,224
  7. snerheb2011
    Replies:
    4
    Views:
    428
  8. FouinyBaby22
    Replies:
    1
    Views:
    216
  9. lgbalfa
    Replies:
    1
    Views:
    317
  10. Ciasanril
    Replies:
    1
    Views:
    446

Share This Page

Loading...