crisp-im / crisp-sdk-android

:package: Crisp Android SDK, add a chat in any Android app and communicate with your users.
https://docs.crisp.chat/guides/chatbox-sdks/android-sdk/
Other
56 stars 17 forks source link

Captured Image from Crisp does nothing and does not upload #193

Closed rezafaraji93 closed 1 month ago

rezafaraji93 commented 1 month ago

After taking photo from Crisp options, the photo does not upload

Doc1faux commented 1 month ago

Hi @rezafaraji93 and thank you for your feedback.

Which version of the SDK are you using? Unfortunately, I do not reproduce your issue on 2.0.4 on either emulator or device.

As explained in a previous issue you had, do you declare a file provider in your app and if so, did you follow this step in our Installation guide?

I see also you already reported this issue previously in the same issue above which I already was not able to reproduce and asked for more info about it.

However, I did not reproduced the captured image not sent. See the video below where I firstly tried to take a picture without the permission, then granted it and retried successfully. Did you do something else? Did you added correctly our authority and path? Do you have an error snackbar at the bottom or more logs (there should be some with an UPLOAD tag) to provide me?

Can you provide me more info to better understand what's going on?

rezafaraji93 commented 1 month ago

@Doc1faux Thanks for your reply. I have followed the installation instructions completely.

On my xiaomi device with android version 14, I get this error from my logcat:

CAM_CameraUtil com.android.camera E InvocationTargetException:null (Ask Gemini) java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com.android.camera.o6.K3(Unknown Source:30) at com.android.camera.o6.a(Unknown Source:0) at com.android.camera.e6.run(Unknown Source:8) at com.xiaomi.camera.rx.CameraSchedulers.lambda$scheduleDirect$1(Unknown Source:0) at com.xiaomi.camera.rx.CameraSchedulers.e(Unknown Source:0) at te.c.accept(Unknown Source:4) at io.reactivex.internal.observers.ConsumerSingleObserver.onSuccess(Unknown Source:7) at io.reactivex.internal.operators.single.SingleObserveOn$ObserveOnSingleObserver.run(Unknown Source:14) at io.reactivex.internal.schedulers.ScheduledDirectTask.call(SourceFile:3) at io.reactivex.internal.schedulers.ScheduledDirectTask.call(SourceFile:1) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) at java.lang.Thread.run(Thread.java:1012) Caused by: java.lang.SecurityException: Permission Denial: ProcessManager.adjBoost from pid=8488, uid=10140 at android.os.Parcel.createExceptionOrNull(Parcel.java:3057) at android.os.Parcel.createException(Parcel.java:3041) at android.os.Parcel.readException(Parcel.java:3024) at android.os.Parcel.readException(Parcel.java:2966) at miui.process.ProcessManagerProxy.adjBoost(ProcessManagerNative.java:746) at miui.process.ProcessManager.adjBoost(ProcessManager.java:257) at java.lang.reflect.Method.invoke(Native Method)  at com.android.camera.o6.K3(Unknown Source:30)  at com.android.camera.o6.a(Unknown Source:0)  at com.android.camera.e6.run(Unknown Source:8)  at com.xiaomi.camera.rx.CameraSchedulers.lambda$scheduleDirect$1(Unknown Source:0)  at com.xiaomi.camera.rx.CameraSchedulers.e(Unknown Source:0)  at te.c.accept(Unknown Source:4)  at io.reactivex.internal.observers.ConsumerSingleObserver.onSuccess(Unknown Source:7)  at io.reactivex.internal.operators.single.SingleObserveOn$ObserveOnSingleObserver.run(Unknown Source:14)  at io.reactivex.internal.schedulers.ScheduledDirectTask.call(SourceFile:3)  at io.reactivex.internal.schedulers.ScheduledDirectTask.call(SourceFile:1)  at java.util.concurrent.FutureTask.run(FutureTask.java:264)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)  at java.lang.Thread.run(Thread.java:1012)  Caused by: android.os.RemoteException: Remote stack trace: at com.android.server.am.ProcessManagerService.adjBoost(ProcessManagerService.java:938) at miui.process.ProcessManagerNative.onTransact(ProcessManagerNative.java:306) at android.os.Binder.execTransactInternal(Binder.java:1346) at android.os.Binder.execTransact(Binder.java:1282)

and also from Samsung A5 with android 8, the Camera app crashes with following log: com.sec.android.app.camera E FATAL EXCEPTION: StateMessageHandler (Ask Gemini) Process: com.sec.android.app.camera, PID: 23626 java.lang.SecurityException: Permission Denial: opening provider androidx.core.content.FileProvider from ProcessRecord{c5f5f49 23626:com.sec.android.app.camera/u0a68} (pid=23626, uid=10068) that is not exported from UID 10806 at android.os.Parcel.readException(Parcel.java:1967) at android.os.Parcel.readException(Parcel.java:1913) at android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:5302) at android.app.ActivityThread.acquireProvider(ActivityThread.java:6164) at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2575) at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1786) at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1255) at android.content.ContentResolver.openOutputStream(ContentResolver.java:1013) at android.content.ContentResolver.openOutputStream(ContentResolver.java:989) at com.sec.android.app.camera.util.Util.writeImageDataToRequestedUri(Util.java:2080) at com.sec.android.app.camera.Camera.startAttachActivity(Camera.java:4445) at com.sec.android.app.camera.Camera.onImageStoringCompleted(Camera.java:2411) at com.sec.android.app.camera.engine.CommonEngine.imageStoringCompleted(CommonEngine.java:5577) at com.sec.android.app.camera.engine.CeStatePreviewing.handleMessage(CeStatePreviewing.java:63) at com.sec.android.app.camera.engine.CommonEngine$StateMessageHandler.handleMessage(CommonEngine.java:10656) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.os.HandlerThread.run(HandlerThread.java:65)

Doc1faux commented 1 month ago

Mmh... I did not faced this SecurityException before... It's awkward as we set the android:grantUriPermissions to true to allow temporarly access to our files to 3rd-party apps and we never needed to add explicitely Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION flags to the "Take Photo" intent.

However, I've just added them and as I do not reproduce this crash, I let you try the new 2.0.5 I released to the staging channel of mavenCentral and tell me back if it fixes your issue to publish the fix to the release channel ;)

In order to get it, follow the steps below.

project settings.gradle

dependencyResolutionManagement {
    repositories {
        maven { url "https://s01.oss.sonatype.org/content/groups/staging/" }
    }
}

module build.gradle

implementation 'im.crisp:crisp-sdk:2.0.5'
rezafaraji93 commented 1 month ago

Thanks, I'll let you know.

rezafaraji93 commented 1 month ago

I am getting this error:

DatabaseUtils cash.bit24.stage E Writing exception to parcel (Ask Gemini) java.lang.SecurityException: The authority cash.bit24.stage.im.crisp.client.uploadfileprovider does not match the one of the contentProvider: cash.bit24.stage.provider at android.content.ContentProvider.validateIncomingAuthority(ContentProvider.java:2757) at android.content.ContentProvider.validateIncomingUri(ContentProvider.java:2781) at android.content.ContentProvider$Transport.openAssetFile(ContentProvider.java:608) at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:287) at android.os.Binder.execTransactInternal(Binder.java:1346) at android.os.Binder.execTransact(Binder.java:1282) CAM_Camera2Module com.android.camera E Exception when doAttach: (Ask Gemini) java.lang.SecurityException: The authority cash.bit24.stage.im.crisp.client.uploadfileprovider does not match the one of the contentProvider: cash.bit24.stage.provider at android.os.Parcel.createExceptionOrNull(Parcel.java:3057) at android.os.Parcel.createException(Parcel.java:3041) at android.os.Parcel.readException(Parcel.java:3024) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190) at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:153) at android.content.ContentProviderProxy.openAssetFile(ContentProviderNative.java:759) at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1878) at android.content.ContentResolver.openOutputStream(ContentResolver.java:1576) at android.content.ContentResolver.openOutputStream(ContentResolver.java:1550) at d6.p2.Vn(Unknown Source:82) at g6.o.u0(Unknown Source:18) at g6.o.j(Unknown Source:0) at g6.n.run(Unknown Source:2) at com.xiaomi.camera.rx.CameraSchedulers.lambda$scheduleDirect$1(Unknown Source:0) at com.xiaomi.camera.rx.CameraSchedulers.e(Unknown Source:0) at te.c.accept(Unknown Source:4) at io.reactivex.internal.observers.ConsumerSingleObserver.onSuccess(Unknown Source:7) at io.reactivex.internal.operators.single.SingleObserveOn$ObserveOnSingleObserver.run(Unknown Source:14) at io.reactivex.Scheduler$DisposeTask.run(Unknown Source:9) at io.reactivex.internal.schedulers.ScheduledRunnable.run(Unknown Source:13) at io.reactivex.internal.schedulers.ScheduledRunnable.call(Unknown Source:0) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) at java.lang.Thread.run(Thread.java:1012)

Doc1faux commented 1 month ago

We progress :)

SecurityException: The authority cash.bit24.stage.im.crisp.client.uploadfileprovider does not match the one of the contentProvider: cash.bit24.stage.provider

This crash should be due the lack of Crisp SDK file provider declaration as I previously mentioned in this issue above and in your 1st issue.

You seem to have declared cash.bit24.stage.provider and not cash.bit24.stage.im.crisp.client.uploadfileprovider, which corresponds to the declared authority ${applicationId}.im.crisp.client.uploadfileprovider in our Installation guide.

Be careful to correctly add Crisp SDK file provider as below as well as its declared files path. If you have already declared a file provider in your AndroidManifest.xml, be sure to add ${applicationId}.im.crisp.client.uploadfileprovider to the android:authorities attribute, separated from yours with a semicolon ;.

AndroidManifest.xml

<!-- Adds the the Crisp SDK upload authority -->
<provider android:name="androidx.core.content.FileProvider"
  android:authorities="my.app.fileprovider;${applicationId}.im.crisp.client.uploadfileprovider"
  android:exported="false"
  android:grantUriPermissions="true"
  tools:replace="android:authorities">
  <meta-data android:name="android.support.FILE_PROVIDER_PATHS"
    android:resource="@xml/file_paths"
    tools:replace="android:resource" />
</provider>

res/xml/file_paths.xml

<paths>
  <!-- Declares the Crisp SDK attachments path into your app's folder -->
  <files-path name="crisp_sdk_attachments" path="im.crisp.client/attachments/" />
</paths>
rezafaraji93 commented 1 month ago

@Doc1faux Thanks for your help. It fixed my issue. When can I expect to use the sdk from release channel?

Doc1faux commented 1 month ago

Nice, I release it right away ;)