Dec
6
21 hours ago
Activity icon
issue

utzcoz issue comment robolectric/robolectric

utzcoz
utzcoz

Add custom JNI_INCLUDE_DIRS for Windows only

See related discussion at https://github.com/robolectric/robolectric/pull/6911.

utzcoz
utzcoz

I force-pushed it with consistent code format for if, else and endif.

Activity icon
issue

hoisie issue comment robolectric/robolectric

hoisie
hoisie

java.lang.RuntimeException: no artifacts found for DependencyJar{org.robolectric:android-all:10-robolectric-5803371}

Description

After updating to JDK 11 and compiling SDK 31 (Android S). I am getting the following issue.

java.lang.RuntimeException: no artifacts found for DependencyJar{org.robolectric:android-all:10-robolectric-5803371}
	at org.robolectric.internal.dependency.PropertiesDependencyResolver.getLocalArtifactUrl(PropertiesDependencyResolver.java:61)
	at org.robolectric.plugins.LegacyDependencyResolver.getLocalArtifactUrl(LegacyDependencyResolver.java:89)
	at org.robolectric.plugins.DefaultSdkProvider$DefaultSdk.getJarPath(DefaultSdkProvider.java:127)
	at org.robolectric.android.internal.AndroidTestEnvironment.loadAppPackage_measured(AndroidTestEnvironment.java:321)
	at org.robolectric.android.internal.AndroidTestEnvironment.lambda$loadAppPackage$1(AndroidTestEnvironment.java:296)
	at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:53)
	at org.robolectric.android.internal.AndroidTestEnvironment.loadAppPackage(AndroidTestEnvironment.java:294)
	at org.robolectric.android.internal.AndroidTestEnvironment.installAndCreateApplication(AndroidTestEnvironment.java:195)
	at org.robolectric.android.internal.AndroidTestEnvironment.setUpApplicationState(AndroidTestEnvironment.java:171)
	at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:319)
	at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:254)
	at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:89)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

Robolectric & Android Version

Roboelectric Version - 4.4 Target SDK Version - 30 Compile SDK Version - 31

hoisie
hoisie
def androidSdkVersions = [
        '7.0.0_r1-robolectric-r1',
        '8.1.0-robolectric-4611349'
]

This only includes Android N and O_MR1. If you want S, you will need version 12.

pull request

utzcoz pull request robolectric/robolectric

utzcoz
utzcoz

Backport FindJNI.cmake from cmake v3.22.0

Backport FindJNI.cmake from cmake v3.22.0 with better Windows and aarch64 supporting.

Activity icon
issue

utzcoz issue comment robolectric/robolectric

utzcoz
utzcoz

Backport FindJNI.cmake from cmake v3.22.0

Backport FindJNI.cmake from cmake v3.22.0 with better Windows and aarch64 supporting.

utzcoz
utzcoz

I will test it on Windows, and close this PR.

Activity icon
issue

utzcoz issue comment robolectric/robolectric

utzcoz
utzcoz

Backport FindJNI.cmake from cmake v3.22.0

Backport FindJNI.cmake from cmake v3.22.0 with better Windows and aarch64 supporting.

utzcoz
utzcoz

What about just this? It seems like JAVA_HOME is required on Windows anyway, so a lot of the logic in findJni may not even be relevant for windows:

IF (WIN32)
  if(NOT DEFINED ENV{JAVA_HOME})
    message(FATAL_ERROR "JAVA_HOME is required in Windows")
  endif()
  # find_package JNI is broken on Windows, manually include header files
  set(JNI_INCLUDE_DIRS "$ENV{JAVA_HOME}/include" "$ENV{JAVA_HOME}/include/win32")
ELSE()
  find_package(JNI REQUIRED)
ENDIF()

It's more concise than before. I created a related PR https://github.com/robolectric/robolectric/pull/6914 for it.

pull request

utzcoz pull request robolectric/robolectric

utzcoz
utzcoz

Add custom JNI_INCLUDE_DIRS for Windows only

See related discussion at https://github.com/robolectric/robolectric/pull/6911.

Activity icon
issue

hoisie issue comment robolectric/robolectric

hoisie
hoisie

Feature Request: publish artifacts for running tests in JVM-only Gradle modules

Description

We have some JVM only Gradle modules in our project that ran tests using this jar file (undocumented, but it worked): .gradle/caches/modules-2/files-2.1/org.robolectric/android-all-instrumented/11-robolectric-6757853-i1/1b10f2a8f4abf22cfc86a2d23a09cc4fc4e22332/android-all-instrumented-11-robolectric-6757853-i1.jar But as of 4.6.x with pre-instrumented AAR files, this is no longer possible so we're stuck on 4.5.1.

Please publish artifacts that can be run against JVM only modules (non-Android). Our use case is we have tests for Sqlite (these modules are mostly DB access modules) and would like to run these using Robolectric. Rebuilding these as Android modules would slow our builds down and require a good amount of restructuring.

Steps to Reproduce

N.A.

Robolectric & Android Version

Robolectric 4.7.3

Link to a public git repo demonstrating the problem:

N.A.

hoisie
hoisie

4.6.x with pre-instrumented AAR files

There may be a misunderstanding, Robolectric does not work with AAR files.

Are the instrumented android-all jars being included in the compile-time classpath? This should not happen, and I have seen this cause issues before.

Activity icon
issue

hoisie issue comment robolectric/robolectric

hoisie
hoisie

Backport FindJNI.cmake from cmake v3.22.0

Backport FindJNI.cmake from cmake v3.22.0 with better Windows and aarch64 supporting.

hoisie
hoisie

What about just this? It seems like JAVA_HOME is required on Windows anyway, so a lot of the logic in findJni may not even be relevant for windows:

IF (WIN32)
  if(DEFINED ENV{JAVA_HOME})
    message(NOTICE "JAVA_HOME is $ENV{JAVA_HOME}")
  else()
    message(FATAL_ERROR "JAVA_HOME is required in Windows")
  endif()
  # find_package JNI is broken on Windows, manually include header files
  set(JNI_INCLUDE_DIRS "$ENV{JAVA_HOME}/include" "$ENV{JAVA_HOME}/include/win32")
ELSE()
  find_package(JNI REQUIRED)
ENDIF()
Activity icon
issue

utzcoz issue comment robolectric/robolectric

utzcoz
utzcoz

Backport FindJNI.cmake from cmake v3.22.0

Backport FindJNI.cmake from cmake v3.22.0 with better Windows and aarch64 supporting.

utzcoz
utzcoz

I renamed FindROBOJNI to FindJNI to try to fix warnings when testing it on Windows.