I have my app calling the AuthenicationClient builder on a button click. This is being tested on a physical Android 12 device.
handler.post(() -> runOnUiThread(() -> authenticationClient = AuthenticationClients.builder()
.setOrgUrl(getResources().getString(R.string.octa_issuer))
.build()));
Inside grade.build(:app) I have
implementation 'com.okta.android:okta-oidc-android:1.0.19'
implementation 'com.okta.authn.sdk:okta-authn-sdk-api:2.0.9'
implementation('com.okta.authn.sdk:okta-authn-sdk-impl:2.0.9') {
exclude group: 'com.okta.sdk', module: 'okta-sdk-httpclient'
}
implementation 'com.okta.sdk:okta-sdk-okhttp:2.0.0'
Error I receive when hitting the button and calling this builder. I have followed every document Okta has and some and just lost at this point. I get this error even without putting the builder on another thread.
FATAL EXCEPTION: main
Process: com.chrobinson.navispherecarrier.dev, PID: 22005
java.lang.NoSuchMethodError: No static method format(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String; in class Lorg/slf4j/helpers/MessageFormatter; or its super classes (declaration of 'org.slf4j.helpers.MessageFormatter' appears in /data/app/~~bfiUKjOLLeBPi-tTbkPssg==/com.chrobinson.navispherecarrier.dev-Bm0xcVwmy5sQv_7p0YZRcQ==/base.apk!classes21.dex)
at org.slf4j.impl.Log4jLoggerAdapter.debug(Log4jLoggerAdapter.java:223)
at com.okta.sdk.impl.config.OptionalPropertiesSource.getProperties(OptionalPropertiesSource.java:42)
at com.okta.authn.sdk.impl.client.DefaultAuthenticationClientBuilder.(DefaultAuthenticationClientBuilder.java:117)
at com.okta.authn.sdk.impl.client.DefaultAuthenticationClientBuilder.(DefaultAuthenticationClientBuilder.java:85)
at java.lang.Class.newInstance(Native Method)
at com.okta.commons.lang.Classes.newInstance(Classes.java:164)
at com.okta.commons.lang.Classes.newInstance(Classes.java:150)
at com.okta.authn.sdk.client.AuthenticationClients.builder(AuthenticationClients.java:43)
at com.chrobinson.navispherecarrier.view.activities.LoginActivity.lambda$onSignIn$6$com-chrobinson-navispherecarrier-view-activities-LoginActivity(LoginActivity.java:208)
at com.chrobinson.navispherecarrier.view.activities.LoginActivity$$ExternalSyntheticLambda6.run(Unknown Source:2)
at android.app.Activity.runOnUiThread(Activity.java:7173)
at com.chrobinson.navispherecarrier.view.activities.LoginActivity.lambda$onSignIn$7$com-chrobinson-navispherecarrier-view-activities-LoginActivity(LoginActivity.java:208)
at com.chrobinson.navispherecarrier.view.activities.LoginActivity$$ExternalSyntheticLambda7.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:250)
at android.app.ActivityThread.main(ActivityThread.java:7877)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
Believe this was a library merge issue and this lib mimeutil was bringing in different versions than Okta was. I was able to fix the crash by excluding some parts the lib.
implementation ('eu.medsea.mimeutil:mime-util:2.1.3') {
exclude group: 'org.slf4j', module: 'slf4j-api'
exclude group: "org.slf4j", module: "slf4j-log4j12"
exclude group: "log4j", module: "log4j"
}
Related
Every time add firebase dependencies, run my app and socket connect to endpoint, my app crashes immediately.
I'm using firebase and socket.io together and is causing the crash due to compatibility issues. Can firebase and socket.io be used together?
I get the following error when i added firebase and try to connect to socket.io in my project
E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
Process: com.project.hubrydemanagerapp, PID: 30101
java.lang.NoSuchMethodError: No virtual method callEngineGetConnection(Lcom/squareup/okhttp/Call;)Lcom/squareup/okhttp/Connection; in class Lcom/squareup/okhttp/internal/Internal; or its super classes (declaration of 'com.squareup.okhttp.internal.Internal' appears in /data/app/com.project.hubrydemanagerapp-t3ZbPD-QZAE9y2BMT64Cdg==/base.apk!classes3.dex)
at com.squareup.okhttp.ws.WebSocketCall.createWebSocket(WebSocketCall.java:154)
at com.squareup.okhttp.ws.WebSocketCall.access$000(WebSocketCall.java:42)
at com.squareup.okhttp.ws.WebSocketCall$1.onResponse(WebSocketCall.java:102)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:177)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
My dependencies:
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.google.firebase:firebase-firestore:21.3.0'
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
implementation('com.github.nkzawa:socket.io-client:0.6.0') {
exclude group: 'org.json', module: 'json'
}
Endpoint
"https://hubryde-trip-service.herokuapp.com/";
"https://hubryde-request-service.herokuapp.com/";
Connection. I'm using Application class to create socket model.
tripSocket = IO.socket(TRIP_URL);
socket2 = IO.socket(BUS_URL);
SocketEndpoint app = (SocketEndpoint) getApplication();
tripSocket = app.getmTripSocket();
if(!tripSocket.connected()) {
tripSocket.connect();
}
socket2 = app.getmBusLocationSocket();
if(!socket2.connected()) {
socket2.connect();
}
}
Im also Using com.github.nkzawa:socket.io-client:0.6.0.
That crash also happened to me after adding firebase in app messaging module,
for me the quick fix (until this will be fixed, hopefully soon..)
was to add exclude..
hope it helps..
implementation ('com.google.firebase:firebase-inappmessaging-display:19.0.3') {
exclude group: 'com.squareup.okhttp', module: 'okhttp'
}
my full gradle file: (Using AndroidX)
implementation 'com.github.nkzawa:socket.io-client:0.6.0'
implementation 'tech.gusavila92:java-android-websocket-client:1.2.2'
implementation "com.google.firebase:firebase-messaging:20.1.4"
implementation 'com.google.firebase:firebase-core:17.3.0'
implementation 'com.google.firebase:firebase-analytics:17.3.0'
implementation 'com.google.firebase:firebase-auth:19.3.0'
implementation ('com.google.firebase:firebase-inappmessaging-display:19.0.3') {
exclude group: 'com.squareup.okhttp', module: 'okhttp'
}
I have tested your dependencies and i realized firestore dependency is the reason for the crash not the entire firebase dependencies. It seems not to support The type of socket.io you are using OR not even support socket.io at all.
I even went further to test older version of cloud firestore, but no luck - The app keeps crashing with the same error.
So remove firestore and sync your project if you will see the error.
All related posts seem to indicate a version mismatch between Firebase and Playservices, but I didn't find one wrt. Firestore. I tried all kinds of permutations, but didn't find a fix. Here is my gradle:
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
//----------------------------------------------------------------------------------------------
//--- FireBase
//----------------------------------------------------------------------------------------------
// Firebase DataBase
// implementation 'com.google.firebase:firebase-database:18.0.0'
// implementation 'com.google.firebase:firebase-auth:18.0.0'
// Firebase Firestore
// Need to exclude 'guava' to avoid dreaded 'Duplicate class' Errors during compile
implementation ('com.google.firebase:firebase-firestore:20.1.0')
{
exclude group: 'com.google.guava'
}
//----------------------------------------------------------------------------------------------
//--- Google Oauth and Google Sheets
//----------------------------------------------------------------------------------------------
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'pub.devrel:easypermissions:0.2.1'
implementation('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation('com.google.apis:google-api-services-sheets:v4-rev465-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
sourceSets {
main.java.srcDirs += 'src/main/<YOUR DIRECTORY>'
}
}
I tried to align it with playservices ie. 17.0.0 , also tried 18.x versions to no avail. Funny that it worked when I used the Firebase Realtime Database, so no incompatibility there. But I want to switch over to Firestore to take advantage of better ArrayList handling in the classes I want to write/read.
I also had to exclude the guava group or I would get those 'Duplicated class' errors (again, only with Firestone, not with the database).
Here is the full logcat:
2019-07-06 12:12:48.397 1671-1684/? E/memtrack: Couldn't load memtrack module
2019-07-06 12:12:48.541 7857-7857/com.mairyu.app.lingoflash E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mairyu.app.lingoflash, PID: 7857
java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$5(com.google.firebase:firebase-firestore##18.0.0:379)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$5.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NoSuchMethodError: No static method checkArgument(ZLjava/lang/String;I)V in class Lcom/google/common/base/Preconditions; or its super classes (declaration of 'com.google.common.base.Preconditions' appears in /data/app/com.mairyu.app.lingoflash-_VKmE7anO3pKy3BbdIRr4w==/base.apk)
at com.google.firebase.Timestamp.validateRange(com.google.firebase:firebase-firestore##18.0.0:160)
at com.google.firebase.Timestamp.<init>(com.google.firebase:firebase-firestore##18.0.0:65)
at com.google.firebase.firestore.model.SnapshotVersion.<clinit>(com.google.firebase:firebase-firestore##18.0.0:26)
at com.google.firebase.firestore.local.SQLiteQueryCache.<init>(com.google.firebase:firebase-firestore##18.0.0:40)
at com.google.firebase.firestore.local.SQLitePersistence.<init>(com.google.firebase:firebase-firestore##18.0.0:111)
at com.google.firebase.firestore.core.FirestoreClient.initialize(com.google.firebase:firebase-firestore##18.0.0:226)
at com.google.firebase.firestore.core.FirestoreClient.lambda$new$2(com.google.firebase:firebase-firestore##18.0.0:114)
at com.google.firebase.firestore.core.FirestoreClient$$Lambda$2.run(Unknown Source:8)
at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$4(com.google.firebase:firebase-firestore##18.0.0:311)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$4.call(Unknown Source:2)
at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$3(com.google.firebase:firebase-firestore##18.0.0:287)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$3.run(Unknown Source:4)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at com.google.firebase.firestore.util.AsyncQueue$DelayedStartFactory.run(com.google.firebase:firebase-firestore##18.0.0:205)
at java.lang.Thread.run(Thread.java:764)
In my very similar case the problem was because I haven't tried to exclude Guava from some dependency except Firestore. So at first I had similar implementation (just with newer version)
implementation ('com.google.firebase:firebase-firestore:21.3.1') {
exclude group: 'com.google.guava'
}
, but then I tried to move exclusion to the other dependency where it was affordable and acceptable. For me it was google api client:
implementation ('com.google.api-client:google-api-client:1.22.0') {
exclude group: 'com.google.guava'
}
Therefore, I left Firestore dependency without exclusions and it's just working fine now.
implementation 'com.google.firebase:firebase-firestore:21.3.1'
When I implement these two dependencies in my project:
For BTC implementation 'org.bitcoinj:bitcoinj-core:0.14.7'
For BCH implementation 'cash.bitcoinj:bitcoincashj-examples:0.14.5.2'
This error will occur:
Caused by: com.android.builder.merge.DuplicateRelativeFileException: More than one file was found with OS independent path 'org.bitcoin.production.checkpoints.txt'
How can I resolve this?
This issue appears because bitcoincashj-examples library also transit org.bitcoinj:bitcoinj-core:0.14.5.2 dependency.
All that you need to do is exclude org.bitcoinj:bitcoinj-core:0.14.5.2 dependency from bitcoincashj-examples library.
implementation 'org.bitcoinj:bitcoinj-core:0.14.7'
implementation ('cash.bitcoinj:bitcoincashj-examples:0.14.5.2'){
exclude group: 'cash.bitcoinj', module: 'bitcoinj-core'
}
I'm trying to make a simple espresso test that will find the first item in
RecyclerView without specific label and click on it. To achieve this I added espresso-contrib to project like this:
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') {
// Necessary to avoid version conflicts
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'design'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'support-annotations'
exclude module: 'recyclerview-v7'
}
and wrote the following expression in my test case:
onView(withId(R.id.sresults_list_recycler)).perform(RecyclerViewActions.actionOnHolderItem(new FirstNotSoldOutMatcher(), click()).atPosition(1));
Matcher works perfectly and RecyclerView got scrolled to the target item. But then I get error:
java.lang.NoSuchMethodError: No virtual method findViewHolderForPosition(I)Landroid/support/v7/widget/RecyclerView$ViewHolder; in class Landroid/support/v7/widget/RecyclerView; or its super classes (declaration of 'android.support.v7.widget.RecyclerView' appears in /data/app/com.example-1/base.apk)
at android.support.test.espresso.contrib.RecyclerViewActions$ActionOnItemAtPositionViewAction.perform(RecyclerViewActions.java:288)
at android.support.test.espresso.contrib.RecyclerViewActions$ActionOnItemViewAction.perform(RecyclerViewActions.java:232)
at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:144)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
This looks strange to me. I read in Google documentation that findViewHolderForPosition method is deprecated now but it should still be there. I also have multidex enabled in the app but according to docs it is supported out of the box so shouldn't be a problem too.
Do you have any idea what can be wrong with this test?
Ok, in my case problem was in ProGuard shrinking unused methods. Disabling it for tests helped.
For future seekers - if you don't want to disable proguard for debug build adding this line to proguard config should help too:
-keepclasseswithmembers public class android.support.v7.widget.RecyclerView { *; }
Also, note that this rule should be added to the regular proguard file(the one of listed in proguardFiles) and not the test one(declared as testProguardFile)
You can combine #Bersh's answer and this answer to be more strict about what to keep:
-keep class android.support.v7.widget.RecyclerView {
public android.support.v7.widget.RecyclerView$ViewHolder findViewHolderForPosition(int);
}
There is no reason to keep the entire RecyclerView class.
Update:
Or for when you inevitably update to AndroidX:
-keep class androidx.recyclerview.widget.RecyclerView {
public androidx.recyclerview.widget.RecyclerView$ViewHolder findViewHolderForPosition(int);
}
Currently I am trying to test the views using RecyclerView. The app works great, but in the test, it doesn't, it couldn't find method of RecyclerView, the followings are the dependencies in the test file
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.0') {
exclude group: 'javax.inject'
exclude group: 'com.google.code.findbugs'
exclude group: 'com.android.support', module: 'support-v4'
}
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.0') {
exclude group: 'javax.inject'
exclude group: 'com.google.guava'
exclude group: 'com.android.support', module: 'support-annotations'
exclude module: 'recyclerview-v7'
}
And I got errors when I was using RecyclerViewActions.actionOnItemAtPosition and it will call RecyclerView's scrollToPosition() method. But it complains that it couldn't find this method:
java.lang.NoSuchMethodError: android.support.v7.widget.RecyclerView.scrollToPosition
at android.support.test.espresso.contrib.RecyclerViewActions$ScrollToPositionViewAction.perform(RecyclerViewActions.java:397)
at android.support.test.espresso.contrib.RecyclerViewActions$ActionOnItemAtPositionViewAction.perform(RecyclerViewActions.java:277)
at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:144)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
....
I assume the problem is, since it works fine in the app, that in the test, it might use the older version than the app. And for test dependency, the version for recyclerView is 21.0.3 and app version is 22.2.0. However, after I change the app version of RecyclerView to 21.0.3 (same as in test), it still has same error.
Much appreciate any comments
Ok, after two days of searching, finally I found the solution. It has something to do with Proguard. It turns out that the RecyclerView is obfuscated by Android Proguard. Thats the reason why Espresso cannot find this method.
Just simply add
-keep class android.support.v7.widget.RecyclerView { *; }
in proguard-rules.text and then you are all set.