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

On generated MSI file getting error "failed to launch JVM" error" But in emulator every thing is OK. #21

Open
MrJabborbek opened this issue Aug 12, 2024 · 3 comments

Comments

@MrJabborbek
Copy link

I am initializing Firebase in desktop side like this, if i commented firebsase initializationsnot getting error, so error is in initialization:

import android.app.Application
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
import com.google.firebase.FirebasePlatform
import dev.gitlive.firebase.Firebase
import dev.gitlive.firebase.FirebaseOptions
import dev.gitlive.firebase.initialize

fun main() = application {
FirebasePlatform.initializeFirebasePlatform(object : FirebasePlatform() {

    val storage = mutableMapOf<String, String>()
    override fun clear(key: String) {
        storage.remove(key)
    }

    override fun log(msg: String) = println(msg)

    override fun retrieve(key: String) = storage[key]

    override fun store(key: String, value: String) = storage.set(key, value)

})

val options = FirebaseOptions(
    projectId = "some_id",
    applicationId = "app_id_here",
    apiKey = "api_key_here",
)


Firebase.initialize(Application(), options)

Window(
    onCloseRequest = ::exitApplication,
    title = "KotlinProject",
) {
    App()
}

}

@nbransby nbransby transferred this issue from GitLiveApp/firebase-kotlin-sdk Aug 12, 2024
@nbransby
Copy link
Member

Are you able to get more information about the error such as a full stack trace?

@JacobCube
Copy link

Perhaps related to this, whenever I run ./gradlew runReleaseDistributable I get an error Exception in thread "main" java.lang.NoClassDefFoundError: java/lang/management/ManagementFactory.

Full stacktrace:

Task :composeApp:runReleaseDistributable

Exception in thread "main" java.lang.NoClassDefFoundError: java/lang/management/ManagementFactory
	at android.os.SystemClock.elapsedRealtime(SystemClock.java:7)
	at com.google.firebase.StartupTime.now(StartupTime.java:54)
	at com.google.firebase.provider.FirebaseInitProvider.<clinit>(FirebaseInitProvider.java:38)
	at com.google.firebase.FirebaseApp.<init>(FirebaseApp.java:412)
	at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:296)
	at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:264)
	at com.google.firebase.FirebaseKt.initialize(Firebase.kt:49)
	at MainKt.initializeFirebase(main.kt:115)
	at MainKt.initializeFirebase$default(main.kt:95)
	at ComposableSingletons$MainKt$lambda-2$1.invoke(main.kt:43)
	at ComposableSingletons$MainKt$lambda-2$1.invoke(main.kt:38)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jb.kt:116)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jb.kt:33)
	at androidx.compose.ui.window.Application_desktopKt$application$1$1.invoke(Application.desktop.kt:117)
	at androidx.compose.ui.window.Application_desktopKt$application$1$1.invoke(Application.desktop.kt:116)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jb.kt:116)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jb.kt:33)
	at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2$1$1.invoke(Application.desktop.kt:233)
	at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2$1$1.invoke(Application.desktop.kt:232)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jb.kt:107)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jb.kt:33)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:380)
	at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2$1.invoke(Application.desktop.kt:223)
	at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2$1.invoke(Application.desktop.kt:221)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jb.kt:107)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jb.kt:33)
	at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:33)
	at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3595)
	at androidx.compose.runtime.ComposerImpl.composeContent$runtime(Composer.kt:3522)
	at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:743)
	at androidx.compose.runtime.Recomposer.composeInitial$runtime(Recomposer.kt:1114)
	at androidx.compose.runtime.CompositionImpl.composeInitial(Composition.kt:649)
	at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:635)
	at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2.invokeSuspend(Application.desktop.kt:221)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: java.lang.management.ManagementFactory
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	... 49 more

Seems to be this method

public static long elapsedRealtime() {
        return ManagementFactory.getRuntimeMXBean().getUptime();
    }

@nbransby
Copy link
Member

Ah yes that method is not available on all runtimes but firebase depends on it, would be great to find another way to get the time since last reboot although I suspect replacing this with simply the time since the application started would suffice

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

3 participants