-
Notifications
You must be signed in to change notification settings - Fork 466
[Bug] [MauiCompat] Xamarin.CommunityToolkit.MauiCompat CameraView produces Android No view found for fragment CameraFragment error #1914
Comments
FYI, I also get the same error trying to debug on a physical Android device. |
I know we have discussed internally that things like CameraView would not be expected to work well if at all in MauiCompat due to complexities and limitations of the compat layer. I don't know if we ever came to a decision on how to make this publicly known - we did discuss marking as obsolete so warnings would present. Sadly this isn't going to help solve this but I believe the answer is going to be to not use the CameraView in a MauiCompat based app. At least that is my understanding, hopefully someone else might rubbish my statement |
Thanks @bijington I was hoping that was not the case. I appreciate your insight. |
I have a similar issue with AndroidRuntime] java.lang.IllegalArgumentException: No view found for id 0x37 (unknown) for fragment CameraFragment{1d6a23a} (af9ca8f7-3e90-410f-9c47-5aa8d6db2ec7 id=0x37 tag=camera)
[AndroidRuntime] at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:513)
[AndroidRuntime] at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
[AndroidRuntime] at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2189)
[AndroidRuntime] at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2100)
[AndroidRuntime] at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2002)
[AndroidRuntime] at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524)
[AndroidRuntime] at android.os.Handler.handleCallback(Handler.java:938)
[AndroidRuntime] at android.os.Handler.dispatchMessage(Handler.java:99)
[AndroidRuntime] at android.os.Looper.loop(Looper.java:223)
[AndroidRuntime] at android.app.ActivityThread.main(ActivityThread.java:7656)
[AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
[AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) Edit: add simple project. |
I could be missing something, but it seems like this error prevents Android builds in Release mode:
Will test disabling optimization, but I'm not sure that's a great final solution (shouldn't that be on?). I'm not using a CameraView anywhere in my application. |
The problem here is that this script XamarinCommunityToolkit/MauiCompat.sh Line 561 in 5a6062f
is renaming the code to use all lowercase, but the actual Resource/Layout is still called CameraFragment. This results in a .net/__res_name_case_map.txt being packaged in the .aar file which comes from the NuGet Package.This contains a remap entry Resources/Layout/CameraFragment.axml;layout/camerafragment.xml which tells the Android build system to expect the code to use CameraFragment but the resource file is camerafragment . I'm not sure why the script was run on the code but it does seem to cause issues when upgradingto .net8.0-android. The fix is to modify your local |
I believe the CameraView implementation in the .NET MAUI Community Toolkit is very close now so it would probably be a better move to migrate to using that. |
Thanks in advance!! I'm quite new to XAML so be kind :)
Description
My requirement is to add a CameraView to a .net Maui app which runs on Android and iOS. I understand that there is no CameraView in the Maui.Community.Toolkit but I was under the impression, which may be wrong, that I could run the Xamarin.Community.Tookit.MauiCompat packages which I'm trying to do in the code below.
Stack Trace
--- End of managed Java.Lang.IllegalArgumentException stack trace ---
java.lang.IllegalArgumentException: No view found for id 0x1 (unknown) for fragment CameraFragment{4e42a40} (ddc40138-4928-4ebc-bfd4-b5fb0b1cacdc id=0x1 tag=camera)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:513)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1840)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1758)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1701)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2849)
at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2784)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:262)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:478)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:246)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1455)
at android.app.Activity.performStart(Activity.java:8076)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3660)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2210)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7839)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Link to Reproduction Sample
I posted my code to stack-overflow but if you need a repo, please let me know:
https://stackoverflow.com/questions/73889560/xamarin-communitytoolkit-mauicompat-cameraview-produces-android-no-view-found-fo
Steps to Reproduce
https://github.com/xamarin/XamarinCommunityToolkit/blob/main/samples/XCT.Sample/Pages/Views/CameraViewPage.xaml
https://github.com/xamarin/XamarinCommunityToolkit/blob/main/samples/XCT.Sample/Pages/Views/CameraViewPage.xaml.cs
Expected Behavior
Expect program to build and run
Actual Behavior
Program errors with Java error
Basic Information
Visual Studio Community 2022 for Mac Preview
Version 17.4 Preview (17.4 build 1583)
Installation UUID: 0b36004a-e5d9-4978-ae2a-2d2f56351cff
Runtime
.NET 6.0.5 (64-bit)
Architecture: Arm64
Roslyn (Language Service)
4.4.0-2.22419.1+ae5663806be933515723b2d5a85faf5d378f460d
NuGet
Version: 6.3.0.128
.NET SDK (Arm64)
SDK: /usr/local/share/dotnet/sdk/7.0.100-rc.1.22431.12/Sdks
SDK Versions:
7.0.100-rc.1.22431.12
6.0.401
6.0.400
6.0.400-preview.22330.6
MSBuild SDKs: /Applications/Visual Studio (Preview).app/Contents/MonoBundle/MSBuild/Current/bin/Sdks
.NET SDK (x64)
SDK Versions:
5.0.408
3.1.423
3.1.422
3.1.421
.NET Runtime (Arm64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
7.0.0-rc.1.22426.10
6.0.9
6.0.8
6.0.6
.NET Runtime (x64)
Runtime: /usr/local/share/dotnet/x64/dotnet
Runtime Versions:
5.0.17
3.1.29
3.1.28
3.1.27
Xamarin.Profiler
Version: 1.8.0.19
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
Updater
Version: 11
Apple Developer Tools
Xcode 14.0.1 (21336)
Build 14A400
Xamarin.Mac
Version: 8.12.0.2 (Visual Studio Community)
Hash: 87f98a75e
Branch: d17-3
Build date: 2022-07-25 20:18:54-0400
Xamarin.iOS
Version: 15.12.0.2 (Visual Studio Community)
Hash: 87f98a75e
Branch: d17-3
Build date: 2022-07-25 20:18:55-0400
Xamarin Designer
Version: 17.4.0.124
Hash: ffbba0c031
Branch: remotes/origin/d17-4
Build date: 2022-09-15 15:36:42 UTC
Xamarin.Android
Version: 13.0.99.81 (Visual Studio Community)
Commit: xamarin-android/main/7c9c24b
Android SDK: /Users/macminim1/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
12.0 (API level 31)
SDK Command-line Tools Version: 7.0
SDK Platform Tools Version: 33.0.2
SDK Build Tools Version: 33.0.0
Build Information:
Mono: dffa5ab
Java.Interop: xamarin/java.interop/main@2c8b0a8f
SQLite: xamarin/sqlite@40e8743
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@29f11f2
Microsoft Build of OpenJDK
Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk
11.0.12
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
Eclipse Temurin JDK
Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk
1.8.0.302
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
Android SDK Manager
Version: 17.4.0.45
Hash: 8cac7ea
Branch: remotes/origin/HEAD~1
Build date: 2022-09-15 15:36:46 UTC
Android Device Manager
Version: 0.0.0.1196
Hash: b2faf27
Branch: main~1
Build date: 2022-09-15 15:36:46 UTC
Build Information
Release ID: 1704001583
Git revision: 70322329919c72a11d9795a3cb403fe4115a5878
Build date: 2022-09-15 15:34:40+00
Build branch: release-17.4
Build lane: release-17.4
Operating System
Mac OS X 12.5.0
Darwin 21.6.0 Darwin Kernel Version 21.6.0
Sat Jun 18 17:05:47 PDT 2022
root:xnu-8020.140.41~1/RELEASE_ARM64_T8101 arm64
Build Information
Release ID: 1704001583
Git revision: 70322329919c72a11d9795a3cb403fe4115a5878
Build date: 2022-09-15 15:34:40+00
Build branch: release-17.4
Build lane: release-17.4
Operating System
Mac OS X 12.5.0
Darwin 21.6.0 Darwin Kernel Version 21.6.0
Sat Jun 18 17:05:47 PDT 2022
root:xnu-8020.140.41~1/RELEASE_ARM64_T8101 arm64
Affected Devices:
MAUI Version:
Could not find it anywhere but I imagine it recent as this is a new install of Visual Studio Preview for Mac,
Workaround
None
The text was updated successfully, but these errors were encountered: