capacitor-community / bluetooth-le

Capacitor plugin for Bluetooth Low Energy
MIT License
274 stars 79 forks source link

[Android] Remove unused layout xml file if feasible #664

Closed ehsieh-semios closed 1 month ago

ehsieh-semios commented 2 months ago

Describe the bug A trivial Android layout xml bridge_layout_main.xml is conflicting with other plugins which have customized bridge_layout_main.xml

To Reproduce Steps to reproduce the behavior:

  1. import another plugin. e.g: @capacitor-mlkit/barcode-scanning
  2. put [bluetooth-le](https://github.com/capacitor-community/bluetooth-le) prior to that plugin in capacitor.build.gradle:
    dependencies {
    implementation project(':capacitor-community-bluetooth-le')
    implementation project(':capacitor-mlkit-barcode-scanning')
    ...

Expected behavior The other modules like barcode-scanning should work successfully.

Screenshots An error is shown:

21:21:55.769  E  Attempt to invoke virtual method 'void androidx.camera.view.PreviewView.setScaleType(androidx.camera.view.PreviewView$ScaleType)' on a null object reference
                 java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.camera.view.PreviewView.setScaleType(androidx.camera.view.PreviewView$ScaleType)' on a null object reference
                    at io.capawesome.capacitorjs.plugins.mlkit.barcodescanning.BarcodeScanner.lambda$startScan$0(BarcodeScanner.java:107)
                    at io.capawesome.capacitorjs.plugins.mlkit.barcodescanning.BarcodeScanner.$r8$lambda$XoJ4tltbmXkBZjUvzn_RkQLTSis(Unknown Source:0)
                    at io.capawesome.capacitorjs.plugins.mlkit.barcodescanning.BarcodeScanner$$ExternalSyntheticLambda3.run(Unknown Source:8)
                    at android.os.Handler.handleCallback(Handler.java:958)
                    at android.os.Handler.dispatchMessage(Handler.java:99)
                    at android.os.Looper.loopOnce(Looper.java:205)
                    at android.os.Looper.loop(Looper.java:294)
                    at android.app.ActivityThread.main(ActivityThread.java:8177)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

Similar case here(conflicting between barcode-scanning and photoviewer ): https://github.com/googlesamples/mlkit/issues/724

Plugin version:

Smartphone (please complete the following information):

Additional context Only one bridge_layout_main.xml(name conflicting) is left after packing, and it depends on the order in the gradle file.

pwespi commented 1 month ago

Thanks for reporting. Fixed in 6.0.1.