My app keeps crashing. Can't figure out where the issue is. I'm not even using okttp3 library.
Currently, I'm only using retrofit 1.9 and otto 1.3.8
java.lang.NoSuchMethodError: No virtual method callEnqueue(Lokhttp3/Call;Lokhttp3/Callback;Z)V in class Lokhttp3/internal/Internal; or its super classes (declaration of 'okhttp3.internal.Internal' appears in /data/app/com.myproj.sample-2/base.apk)
at okhttp3.ws.WebSocketCall.enqueue(WebSocketCall.java:108)
at io.socket.engineio.client.transports.WebSocket.doOpen(WebSocket.java:73)
at io.socket.engineio.client.Transport$1.run(Transport.java:75)
at io.socket.thread.EventThread.exec(EventThread.java:50)
at io.socket.engineio.client.Transport.open(Transport.java:70)
at io.socket.engineio.client.Socket.probe(Socket.java:458)
at io.socket.engineio.client.Socket.onOpen(Socket.java:471)
at io.socket.engineio.client.Socket.onHandshake(Socket.java:512)
at io.socket.engineio.client.Socket.onPacket(Socket.java:485)
at io.socket.engineio.client.Socket.access$900(Socket.java:30)
at io.socket.engineio.client.Socket$5.call(Socket.java:299)
at io.socket.emitter.Emitter.emit(Emitter.java:117)
at io.socket.engineio.client.Transport.onPacket(Transport.java:127)
at io.socket.engineio.client.transports.Polling$2.call(Polling.java:124)
at io.socket.engineio.parser.Parser.decodePayload(Parser.java:251)
at io.socket.engineio.client.transports.Polling._onData(Polling.java:134)
at io.socket.engineio.client.transports.Polling.onData(Polling.java:106)
at io.socket.engineio.client.transports.PollingXHR$5$1.run(PollingXHR.java:113)
at io.socket.thread.EventThread$2.run(EventThread.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Solved it with the help of this post.
Just add the following to your gradle dependecies.
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.okhttp3:okhttp-ws:3.4.1'
Try these dependencies :
implementation 'com.shopify.mobilebuysdk:buy3:3.2.3'
implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
Hope this may help you.
Related
When we want to move to another Activity using Intent in Kotlin, it gives this error.
In Intent, it doesn't recognize .java after ::class
look:
And when I delete .java, Intent gives an error
Note: My problem was not solved with Invalidate Caches / Restart... option in File
I don't know where the problem is. please help me.
Kinda strange because it seems good to me. Try this.
Remove the lateinit and declare it directly when you need it, maybe it will solve the problem.
val intent = Intent(this, LauncherActivity::class.java)
I don't think the this#KotlinActivity is needed in this case.
Let me know if this fix it
UPDATE
Are you sure the findViewById<TextView>... is correct ? Shouldn't it has a declaration before ? Like
val view = findViewById<>...
The solution is:
In build.gradle (:app) file, in dependencies, you should change appcompat version to 1.4.2.
befor error:
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.0'
...
}
And when I changed the version to 1.4.2, the problem was solved
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.2'
...
}
And make sure the kotlin version is 1.5.0
I am trying to add tests using latest (5.7.0) Mockito and using Mockito.mockStatic(...)
to mock class with static methods which works fine . However when I have class with static block it is unable to create mock and fais with java.lang.InternalError: class redefinition failed: invalid class .
Is this supported in latest mockito versions or still I have to live with other alternatives like powermock.
I did face the same error and couldn't find answer in the internet, so I see that it is 1 month old question but might help someone.
The problem was that mocked class (or classes that this static block used) was not in the classpath. Before you can mock the method all static blocks or fields initializators will be run, and it causes the problem.
You can verify what class is missing in your classpath by simply trying to use this static method before mocking it. You should get java.lang.NoClassDefFoundError with a class name.
When you resolve this problem, everything should work.
I had this issue, and for me it was due to an Error being thrown from instrumentation.retransformClasses called from org.mockito.internal.creation.bytebuddy.inlineBytecodeGenerator. Somewhere between there and findOrInsert in net.bytebuddy.TypeCache, the Throwable looses its context (for mockito-core 4.1.0 and bytebuddy 1.12.0)
In my case, the error being thrown was a NoClassDefFoundError for Jetty Servlet. This ultimately turned out to be a dodgy local build of a different maven module I had been working on, so clearing out my ~/.m2 and downloading a legit version fixed that right up.
You might be able to catch the Error being thrown in inlineBytecodeGenerator and taking a look at what's really going on, if this is in fact the same problem.
In an Android Kotlin project, I implemented EncryptedSharedPreference feature based on this link using the androidx.security library and it worked well in debug mode. But in release mode, I keep getting this error
java.lang.ExceptionInInitializerError
at com.package_name.i.a.f(:46)
at com.package_name.i.a.j(:52)
at com.package_name.i.a.e(:82)
at com.package_name.MyApplication.onCreate(:37)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.RuntimeException: Field keySize_ for k.a.d.a.h0.u not found. Known fields are [private int k.a.d.a.h0.u.i, private static final k.a.d.a.h0.u k.a.d.a.h0.u.j, private static volatile k.a.d.a.i0.a.a1 k.a.d.a.h0.u.k]
at k.a.d.a.i0.a.v0.n0(:608)
Please kindly share your ideas on how to solve this error.
This bug is related to Minify Enabled, which most likely causes some values to be removed.
A bug is reported already, you can track it here:
https://issuetracker.google.com/issues/157983099
-keep class com.google.crypto.** { *; }
Something is wrong with the rc2 version of android crypto of may 20. So it is better to use 1.0.0-alpha02 in your gradle file.
Remember, takes care with dependencies which are not in rc. You can also fix the issue with a proguard rules (see comment of Sebas LG).
dependencies {
implementation "androidx.security:security-crypto:1.0.0-alpha02"
}
Official documentation : https://developer.android.com/jetpack/androidx/releases/security
Linked commits : https://android.googlesource.com/platform/frameworks/support/+log/f66cdf1658639bd74ae850dfe3c1f5bb72eaebe6..6be101c2241593fee3ef9ab4e1fb337b485f2f9a/security/crypto
I solved using
dependencies {
..
implementation "androidx.security:security-crypto:1.0.0-rc03"
This is due to the fact that AndroidX security library uses the Google Tink library(This is already fixed in Tink 1.4.0), where there is a flaw in working with Proguard.
Add this code to proguard-rules.pro and this should help:
-keepclassmembers class * extends com.google.crypto.tink.shaded.protobuf.GeneratedMessageLite {
<fields>;
}
Links:
https://github.com/google/tink/issues/361
https://github.com/google/tink/blob/master/java_src/src/main/resources/META-INF/proguard/protobuf.pro
java.lang.NoClassDefFoundError:
org/junit/internal/AssumptionViolatedException at
org.spockframework.runtime.JUnitSupervisor.error(JUnitSupervisor.java:92)
at
org.spockframework.runtime.BaseSpecRunner.invokeRaw(BaseSpecRunner.java:318)
at
org.spockframework.runtime.BaseSpecRunner.invoke(BaseSpecRunner.java:297)
at
org.spockframework.runtime.BaseSpecRunner.runSpec(BaseSpecRunner.java:90)
at
org.spockframework.runtime.BaseSpecRunner.run(BaseSpecRunner.java:81)
at org.spockframework.runtime.Sputnik.run(Sputnik.java:63) at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
I have a simple test case that calls a method,
def 'some test for empty Lists'(){
setup:
List<Object> clauses=new ArrayList<Object>()
when:
String someString=builder.buildString(clauses, "someName", "AND");
then:
noExceptionThrown()
someString==""
}
Assume builder is injected via spring. I can't make out why this happens. It happens only for a few test cases.
Any help is much appreciated :) I use spock 0.6 with groovy 1.8.
The solution for spock 1.0 with jUnit 4.12
As soon as I added hamcrest-core-1.3 to my test classpath the error disappeared.
What was the problem?
I observed the same error described in the question, but I managed to get spock 1.0 groovy 2.4 to work with junit-4.12.
The problem was that junit-4.12 depends on hamcrest.
In fact org.junit.internal.AssumptionViolatedException implements the interface org.hamcrest.SelfDescribing.
I've got the same error with spock tests using a simple Eclipse java project with these versions:
spock-core-1.0-groovy-2.3
junit-4.12
The exception was thrown only when there was a test failures, but was working for the successful ones
I've found that it was a Junit version compatibility matter. i resolved it using junit-4.7 and also tested the following versions:
junit-4.6 => ok
junit-4.5 => ok
junit-4.4 => ko
junit-4.0 => ko
Hope it helps
I had the same compatibility issue while trying to run my spocks in STS:3.6.4 and JBoss Developer Studio Version: 7.1.1.GA.
It was resolved using junit-4.7 instead of junit-4.12
Other instructions can be found at https://code.google.com/p/spock/wiki/GettingStarted#Eclipse
I´ve deployed an EAR on a Websphere Application Server 7. In my code there is a part where I try to unmarshall a XML file into an object. I get this error when trying to do that:
java.lang.NoClassDefFoundError: com.ibm.xtq.bcel.util.SyntheticRepository (initialization failure)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:140)
at com.ibm.xtq.bcel.classfile.JavaClass.<init>(JavaClass.java:109)
at com.ibm.xtq.bcel.classfile.JavaClass.<init>(JavaClass.java:228)
at com.ibm.xtq.bcel.generic.ClassGen.getJavaClass(ClassGen.java:174)
at com.ibm.fcg.bcel.FcgClassGenBCEL.dump2(Unknown Source)
at com.ibm.fcg.bcel.FcgClassGenBCEL.dump(Unknown Source)
at com.ibm.xml.xlxp2.jaxb.unmarshal.codegen.fcg.FCGDeserializationStubGenerator.generate(FCGDeserializationStubGenerator.java:249)
at com.ibm.xml.xlxp2.jaxb.codegen.AbstractGeneratedStubFactory.generateByteCode(AbstractGeneratedStubFactory.java:96)
at com.ibm.xml.xlxp2.jaxb.unmarshal.codegen.fcg.FCGStubFactory.generateStubByteCode(FCGStubFactory.java:46)
at com.ibm.xml.xlxp2.jaxb.codegen.AbstractGeneratedStubFactory.getStubClassConstructor(AbstractGeneratedStubFactory.java:154)
at com.ibm.xml.xlxp2.jaxb.unmarshal.codegen.AbstractGeneratedDeserializationStubFactory.createStub(AbstractGeneratedDeserializationStubFactory.java:58)
at com.ibm.xml.xlxp2.jaxb.unmarshal.impl.DeserializationContext.startComplexType(DeserializationContext.java:662)
at com.ibm.xml.xlxp2.jaxb.unmarshal.impl.DeserializationContext.handleRootElementEvent(DeserializationContext.java:303)
at com.ibm.xml.xlxp2.jaxb.unmarshal.impl.JAXBDocumentScanner.produceRootElementEvent(JAXBDocumentScanner.java:186)
at com.ibm.xml.xlxp2.scan.DocumentScanner.scanRootElement(DocumentScanner.java:2234)
at com.ibm.xml.xlxp2.scan.DocumentScanner.scanProlog(DocumentScanner.java:1726)
at com.ibm.xml.xlxp2.scan.DocumentScanner.nextEvent(DocumentScanner.java:1316)
at com.ibm.xml.xlxp2.scan.DocumentScanner.parseDocumentEntity(DocumentScanner.java:1168)
at com.ibm.xml.xlxp2.jaxb.unmarshal.impl.JAXBDocumentScanner.unmarshal(JAXBDocumentScanner.java:125)
at com.ibm.xml.xlxp2.jaxb.unmarshal.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:120)
at com.inditex.lois.core.ws.utilidades.services.impl.AdaptadorServiceImpl.transformarXMLenObjeto(AdaptadorServiceImpl.java:137)
As far as I know that class is part of IBM JDK and cannot be found in runtime. Is there anything I have to modify in my ear or, as I guess, its all about configuring/modifiying WAS configuration (or even applying a patch if this is a bug).
Any help? Thanks a lot.
(Sorry for my english :) )
This exception means that the class com.ibm.xtq.bcel.util.SyntheticRepository is found, but failed static initialization. If there is no other message in the log about this, then this is the time to open a PMR with IBM. Static initializers in internal WebSphere code should never fail during normal usage course.
Same here, there is an APAR:
http://www-01.ibm.com/support/docview.wss?uid=swg1IV41639
Problem conclusion
This defect will be fixed in:
6.0.0 SR14
6.0.1 SR6
7.0.0 SR5
.
The fix resolved the AccessControlException. SyntheticRepository
class can be initialized properly, hence NoClassDefFoundError
does not occur.