Azure Cosmos DB connection in Android? - android

I am trying to use Azure Cosmos Java-based libraries for connecting my Android app to Cosmos and getting errors. I am simply doing:
CosmosClient client = new CosmosClientBuilder()
.endpoint("https://mystuff.documents.azure.com:443/")
.key("MY_KEY")
.preferredRegions(Collections.singletonList("West US"))
.consistencyLevel(ConsistencyLevel.EVENTUAL)
.contentResponseOnWriteEnabled(true)
.buildClient();
but I get exceptions like:
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$4.done(AsyncTask.java:415)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/sun/management/OperatingSystemMXBean;
at com.azure.cosmos.implementation.cpu.CpuReader.<init>(CpuReader.java:25)
at com.azure.cosmos.implementation.cpu.CpuMonitor.<clinit>(CpuMonitor.java:35)
at com.azure.cosmos.implementation.cpu.CpuMonitor.register(CpuMonitor.java:70)
at com.azure.cosmos.implementation.RxDocumentClientImpl.<init>(RxDocumentClientImpl.java:263)
at com.azure.cosmos.implementation.RxDocumentClientImpl.<init>(RxDocumentClientImpl.java:159)
at com.azure.cosmos.implementation.RxDocumentClientImpl.<init>(RxDocumentClientImpl.java:144)
This seems to me to be due to the fact that Android isn't using Sun / Oracle Java but something else.
Anyone found a good way around this? Besides ditching Microsoft's stuff for something more Android-friendly?

Related

Dalvik crash on Oneplus on Android 12

I've got an app in the play store, and have just started seeing the following crash on crashlytics as we're releasing a new version:
Fatal Exception: java.lang.VerifyError: Verifier rejected class app.models.basket.BasketPrice: app.models.pricing.Money app.models.basket.BasketPrice.component1() failed to verify: app.models.pricing.Money app.models.basket.BasketPrice.component1(): [0x2] return-wide not expected
app.models.pricing.Money app.models.basket.BasketPrice.component2() failed to verify: app.models.pricing.Money app.models.basket.BasketPrice.component2(): [0x2] return-wide not expected
app.models.pricing.Money app.models.basket.BasketPrice.component3() failed to verify: app.models.pricing.Money app.models.basket.BasketPrice.component3(): [0x2] return-wide not expected (declaration of 'app.models.basket.BasketPrice' appears in /data/app/~~SMvMJ3wjLcBZoO_7ATEdrA==/app-MRhsaTqPRxyDfq-Ma3jNMA==/base.apk)
at app.models.basket.BasketPriceJsonAdapter.fromJson(BasketPriceJsonAdapter.kt:53)
at app.models.basket.BasketPriceJsonAdapter.fromJson(BasketPriceJsonAdapter.kt:21)
at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41)
at app.models.basket.BasketPricedFulfilmentOptionJsonAdapter.fromJson(BasketPricedFulfilmentOptionJsonAdapter.kt:57)
at app.models.basket.BasketPricedFulfilmentOptionJsonAdapter.fromJson(BasketPricedFulfilmentOptionJsonAdapter.kt:22)
at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41)
at app.models.basket.BasketPricedFulfilmentOptionsJsonAdapter.fromJson(BasketPricedFulfilmentOptionsJsonAdapter.kt:37)
at app.models.basket.BasketPricedFulfilmentOptionsJsonAdapter.fromJson(BasketPricedFulfilmentOptionsJsonAdapter.kt:20)
at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41)
at app.models.basket.BasketResponseJsonAdapter.fromJson(BasketResponseJsonAdapter.kt:79)
at app.models.basket.BasketResponseJsonAdapter.fromJson(BasketResponseJsonAdapter.kt:24)
at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41)
at app.models.DataWrapperJsonAdapter.fromJson(DataWrapperJsonAdapter.kt:44)
at app.models.DataWrapperJsonAdapter.toJson(DataWrapperJsonAdapter.kt:22)
at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41)
at retrofit2.converter.moshi.MoshiResponseBodyConverter.convert(MoshiResponseBodyConverter.java:46)
at retrofit2.converter.moshi.MoshiResponseBodyConverter.convert(MoshiResponseBodyConverter.java:27)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:243)
at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:153)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)
I can't find anyone with this same return-wide not expected issue anywhere on the internet, although the VerifyError thing seems to be when the Dalvik runtime runs into issues.
My theory at the moment is that this is just a device specific issue for Oneplus Android 12 devices, but the stacktrace is in our(/Moshi) code, and it seems to only be on the new version, so I feel like there's some kind of aggravating factor. Can anyone say why this is happening?

Firebase Crashlytic Errors: Android

We are using the latest Firebase Crashlytic dependency com.google.firebase:firebase-crashlytics:18.0.0
The issues are:
W/OkHttpClient: A connection to https://firebase-settings.crashlytics.com/ was leaked. Did you forget to close a response body?
E/FirebaseCrashlytics: Settings request failed.
java.io.FileNotFoundException: https://firebase-settings.crashlytics.com/spi/v2/platforms/android/gmp/1:582811355855:android:a439b44cdd024799/settings?instance=de187b29e345c342d109ce02e794bff07e1613b0&build_version=7&display_version=1.2.0&source=1
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:251)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(Unknown Source:0)
at j1.a.c(HttpGetRequest.java:80)
at com.google.firebase.crashlytics.internal.settings.network.a.a(DefaultSettingsSpiCall.java:113)
at com.google.firebase.crashlytics.internal.settings.d$a.b(SettingsController.java:199)
at com.google.firebase.crashlytics.internal.settings.d$a.a(SettingsController.java:192)
at com.google.android.gms.tasks.g0.run(com.google.android.gms:play-services-tasks##17.2.1:1)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at com.google.firebase.crashlytics.internal.common.t$a$a.a(ExecutorUtils.java:64)
at com.google.firebase.crashlytics.internal.common.c.run(BackgroundPriorityRunnable.java:27)
at java.lang.Thread.run(Thread.java:764)
The console also is not responding on enabling the feature unlike on other apps we worked on where it works pretty well.

Does the Google Play Console log all crashes?

I have a crash that has slowly crept up in crash rate over my last few releases. All attempts to fix the crash have proved futile. I suspect that the crash happens in the background and users are not actually seeing the issue, else I would have many more reviews about the app crashing.
Do users still need to tap the the crash module that pops up in order for Google to log the crash or does the crash report get sent automatically at this point?
I can not find a definitive answer to this.
Here is the crash if anyone has ideas. There is a lot of info available on that I have tried as well as anything else I could think of. Dug through every SDK, reverted back to previous target API, turned off features etc etc :(
java.lang.RuntimeException: An error occurred while executing doInBackground()
at
android.os.AsyncTask$3.done(AsyncTask.java:354)
at
java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at
java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at
java.util.concurrent.FutureTask.run(FutureTask.java:271)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at
java.lang.Thread.run(Thread.java:798)
Caused by: java.lang.SecurityException: Caller no longer running, last stopped +2s531ms because: timed out while starting
at
android.os.Parcel.createException(Parcel.java:1950)
at
android.os.Parcel.readException(Parcel.java:1918)
at
android.os.Parcel.readException(Parcel.java:1868)
at
android.app.job.IJobCallback$Stub$Proxy.dequeueWork(IJobCallback.java:195)
at
android.app.job.JobParameters.dequeueWork(JobParameters.java:243)
at
androidx.core.app.JobIntentService$JobServiceEngineImpl.dequeueWork(:4)
at
androidx.core.app.JobIntentService.dequeueWork(:2)
at
androidx.core.app.JobIntentService$CommandProcessor.doInBackground(:2)
at
androidx.core.app.JobIntentService$CommandProcessor.doInBackground(:1)
at
android.os.AsyncTask$2.call(AsyncTask.java:333)
at
java.util.concurrent.FutureTask.run(FutureTask.java:266)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at
java.lang.Thread.run(Thread.java:798)
Caused by: android.os.RemoteException: Remote stack trace:
at
com.android.server.job.JobServiceContext.assertCallerLocked(JobServiceContext.java:481)
at
com.android.server.job.JobServiceContext.doDequeueWork(JobServiceContext.java:359)
at
com.android.server.job.JobServiceContext$JobCallback.dequeueWork(JobServiceContext.java:160)
at
android.app.job.IJobCallback$Stub.onTransact(IJobCallback.java:83)
at
android.os.Binder.execTransact(Binder.java:746)

Google ML Kit Text Recognition(v16.1.3) crashes after upgrading the dependency

After upgrading the Text Recognition dependency from 16.1.1 to 16.1.3:
com.google.android.gms:play-services-mlkit-text-recognition:16.1.3
on some devices(Realme 3 Pro Android 10), the app starts crashing when calling
TextRecognition.getClient().process(InputImage.fromFilePath(context, data)).await()
here is the stack trace from firebase:
Non-fatal Exception: f.b.e.a.a: Failed to init thin text recognizer.
at com.google.mlkit.vision.text.internal.zzb.zza(zzb.java:47)
at com.google.mlkit.vision.text.internal.zzn.load(zzn.java:3)
at com.google.mlkit.common.sdkinternal.ModelResource.zza(ModelResource.java:18)
at com.google.mlkit.common.sdkinternal.zzn.run(zzn.java:10)
at com.google.mlkit.common.sdkinternal.zzp.run(zzp.java:10)
at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zze(MlKitThreadPool.java:13)
at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzc(MlKitThreadPool.java:8)
at com.google.mlkit.common.sdkinternal.zzj.run(zzj.java:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzd(MlKitThreadPool.java:10)
at com.google.mlkit.common.sdkinternal.zzk.run(zzk.java:2)
at java.lang.Thread.run(Thread.java:919)
Caused by android.os.RemoteException: Not allowed since feature flag for ML Kit is not enabled.
at ii.a(ii.java)
at com.google.android.gms.vision.text.mlkit.TextRecognizerCreator.newTextRecognizer(TextRecognizerCreator.java:11)
at com.google.android.gms.vision.text.mlkit.TextRecognizerCreator.newTextRecognizer(TextRecognizerCreator.java)
at mu.u(mu.java:4)
at al.onTransact(al.java:4)
at android.os.Binder.transact(Binder.java:914)
at com.google.android.gms.internal.mlkit_vision_text.zza.zzb(zza.java:7)
at com.google.android.gms.internal.mlkit_vision_text.zzlh.zzd(zzlh.java:8)
at com.google.mlkit.vision.text.internal.zzb.zza(zzb.java:30)
at com.google.mlkit.vision.text.internal.zzn.load(zzn.java:3)
at com.google.mlkit.common.sdkinternal.ModelResource.zza(ModelResource.java:18)
at com.google.mlkit.common.sdkinternal.zzn.run(zzn.java:10)
at com.google.mlkit.common.sdkinternal.zzp.run(zzp.java:10)
at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zze(MlKitThreadPool.java:13)
at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzc(MlKitThreadPool.java:8)
at com.google.mlkit.common.sdkinternal.zzj.run(zzj.java:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzd(MlKitThreadPool.java:10)
at com.google.mlkit.common.sdkinternal.zzk.run(zzk.java:2)
at java.lang.Thread.run(Thread.java:919)
The feature flag should already be enabled everywhere, it may due to your play services have not received the update. You can reboot your device to see if the issue gets resolved.
See github.com/googlesamples/mlkit/issues/236 for a similar report.

Connecting to Cloud SQL using Compute Engine via JDBC

I cannot connect to my database thru Compute Engine.
Things I have done so far:
Setup my Compute Engine
Connect my Compute Engine to my Cloud SQL
Install and run Cloud Proxy on my Compute Engine
Included the JDBC Jar file on my libs folder
Created the JDBC Connection string
"jdbc:mysql:///?cloudSqlInstance=&socketFactory=com.google.cloud.sql.mysql.SocketFactory;user=&password=";
Added dependency on my Gradle file
-implementation fileTree(dir: 'libs', include: ['*.jar'])
-implementation 'com.google.cloud.sql:mysql-socket-factory-connector-j-8:1.1.0'
Here is the stack trace:
W/System.err: java.sql.SQLNonTransientConnectionException: Cannot
connect to MySQL server on localhost:3,306. W/System.err: Make sure
that there is a MySQL server running on the machine/port you are
trying to connect to and that the machine this software is running on
is able to connect to this host/port (i.e. not firewalled). Also make
sure that the server has not been started with the --skip-networking
flag.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
W/System.err: at
com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:470)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
W/System.err: at
com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
at java.sql.DriverManager.getConnection(DriverManager.java:569)
at java.sql.DriverManager.getConnection(DriverManager.java:237)
W/System.err: at
com.dedase.dedaseconstruction.ui.login.LoginActivity$GetPatientID.doInBackground(LoginActivity.java:150)
at com.dedase.dedaseconstruction.ui.login.LoginActivity$GetPatientID.doInBackground(LoginActivity.java:136)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
W/System.err: at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.mysql.cj.protocol.SocketConnection
com.mysql.cj.protocol.a.NativeProtocol.getSocketConnection()' on a
null object reference
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:980)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826)
W/System.err: at
com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:456)
... 12 more I/Choreographer: Skipped 58 frames! The application may be doing too much work on its main thread. I/zygote: Do full code
cache collection, code=123KB, data=111KB
After code cache collection, code=117KB, data=78KB
This line localhost:3,306. looks really suspicious. Are you sure you don't have a typo somewhere?
You probably came across this repo, and it's not very accurate. I don't have a java client at hand to test it, but I do use Cloud SQL with a different stack and the point of using Proxy is that your app connects to the DB via it as if the DB itself is running locally. Your connection string should not have anything apart from creds and localhost:3306.

Categories

Resources