From 5377ef0ef1700a0e58c28f517988f0494735300c Mon Sep 17 00:00:00 2001 From: sandeeppadala Date: Thu, 3 Oct 2024 12:42:22 -0700 Subject: [PATCH] feat: Add KMP module Added a new KMP module named "shared" to the project. This module includes: - Support for Android and iOS platforms. - A function `createCrashInKMPModule` in the Android source set that triggers a crash. - Basic unit tests for both Android and common source sets. This change also involved updating the app module to trigger the crash from the KMP module and upgrading Gradle to version 8. 10.2. --- app/build.gradle | 3 +- .../appqualityinsightsqaapp/MainActivity.java | 9 +- app/src/main/res/layout/content_main.xml | 10 ++ build.gradle | 8 +- flavorsModule/build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- lib/build.gradle | 3 + settings.gradle | 5 + shared/build.gradle.kts | 103 ++++++++++++++++++ .../opted/shared/ExampleInstrumentedTest.kt | 27 +++++ shared/src/androidMain/AndroidManifest.xml | 4 + .../filters/opted/shared/Platform.android.kt | 9 ++ .../filters/opted/shared/ExampleUnitTest.kt | 16 +++ .../dynamic/filters/opted/shared/Platform.kt | 3 + .../filters/opted/shared/Platform.ios.kt | 3 + 15 files changed, 200 insertions(+), 7 deletions(-) create mode 100644 shared/build.gradle.kts create mode 100644 shared/src/androidInstrumentedTest/kotlin/com/google/play/dynamic/filters/opted/shared/ExampleInstrumentedTest.kt create mode 100644 shared/src/androidMain/AndroidManifest.xml create mode 100644 shared/src/androidMain/kotlin/com/google/play/dynamic/filters/opted/shared/Platform.android.kt create mode 100644 shared/src/androidUnitTest/kotlin/com/google/play/dynamic/filters/opted/shared/ExampleUnitTest.kt create mode 100644 shared/src/commonMain/kotlin/com/google/play/dynamic/filters/opted/shared/Platform.kt create mode 100644 shared/src/iosMain/kotlin/com/google/play/dynamic/filters/opted/shared/Platform.ios.kt diff --git a/app/build.gradle b/app/build.gradle index 12fc47f..34780b0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,7 +18,7 @@ android { defaultConfig { applicationId "com.quality.appqualityinsightsqaapp" - minSdk 24 + minSdk 27 targetSdk 34 versionCode 6 versionName "6.0" @@ -61,4 +61,5 @@ dependencies { testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + implementation(project(":shared")) } \ No newline at end of file diff --git a/app/src/main/java/com/example/appqualityinsightsqaapp/MainActivity.java b/app/src/main/java/com/example/appqualityinsightsqaapp/MainActivity.java index 6a63569..93f4cce 100644 --- a/app/src/main/java/com/example/appqualityinsightsqaapp/MainActivity.java +++ b/app/src/main/java/com/example/appqualityinsightsqaapp/MainActivity.java @@ -2,6 +2,7 @@ import static com.example.lib.JavaLibraryClass.createCrashInJavaLibrary; import static com.example.mylibrary.AndroidLibraryClass.createCrashInAndroidLibrary; +import static com.google.play.dynamic.filters.opted.shared.Platform_androidKt.createCrashInKMPModule; import android.content.Intent; import android.os.Bundle; @@ -36,6 +37,7 @@ public class MainActivity extends AppCompatActivity { Button andLibButton2; Button javalibCrash; Button realLifeCrashScenario; + Button kmpCrash; @Override protected void onCreate(Bundle savedInstanceState) { @@ -67,12 +69,14 @@ protected void onCreate(Bundle savedInstanceState) { public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); - throw new RuntimeException("Test Crash vcs"); + throw new RuntimeException("Test Crash vcs"); + } }); andLibButton=findViewById(R.id.and_lib_crash); andLibButton2=findViewById(R.id.and_lib_crash2); javalibCrash=findViewById(R.id.java_lib_crash); + kmpCrash=findViewById(R.id.kmp_crash); realLifeCrashScenario = findViewById(R.id.real_life_crash_scenario); andLibButton.setOnClickListener(new View.OnClickListener() { @@ -104,6 +108,9 @@ public void onClick(View view) { realLifeCrashScenario.setOnClickListener(v -> { startActivity(new Intent(this, RealCrashScenariosMainActivity.class)); }); + kmpCrash.setOnClickListener(v -> { + createCrashInKMPModule(); + }); } @Override diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index 975016e..f93d8f2 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -1,6 +1,7 @@ @@ -70,4 +71,13 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> +