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

java.lang.NoSuchMethod: com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(Ljava/util/Comparator;)Ljava/util/stream/Collector; Label: help wanted #3538

Closed
lzrdboy opened this issue Nov 16, 2017 · 16 comments

Comments

@lzrdboy
Copy link

lzrdboy commented Nov 16, 2017

I'm relatively new with test automation in android, but I've run into some issues and I can't seem to work out what the issue is.

I've been running tests with junit / selenium server and appium. I wanted to take advantage of the toast functionality in robolectric. I added robo into my dependencies:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile project(':sdk')
    testCompile files('libs/java-client-5.0.4.jar')
    testCompile files('libs/selenium-server-standalone-3.7.1.jar')
    testCompile "org.robolectric:robolectric:3.5.1"
}

I haven't even added anything else into my tests yet, but if I try to run them this occurs:

java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(Ljava/util/Comparator;)Ljava/util/stream/Collector;

	at org.openqa.selenium.remote.NewSessionPayload.lambda$validate$4(NewSessionPayload.java:197)
	at java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:372)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:373)
	at java.util.Iterator.forEachRemaining(Iterator.java:116)
	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
	at org.openqa.selenium.remote.NewSessionPayload.validate(NewSessionPayload.java:213)
	at org.openqa.selenium.remote.NewSessionPayload.<init>(NewSessionPayload.java:161)
	at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:112)
	at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:105)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
	at com.realwear.camera.cameraTests.setUp(cameraTests.java:42)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)


java.lang.NullPointerException
	at com.realwear.camera.cameraTests.End(cameraTests.java:72)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)


If I remove the dependency, and try and run the tests they will work fine again.

I might be doing something completely wrong with the setup, but I was just wondering if anyone had any insight into what was happening and if there was a way I could resolve this?

@lzrdboy
Copy link
Author

lzrdboy commented Nov 16, 2017

I have resolved the issue now, I set up my framework incorrect. Thanks.

@maanj
Copy link

maanj commented Nov 23, 2017

@lzrdboy How you resolved that issue, i am also getting the same error

@Anojan
Copy link

Anojan commented Dec 8, 2017

Please provide the solution here. I'm facing the same error as well.

@jongerrish
Copy link
Contributor

jongerrish commented Dec 8, 2017 via email

@rajoberoi
Copy link

@lzrdboy,

I am having the same issue can you please submit the solution here.

Thanks

@mstefan7
Copy link

@rajoberoi this should be resolved by updating your version of guava, it worked at least for me (using v23)

@darkainsoul
Copy link

darkainsoul commented Feb 15, 2018

I fix this updating the guava version I just add the most recent version to my pom.xml fie

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>24.0-jre</version>
</dependency>

@fkqa11
Copy link

fkqa11 commented Nov 28, 2018

I fix this updating the guava version I just add the most recent version to my pom.xml fie

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>24.0-jre</version>
</dependency>

Thanks for this solution

@vijayjdk
Copy link

Hi,
I am also new to Appium and facing the same error I tried with the above dependency and that error is removed. However, I am facing new error now please help me to resolve this

Please help me to get it resolved

An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: 'Command 'D:\Office\Appium\android-sdk\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 4b1e2357cf40 shell pm install -g /data/local/tmp/appium_cache/3d97225b036c28750562ef8962defee6b1af19a4.apk' exited with code 1'; Stderr: 'Error: java.lang.SecurityException: You need the android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS permission to use the PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS flag'; Code: '1'
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'VIJAY', ip: '10.60.1.106', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_231'
Driver info: driver.version: AndroidDriver

@katebygrace
Copy link

Also seeing this issue, but my Guava version is set in the build.gradle file to 28. Is there anywhere else it lives that I'd need to change?

@katebygrace
Copy link

FYI If you're a random on the internet searching for the solution! it NEEDs to be the -jre version of guava. The -android version of guava does not work. guava:28.1-jre worked for me (but guava:28.1-android does not)

@hoisie
Copy link
Contributor

hoisie commented Sep 10, 2020

Awesome, thanks for sharing that info @katebygrace. Closing this issue. If anyone else has this problem and updating to the -jre version of guava does not work, let me know and I'll reopen.

@hoisie hoisie closed this as completed Sep 10, 2020
@Dsilva-Rohan
Copy link

Dsilva-Rohan commented Sep 12, 2020

Error
exception in thread "main" java.lang.nosuchmethoderror: com.google.common.collect.immutablesortedset.toimmutablesortedset(ljava/util/comparator;)ljava/util/stream/collector; at org.openqa.selenium.remote.newsessionpayload.lambda$validate$3(newsessionpayload.java:191)

Solution:
This Issue you can fix by updating below dependency:

com.google.guava
guava
24.0-jre

Use below version of chrome : Version 85.0.4183.102 (Official Build) (64-bit)

@UmeshChakre
Copy link

can someone show how to fix this in gradle,
i tried adding guava dependency

` //guava
implementation("com.google.guava:guava:29.0-android")

api 'com.google.guava:guava:29.0-android'`

but it didnt worked!

@UmeshChakre
Copy link

FYI If you're a random on the internet searching for the solution! it NEEDs to be the -jre version of guava. The -android version of guava does not work. guava:28.1-jre worked for me (but guava:28.1-android does not)

@katebygrace , it didnt work !!
still gives initialization error

java.lang.NoSuchMethodError: com.google.common.collect.ImmutableList.sortedCopyOf(Ljava/util/Comparator;Ljava/lang/Iterable;)Lcom/google/common/collect/ImmutableList;

at org.robolectric.internal.bytecode.ShadowProviders.<init>(ShadowProviders.java:25)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.robolectric.util.inject.Injector.inject(Injector.java:239)
at org.robolectric.util.inject.Injector.lambda$memoized$1(Injector.java:221)
at org.robolectric.util.inject.Injector$MemoizingProvider.get(Injector.java:485)
at org.robolectric.util.inject.Injector.getInstanceInternal(Injector.java:213)
at org.robolectric.util.inject.Injector.getInstance(Injector.java:197)
at org.robolectric.util.inject.Injector.getInstance(Injector.java:191)
at org.robolectric.internal.SandboxTestRunner.<init>(SandboxTestRunner.java:75)
at org.robolectric.RobolectricTestRunner.<init>(RobolectricTestRunner.java:101)
at org.robolectric.RobolectricTestRunner.<init>(RobolectricTestRunner.java:96)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:36)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)

@prashantranjan816
Copy link

Just Add bellow dependency to your POM.xml
<dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>24.0-jre</version> </dependency>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests