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

Robolectric tests fail to run after declaring purchases-kmp dependency #271

Open
6 of 10 tasks
jadlr opened this issue Nov 29, 2024 · 2 comments
Open
6 of 10 tasks
Labels
bug Something isn't working

Comments

@jadlr
Copy link

jadlr commented Nov 29, 2024

Describe the bug
After adding the purchases-kmp library to an android kmp project the androidUnitTest using robolectric stop working. It seems to have something to with the an amazon dependency.

  1. Environment
    1. Platform: Android
    2. SDK version: "1.3.2+13.9.0"
    3. OS version:
    4. IDE (e.g. Android Studio, Xcode, Fleet): Android Studio
    5. IDE version: Android Studio Koala | 2024.1.1 Patch 2 / Build #AI-241.18034.62.2411.12169540
    6. Device and/or emulator/simulator:
      • Device
      • Emulator/simulator
    7. Environment:
      • Closed testing / Sandbox
      • TestFlight
      • Production
    8. How widespread is the issue. Percentage of devices affected.
  2. Debug logs that reproduce the issue
  3. Steps to reproduce, with a description of expected vs. actual behavior

Expected bahavior would be that the tests run

Steps to reproduce:

  • Write a simple robolectric test in androidUnitTest in shared
  • Add purchases-kmp depencendy
  • Run test
  1. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to
    have context, eg. stackoverflow, etc.)
Expecting a stackmap frame at branch target 11
Exception Details:
  Location:
    com/amazon/device/iap/ResponseReceiver.onReceive(Landroid/content/Context;Landroid/content/Intent;)V @0: invokestatic
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0000000: b800 0c2b 2cb6 000b a700 1d4e b200 09bb
    0000010: 0008 59b7 000f 1201 b600 112d b600 10b6
    0000020: 0012 b800 0db1                         
  Exception Handler Table:
    bci [0, 8] => handler: 11

java.lang.VerifyError: Expecting a stackmap frame at branch target 11
Exception Details:
  Location:
    com/amazon/device/iap/ResponseReceiver.onReceive(Landroid/content/Context;Landroid/content/Intent;)V @0: invokestatic
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0000000: b800 0c2b 2cb6 000b a700 1d4e b200 09bb
    0000010: 0008 59b7 000f 1201 b600 112d b600 10b6
    0000020: 0012 b800 0db1                         
  Exception Handler Table:
    bci [0, 8] => handler: 11

	at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
	at java.base/java.lang.Class.getConstructor0(Unknown Source)
	at java.base/java.lang.Class.getDeclaredConstructor(Unknown Source)
	at org.robolectric.util.ReflectionHelpers.callConstructor(ReflectionHelpers.java:519)
	at org.robolectric.internal.bytecode.ShadowImpl.newInstanceOf(ShadowImpl.java:19)
	at org.robolectric.shadow.api.Shadow.newInstanceOf(Shadow.java:39)
	at org.robolectric.android.internal.AndroidTestEnvironment.registerBroadcastReceivers(AndroidTestEnvironment.java:656)
	at org.robolectric.android.internal.AndroidTestEnvironment.installAndCreateApplication(AndroidTestEnvironment.java:364)
	at org.robolectric.android.internal.AndroidTestEnvironment.lambda$createApplicationSupplier$0(AndroidTestEnvironment.java:262)
	at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:51)
	at org.robolectric.android.internal.AndroidTestEnvironment.lambda$createApplicationSupplier$1(AndroidTestEnvironment.java:259)
	at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:200)
	at org.robolectric.RuntimeEnvironment.lambda$getApplication$0(RuntimeEnvironment.java:71)
	at org.robolectric.shadows.ShadowInstrumentation.runOnMainSyncNoIdle(ShadowInstrumentation.java:1190)
	at org.robolectric.RuntimeEnvironment.getApplication(RuntimeEnvironment.java:71)
	at org.robolectric.android.internal.AndroidTestEnvironment.setUpApplicationState(AndroidTestEnvironment.java:230)
	at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:284)
	at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$2(SandboxTestRunner.java:279)
	at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:104)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

Additional context

Robolectric version 4.14.1
Junit 4.13.2

@jadlr jadlr added the bug Something isn't working label Nov 29, 2024
@JayShortway
Copy link
Member

Hi @jadlr, thanks for reporting this. Do you have a reproducer project for me to try? I followed the steps you shared, but it doesn't reproduce for me, so it would be good to ensure we are working with the same code. Also, which JVM version are you using to build and run the tests? Thanks in advance!

@jadlr
Copy link
Author

jadlr commented Dec 2, 2024

Thanks for taking a look into this @JayShortway! I'll try to create a repo that reproduces the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants