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

Compose Preview crashes because of Parse init #1205

Open
4 tasks done
FlorinCusmereanu opened this issue Dec 14, 2023 · 3 comments
Open
4 tasks done

Compose Preview crashes because of Parse init #1205

FlorinCusmereanu opened this issue Dec 14, 2023 · 3 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@FlorinCusmereanu
Copy link

New Issue Checklist

Issue Description

Cannot run Preview

Steps to reproduce

Create a Preview page

Actual Outcome

Error

Expected Outcome

Component rendered in preview pane

Environment

Android

Parse Android SDK

  • SDK version: 4.2.1
  • Operating system version: Sonoma 14.2

Server

  • Parse Server version: FILL_THIS_OUT
  • Operating system: FILL_THIS_OUT
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): FILL_THIS_OUT

Database

  • System (MongoDB or Postgres): FILL_THIS_OUT
  • Database version: FILL_THIS_OUT
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): FILL_THIS_OUT

Logs

java.lang.NullPointerException: Cannot invoke "java.io.File.getAbsolutePath()" because the return value of "com.parse.ParseCacheDirMigrationUtils.getOldParseDir(android.content.Context)" is null

I am trying with this code to preview my signup component
I have tried initializing Parse in my preview, but it still doesn't work

@OptIn(ExperimentalMaterial3Api::class)
@Preview(showBackground = true)
@Composable
fun SignUpPagePreview() {

    val configuration = Parse.Configuration
        .Builder(LocalContext.current)
        .applicationId("****")
        .server("****")
        .build()
    Parse.initialize(configuration)
    Parse.enableLocalDatastore(LocalContext.current)

    CompositionLocalProvider(
        LocalUserState provides remember { UserStateViewModel() },
    ) {
        val navController = rememberNavController()
        SignUpPage(navController = navController)
    }

}
Copy link

Thanks for opening this issue!

  • ❌ Please fill out all fields with a placeholder FILL_THIS_OUT, otherwise your issue will be closed. If a field does not apply to the issue, fill in n/a.

@mtrezza mtrezza added the type:bug Impaired feature or lacking behavior that is likely assumed label Dec 14, 2023
@mtrezza
Copy link
Member

mtrezza commented Dec 14, 2023

Not sure whether this is a bug or actually an incorrect setup of the preview context.

@FlorinCusmereanu
Copy link
Author

FlorinCusmereanu commented Dec 19, 2023

hello @mtrezza and thanks for the reply.
that context object is the only context reference I have in the Preview component.
do you or anyone else know how to do it better? or know what is wrong? or what am I doing wrong, if any?

Now I have a new one with

@Preview(showBackground = true)
@Composable
fun PostViewPreview() {

    val configuration = Parse.Configuration
        .Builder(LocalContext.current)
        .applicationId("****")
        .server("****")
        .build()
    Parse.initialize(configuration)
    Parse.enableLocalDatastore(LocalContext.current)

    ParseObject.registerSubclass(User::class.java)
    ParseObject.registerSubclass(UserInspiration::class.java)
    val user = User()
    user.uniqueDisplayName = "John Doe"
    val userInspiration = UserInspiration()
    userInspiration.user = user
    userInspiration.title = "Something to test #test"
    PostView(userInspiration = userInspiration)
}

java.lang.NullPointerException: Cannot invoke "java.io.File.getAbsolutePath()" because the return value of "com.parse.ParseCacheDirMigrationUtils.getOldParseDir(android.content.Context)" is null   at com.parse.ParseCacheDirMigrationUtils.runSilentMigration(ParseCacheDirMigrationUtils.java:30)

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

2 participants