-
Notifications
You must be signed in to change notification settings - Fork 0
Example app #42
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
Merged
Merged
Example app #42
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
21dae33
feat(app) added example app
YYChen01988 ad0a14e
feat(app) removed platform class and make api-key a share value
YYChen01988 a87b69a
feat(app) added fatal crash
YYChen01988 51a03cf
feat(app) replaced icons
YYChen01988 4decc94
feat(app) added js app
YYChen01988 4ea7a8a
feat(app) added ios app icons
YYChen01988 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
*.iml | ||
.kotlin | ||
.gradle | ||
**/build/ | ||
xcuserdata | ||
!src/**/build/ | ||
local.properties | ||
.idea | ||
.DS_Store | ||
captures | ||
.externalNativeBuild | ||
.cxx | ||
*.xcodeproj/* | ||
!*.xcodeproj/project.pbxproj | ||
!*.xcodeproj/xcshareddata/ | ||
!*.xcodeproj/project.xcworkspace/ | ||
!*.xcworkspace/contents.xcworkspacedata | ||
**/xcshareddata/WorkspaceSettings.xcsettings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
This is a Kotlin Multiplatform project targeting Android, iOS. | ||
|
||
* `/composeApp` is for code that will be shared across your Compose Multiplatform applications. | ||
It contains several subfolders: | ||
- `commonMain` is for code that’s common for all targets. | ||
- Other folders are for Kotlin code that will be compiled for only the platform indicated in the folder name. | ||
For example, if you want to use Apple’s CoreCrypto for the iOS part of your Kotlin app, | ||
`iosMain` would be the right folder for such calls. | ||
|
||
* `/iosApp` contains iOS applications. Even if you’re sharing your UI with Compose Multiplatform, | ||
you need this entry point for your iOS app. This is also where you should add SwiftUI code for your project. | ||
|
||
|
||
Learn more about [Kotlin Multiplatform](https://www.jetbrains.com/help/kotlin-multiplatform-dev/get-started.html)… |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
plugins { | ||
alias(libs.plugins.androidApplication) apply false | ||
alias(libs.plugins.androidLibrary) apply false | ||
alias(libs.plugins.composeMultiplatform) apply false | ||
alias(libs.plugins.composeCompiler) apply false | ||
alias(libs.plugins.kotlinMultiplatform) apply false | ||
alias(libs.plugins.bugsnag.gradle) apply false | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
|
||
plugins { | ||
alias(libs.plugins.kotlinMultiplatform) | ||
alias(libs.plugins.androidApplication) | ||
alias(libs.plugins.composeMultiplatform) | ||
alias(libs.plugins.composeCompiler) | ||
alias(libs.plugins.bugsnag.gradle) | ||
} | ||
|
||
kotlin { | ||
androidTarget { | ||
@OptIn(ExperimentalKotlinGradlePluginApi::class) | ||
compilerOptions { | ||
jvmTarget.set(JvmTarget.JVM_11) | ||
} | ||
} | ||
|
||
listOf( | ||
iosX64(), | ||
iosArm64(), | ||
iosSimulatorArm64() | ||
).forEach { iosTarget -> | ||
iosTarget.binaries.framework { | ||
baseName = "ComposeApp" | ||
isStatic = true | ||
} | ||
} | ||
|
||
sourceSets { | ||
|
||
androidMain.dependencies { | ||
implementation(compose.preview) | ||
implementation(libs.androidx.activity.compose) | ||
} | ||
commonMain.dependencies { | ||
implementation(compose.runtime) | ||
implementation(compose.foundation) | ||
implementation(compose.material3) | ||
implementation(compose.ui) | ||
implementation(compose.components.resources) | ||
implementation(compose.components.uiToolingPreview) | ||
implementation(libs.androidx.lifecycle.viewmodel) | ||
implementation(libs.androidx.lifecycle.runtimeCompose) | ||
implementation(libs.bugsnag.kmp) | ||
} | ||
commonTest.dependencies { | ||
implementation(libs.kotlin.test) | ||
} | ||
} | ||
} | ||
|
||
android { namespace = "com.example.bugsnag.kmp.android" | ||
compileSdk = 35 | ||
YYChen01988 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
defaultConfig { | ||
applicationId = "com.example.bugsnag.kmp.android" | ||
minSdk = 24 | ||
targetSdk = 35 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
} | ||
buildFeatures { | ||
compose = true | ||
} | ||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
buildTypes { | ||
getByName("release") { | ||
isMinifyEnabled = false | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(libs.androidx.appcompat) | ||
debugImplementation(compose.uiTooling) | ||
YYChen01988 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
implementation(libs.bugsnag.android) | ||
implementation(libs.bugsnag.okhttp) | ||
implementation(libs.squareup.okhttp3) | ||
YYChen01988 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
implementation(libs.bugsnag.kmp) | ||
} |
25 changes: 25 additions & 0 deletions
25
example/BugsnagExample/composeApp/src/androidMain/AndroidManifest.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@android:style/Theme.Material.Light.NoActionBar"> | ||
<activity | ||
android:exported="true" | ||
android:name="com.example.bugsnag.kmp.MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<meta-data | ||
android:name="com.bugsnag.android.API_KEY" | ||
android:value="your-api-key" /> | ||
YYChen01988 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</application> | ||
|
||
</manifest> |
73 changes: 73 additions & 0 deletions
73
.../BugsnagExample/composeApp/src/androidMain/kotlin/com/example/bugsnag/kmp/MainActivity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.example.bugsnag.kmp | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import com.bugsnag.kmp.BreadcrumbType | ||
import com.bugsnag.kmp.Bugsnag | ||
import com.bugsnag.kmp.Configuration | ||
|
||
class MainActivity : ComponentActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
val config = Configuration(applicationContext) | ||
Bugsnag.start(config) | ||
|
||
|
||
setContent { | ||
Surface( | ||
modifier = Modifier.fillMaxSize(), | ||
color = MaterialTheme.colorScheme.background, | ||
) { | ||
MainScreen() | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun MainScreen() { | ||
YYChen01988 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(16.dp), | ||
verticalArrangement = Arrangement.spacedBy(12.dp), | ||
) { | ||
Text("Bugsnag KMP - Android example app") | ||
|
||
Button( | ||
onClick = { | ||
Bugsnag.notify(RuntimeException("Fatal Crash")) | ||
}, | ||
modifier = Modifier.fillMaxWidth(), | ||
) { | ||
Text("Trigger A Fatal Crash") | ||
} | ||
|
||
Button( | ||
onClick = { | ||
Bugsnag.leaveBreadcrumb("LoginButtonClick") | ||
|
||
val metadata = mapOf(Pair("reason", "incorrect password")) | ||
Bugsnag.leaveBreadcrumb("WebAuthFailure", metadata, BreadcrumbType.ERROR) | ||
Bugsnag.notify(RuntimeException("Error Report with Breadcrumbs")) | ||
}, | ||
modifier = Modifier.fillMaxWidth(), | ||
) { | ||
Text("Attach Custom Breadcrumbs") | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...snagExample/composeApp/src/androidMain/kotlin/com/example/bugsnag/kmp/Platform.android.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.example.bugsnag.kmp | ||
|
||
import android.os.Build | ||
|
||
class AndroidPlatform : Platform { | ||
override val name: String = "Android ${Build.VERSION.SDK_INT}" | ||
} | ||
|
||
actual fun getPlatform(): Platform = AndroidPlatform() |
30 changes: 30 additions & 0 deletions
30
...ple/BugsnagExample/composeApp/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:aapt="http://schemas.android.com/aapt" | ||
android:width="108dp" | ||
android:height="108dp" | ||
android:viewportWidth="108" | ||
android:viewportHeight="108"> | ||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z"> | ||
<aapt:attr name="android:fillColor"> | ||
<gradient | ||
android:endX="85.84757" | ||
android:endY="92.4963" | ||
android:startX="42.9492" | ||
android:startY="49.59793" | ||
android:type="linear"> | ||
<item | ||
android:color="#44000000" | ||
android:offset="0.0" /> | ||
<item | ||
android:color="#00000000" | ||
android:offset="1.0" /> | ||
</gradient> | ||
</aapt:attr> | ||
</path> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:fillType="nonZero" | ||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z" | ||
android:strokeWidth="1" | ||
android:strokeColor="#00000000" /> | ||
</vector> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.