Skip to content

Commit faed860

Browse files
fixes
1 parent 4d83504 commit faed860

File tree

24 files changed

+220
-201
lines changed

24 files changed

+220
-201
lines changed

examples/KMPSharedUI/composeApp/build.gradle.kts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ kotlin {
6666
implementation(compose.components.uiToolingPreview)
6767
implementation(libs.androidx.lifecycle.viewmodel)
6868
implementation(libs.androidx.lifecycle.runtimeCompose)
69-
implementation(libs.kotlinx.serialization.json)
70-
7169
}
7270
commonTest.dependencies {
7371
implementation(libs.kotlin.test)
@@ -76,11 +74,11 @@ kotlin {
7674
}
7775

7876
android {
79-
namespace = "org.example.project"
77+
namespace = "com.example.bugsnag.kmp.sharedui"
8078
compileSdk = libs.versions.android.compileSdk.get().toInt()
8179

8280
defaultConfig {
83-
applicationId = "org.example.project"
81+
applicationId = "com.example.bugsnag.kmp.sharedui"
8482
minSdk = libs.versions.android.minSdk.get().toInt()
8583
targetSdk = libs.versions.android.targetSdk.get().toInt()
8684
versionCode = 1
@@ -98,7 +96,7 @@ android {
9896
}
9997
buildTypes {
10098
getByName("release") {
101-
isMinifyEnabled = false
99+
isMinifyEnabled = true
102100
}
103101
}
104102
compileOptions {
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
package org.example.project
1+
package com.example.bugsnag.kmp.sharedui
22

33
import android.os.Bundle
44
import androidx.activity.ComponentActivity
55
import androidx.activity.compose.setContent
66
import androidx.activity.enableEdgeToEdge
7-
import androidx.compose.runtime.Composable
8-
import androidx.compose.ui.tooling.preview.Preview
97
import com.bugsnag.kmp.Configuration
108

119
class MainActivity : ComponentActivity() {
@@ -19,9 +17,3 @@ class MainActivity : ComponentActivity() {
1917
}
2018
}
2119
}
22-
23-
@Preview
24-
@Composable
25-
fun AppAndroidPreview() {
26-
App()
27-
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.example.project
1+
package com.example.bugsnag.kmp.sharedui
22

33
class NativeCaller {
44
init {
@@ -8,4 +8,4 @@ class NativeCaller {
88
external fun throwNative();
99

1010
external fun throwNativeANR();
11-
}
11+
}

examples/KMPSharedUI/composeApp/src/androidMain/kotlin/org/example/project/Platform.android.kt renamed to examples/KMPSharedUI/composeApp/src/androidMain/kotlin/com/example/bugsnag/kmp/sharedui/Platform.android.kt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
package org.example.project
2-
3-
import android.os.Build
4-
5-
class AndroidPlatform : Platform {
6-
override val name: String = "Android ${Build.VERSION.SDK_INT}"
7-
}
8-
9-
actual fun getPlatform(): Platform = AndroidPlatform()
1+
package com.example.bugsnag.kmp.sharedui
102

113
actual fun getPlatformName(): String {
124
return "Android"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.example.bugsnag.kmp.sharedui
2+
3+
import androidx.compose.foundation.layout.Column
4+
import androidx.compose.foundation.layout.fillMaxSize
5+
import androidx.compose.foundation.layout.safeContentPadding
6+
import androidx.compose.material3.MaterialTheme
7+
import androidx.compose.runtime.Composable
8+
import androidx.compose.ui.Alignment
9+
import androidx.compose.ui.Modifier
10+
import com.bugsnag.kmp.Bugsnag
11+
import org.jetbrains.compose.ui.tooling.preview.Preview
12+
13+
@Composable
14+
@Preview
15+
fun App() {
16+
MaterialTheme {
17+
Column(
18+
modifier = Modifier
19+
.safeContentPadding()
20+
.fillMaxSize(),
21+
horizontalAlignment = Alignment.CenterHorizontally,
22+
) {
23+
24+
TextButton(
25+
text = "Throw error",
26+
onClick = { throw Exception("Compose throw on ${getPlatformName()}") }
27+
)
28+
TextButton(
29+
text = "Throw native error",
30+
onClick = { throwNative() }
31+
)
32+
TextButton(
33+
text = "Trigger not responding error",
34+
onClick = { throwNotResponding() }
35+
)
36+
TextButton(
37+
text = "Notify error",
38+
onClick = { Bugsnag.notify(Exception("Bugsnag notify on ${getPlatformName()}")) }
39+
)
40+
TextButton(
41+
text = "Leave breadcrumb",
42+
onClick = { Bugsnag.leaveBreadcrumb("Button clicked on ${getPlatformName()}") }
43+
)
44+
TextButton(
45+
text = "Add metadata",
46+
onClick = { Bugsnag.addMetadata("Kotlin", "multi", "platform") }
47+
)
48+
}
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.example.project
1+
package com.example.bugsnag.kmp.sharedui
22

33
import com.bugsnag.kmp.Bugsnag
44
import com.bugsnag.kmp.Configuration
@@ -7,4 +7,4 @@ fun startBugsnag(configuration: Configuration) {
77
configuration.addMetadata("App", "multiplatform", true)
88
configuration.addMetadata("App", "platform", getPlatformName())
99
Bugsnag.start(configuration)
10-
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.example.bugsnag.kmp.sharedui
2+
3+
import androidx.compose.material3.Button
4+
import androidx.compose.material3.Text
5+
import androidx.compose.runtime.Composable
6+
import androidx.compose.ui.Modifier
7+
8+
@Composable
9+
fun TextButton(
10+
text: String,
11+
onClick: () -> Unit,
12+
modifier: Modifier = Modifier
13+
) {
14+
Button(
15+
onClick = onClick,
16+
modifier = modifier
17+
) {
18+
Text(text)
19+
}
20+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.example.bugsnag.kmp.sharedui
2+
3+
expect fun getPlatformName(): String
4+
5+
expect fun getPlatformBugsnagKey(): String
6+
7+
expect fun throwNative()
8+
9+
expect fun throwNotResponding()

examples/KMPSharedUI/composeApp/src/commonMain/kotlin/org/example/project/App.kt

Lines changed: 0 additions & 44 deletions
This file was deleted.

examples/KMPSharedUI/composeApp/src/commonMain/kotlin/org/example/project/Greeting.kt

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)