ishaquehassan / document_scanner_flutter

A document scanner plugin for flutter
MIT License
59 stars 130 forks source link

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mypackage/com.scanlibrary.ScanActivity}: java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority com.scanlibrary.provider #12

Open aiman5252 opened 2 years ago

aiman5252 commented 2 years ago

Hi, I've encountered an issue while using this package. What I wanted is to add a document scanner feature to my app using this code below:

try {
      scannedDoc = await DocumentScannerFlutter.launch(context,
          source: ScannerFileSource.CAMERA);
    } catch (e) {
      print(e);
    }

After I trigger that method, my app crashed and this is the stack trace:

W/ActivityThread( 7922): handleWindowVisibility: no activity for token android.os.BinderProxy@ab31445
D/        ( 7922): openCamera: isDirectoryCreated: false
D/AndroidRuntime( 7922): Shutting down VM
E/AndroidRuntime( 7922): FATAL EXCEPTION: main
E/AndroidRuntime( 7922): Process: com.gilkor.app.sedayuone, PID: 7922
E/AndroidRuntime( 7922): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gilkor.app.sedayuone/com.scanlibrary.ScanActivity}: java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority com.scanlibrary.provider
E/AndroidRuntime( 7922):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
E/AndroidRuntime( 7922):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
E/AndroidRuntime( 7922):    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
E/AndroidRuntime( 7922):    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime( 7922):    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime( 7922):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
E/AndroidRuntime( 7922):    at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime( 7922):    at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime( 7922):    at android.app.ActivityThread.main(ActivityThread.java:7356)
E/AndroidRuntime( 7922):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 7922):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime( 7922):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/AndroidRuntime( 7922): Caused by: java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority com.scanlibrary.provider
E/AndroidRuntime( 7922):    at androidx.core.content.FileProvider.parsePathStrategy(FileProvider.java:662)
E/AndroidRuntime( 7922):    at androidx.core.content.FileProvider.getPathStrategy(FileProvider.java:635)
E/AndroidRuntime( 7922):    at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:441)
E/AndroidRuntime( 7922):    at com.scanlibrary.PickImageFragment.openCamera(PickImageFragment.java:135)
E/AndroidRuntime( 7922):    at com.scanlibrary.PickImageFragment.handleIntentPreference(PickImageFragment.java:87)
E/AndroidRuntime( 7922):    at com.scanlibrary.PickImageFragment.init(PickImageFragment.java:68)
E/AndroidRuntime( 7922):    at com.scanlibrary.PickImageFragment.onCreateView(PickImageFragment.java:57)
E/AndroidRuntime( 7922):    at android.app.Fragment.performCreateView(Fragment.java:2534)
E/AndroidRuntime( 7922):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1303)
E/AndroidRuntime( 7922):    at android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2431)
E/AndroidRuntime( 7922):    at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2210)
E/AndroidRuntime( 7922):    at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2166)
E/AndroidRuntime( 7922):    at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2067)
E/AndroidRuntime( 7922):    at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3057)
E/AndroidRuntime( 7922):    at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3004)
E/AndroidRuntime( 7922):    at android.app.FragmentController.dispatchActivityCreated(FragmentController.java:184)
E/AndroidRuntime( 7922):    at android.app.Activity.performCreate(Activity.java:7809)
E/AndroidRuntime( 7922):    at android.app.Activity.performCreate(Activity.java:7791)
E/AndroidRuntime( 7922):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
E/AndroidRuntime( 7922):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
E/AndroidRuntime( 7922):    ... 11 more
D/TransportRuntime.SQLiteEventStore( 7922): Storing event with priority=HIGHEST, name=FIREBASE_CRASHLYTICS_REPORT for destination cct
D/TransportRuntime.JobInfoScheduler( 7922): Scheduling upload for context TransportContext(cct, HIGHEST, MSRodHRwczovL2NyYXNobHl0aWNzcmVwb3J0cy1wYS5nb29nbGVhcGlzLmNvbS92MS9maXJlbG9nL2xlZ2FjeS9iYXRjaGxvZ1xBSXphU3lCcnBTWVQ0RkZMMDlyZUhKaTZIOUZZZGVpU25VVE92Mk0=) with jobId=-1046662295 in 1000ms(Backend next call timestamp 1641300973324). Attempt 1
I/Process ( 7922): Sending signal. PID: 7922 SIG: 9
Lost connection to device.

Can you please help me? Thanks in advance.

kalloszsolty commented 2 years ago

Did you solve this issue with the provider tag: https://github.com/ishaquehassan/document_scanner_flutter/issues/9 ?

aiman5252 commented 2 years ago

No, I need to use that provider tag to build the app, but it didn't solve this issue.

kalloszsolty commented 2 years ago

As far as I understand this is beacuse of the tools:replace="android:authorities" What build error do you get if you remove the provider from the Manifest? For me it builds, but if I try to use the same library in a sibling app of mine, I get the error: [INSTALL_FAILED_CONFLICTING_PROVIDER: Scanning Failed.: Can't install because provider name com.scanlibrary.provider is already used

rajada1 commented 2 years ago

this #9 solved my problem

sanjeevinnobit commented 1 year ago

@aiman5252 please refer this https://github.com/ishaquehassan/document_scanner_flutter/issues/19#issuecomment-1579374629