maui icon indicating copy to clipboard operation
maui copied to clipboard

Cant debug on real Android API 21 Device

Open deepx opened this issue 3 years ago • 19 comments

Description

I want to develop a MAUI-App and read that it works back to API 21. So i created an emulated device that uses Android API 21. All the Debug-Stuff works well, but when i try to start debugging on a "real" Device (In my Case a Samsumg Galaxy Tab 4 (SM-T535) i get the following Error as seen in the log.

The device dont start the app even after Factory-Reset.

Steps to Reproduce

1.) Create a new .NET MAUI Application 2.) Debug Application on a real connected Device.

Version with bug

Preview 14 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 5.0.2

Did you find any workaround?

Nope.

Relevant log output

Build started...
1>------ Build started: Project: MauiApp1, Configuration: Debug Any CPU ------
1>You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
1>Skipping analyzers to speed up the build. You can execute 'Build' or 'Rebuild' command to run analyzers.
1>MauiApp1 -> C:\Users\djdee\source\repos\MauiDemoApp\MauiApp1\bin\Debug\net6.0-android\MauiApp1.dll
2>------ Deploy started: Project: MauiApp1, Configuration: Debug Any CPU ------
2>Starting deployment to Samsung SM-T535 ...
2>Deploying to Samsung SM-T535 ...
Build started.
Project "MauiApp1.csproj" (Install target(s)):
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
There is no application host available for the specified RuntimeIdentifier 'android-x86'.
Found Java SDK version 11.0.12.
Found Java SDK version 11.0.12.
 Found Xamarin.Android 31.0.200.106
Dex Fast Deployment Enabled: False
MonoAndroid Tools: C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.200-preview.14.106\tools\
Android Platform API level: 31
TargetFrameworkVersion: v6.0
Android NDK: C:\Program Files (x86)\Android\android-sdk
dk-bundle\
Android SDK: C:\Program Files (x86)\Android\android-sdk\
Android SDK Build Tools: C:\Program Files (x86)\Android\android-sdk\build-tools\30.0.3\
Java SDK: C:\Program Files\Microsoft\jdk-11.0.12.7-hotspot\
Application Java class: android.app.Application
Skipping target "ProcessMauiSplashScreens" because all output files are up-to-date with respect to the input files.
Skipping target "ProcessMauiFonts" because all output files are up-to-date with respect to the input files.
Skipping target "ResizetizeImages" because all output files are up-to-date with respect to the input files.
Skipping target "_ResolveLibraryProjectImports" because all output files are up-to-date with respect to the input files.
Skipping target "_BuildLibraryImportsCache" because all output files are up-to-date with respect to the input files.
Skipping target "_GenerateAndroidResourceDir" because all output files are up-to-date with respect to the input files.
Skipping target "_GenerateLayoutBindings" because it has no outputs.
Skipping target "_ConvertResourcesCases" because all output files are up-to-date with respect to the input files.
Skipping target "_CompileResources" because all output files are up-to-date with respect to the input files.
Skipping target "_PrepareUpdateAndroidResgen" because all output files are up-to-date with respect to the input files.
Skipping target "_UpdateAndroidResgen" because all output files are up-to-date with respect to the input files.
Project "MauiApp1.csproj" (_ComputeFilesToPublishForRuntimeIdentifiers target(s)):
Done building project "MauiApp1.csproj".
Skipping target "_LinkAssembliesNoShrink" because all output files are up-to-date with respect to the input files.
Skipping target "_GenerateJavaStubs" because all output files are up-to-date with respect to the input files.
Skipping target "_ManifestMerger" because all output files are up-to-date with respect to the input files.
Skipping target "_ConvertCustomView" because all output files are up-to-date with respect to the input files.
Skipping target "_AddStaticResources" because all output files are up-to-date with respect to the input files.
Skipping target "_GeneratePackageManagerJava" because all output files are up-to-date with respect to the input files.
Skipping target "_GenerateAndroidAssetsDir" because all output files are up-to-date with respect to the input files.
Skipping target "_PrepareCreateBaseApk" because all output files are up-to-date with respect to the input files.
Skipping target "_CreateBaseApk" because all output files are up-to-date with respect to the input files.
Skipping target "_CompileJava" because all output files are up-to-date with respect to the input files.
Skipping target "_CompileNativeAssemblySources" because all output files are up-to-date with respect to the input files.
Skipping target "_CreateApplicationSharedLibraries" because all output files are up-to-date with respect to the input files.
Skipping target "_CompileToDalvik" because all output files are up-to-date with respect to the input files.
Copying file from "C:\Users\djdee\source\repos\MauiDemoApp\MauiApp1\obj\Debug
et6.0-android\android\bin\com.companyname.mauiapp1.apk" to "C:\Users\djdee\source\repos\MauiDemoApp\MauiApp1\bin\Debug
et6.0-android\com.companyname.mauiapp1.apk".
Creating "obj\Debug
et6.0-android\android_debug_keystore.flag" because "AlwaysCreate" was specified.
C:\Program Files (x86)\Android\android-sdk\build-tools\30.0.3\zipalign.exe -p 4 "obj\Debug
et6.0-android\android\bin\com.companyname.mauiapp1.apk" "bin\Debug
et6.0-android\\com.companyname.mauiapp1-Signed.apk" 
C:\Program Files\Microsoft\jdk-11.0.12.7-hotspot\bin\java.exe -jar "C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.200-preview.14.106\tools\apksigner.jar" sign --ks "C:\Users\djdee\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-pass pass:android --ks-key-alias androiddebugkey --key-pass pass:android --min-sdk-version 21 --max-sdk-version 31  bin\Debug
et6.0-android\com.companyname.mauiapp1-Signed.apk 
Signed android package 'bin\Debug
et6.0-android\com.companyname.mauiapp1-Signed.apk'
Using cached value from RegisterTaskObject
Found device: cf92711d
XA0132: The package was not installed. Please check you do not have it installed under any other user.
If the package does show up on the device, try manually uninstalling it then try again.
You should be able to uninstall the app via the Settings app on the device.
Done building project "MauiApp1.csproj" -- FAILED.
Build FAILED.
2>Deployment failed to Samsung SM-T535.
2>Deploy failed
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

deepx avatar Apr 03 '22 15:04 deepx

Did it run at least once successfully on the device? The error mentions it might be installed under a different user (on the Android device) is that a possibility? Could you check in the settings under app management if there is an entry for the app you're trying to deploy and if so, uninstall it and try again?

jfversluis avatar Apr 04 '22 12:04 jfversluis

Hi @deepx. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar Apr 04 '22 12:04 ghost

@jfversluis I have deinstalled under all users every app thats connected to development. no success. Then i set the device back to factorysettings, wiped all and get the same error.

deepx avatar Apr 04 '22 12:04 deepx

What happens if you try deploying a .NET 6 Android app without MAUI? As in, if you do dotnet new android and try to deploy that, does it work?

drasticactions avatar Apr 04 '22 16:04 drasticactions

@drasticactions

No. It shows the same Error. Tried it with Android and a XamarinForms-App. If i deploy with for example Godot or an Unrealengine game it works well.

1>------ Deploy started: Project: TestAndroid, Configuration: Debug Any CPU ------ 1>Starting deployment to Samsung SM-T535 ... 1>Deploying to Samsung SM-T535 ... Build started. Project "TestAndroid.csproj" (Install target(s)): You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview There is no application host available for the specified RuntimeIdentifier 'android-x86'. Found Java SDK version 11.0.12. Found Java SDK version 11.0.12. Dex Fast Deployment Enabled: False MonoAndroid Tools: C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.200-preview.14.106\tools
Android Platform API level: 31 TargetFrameworkVersion: v6.0 Android NDK: C:\Program Files (x86)\Android\android-sdk dk-bundle
Android SDK: C:\Program Files (x86)\Android\android-sdk
Android SDK Build Tools: C:\Program Files (x86)\Android\android-sdk\build-tools\30.0.3
Java SDK: C:\Program Files\Microsoft\jdk-11.0.12.7-hotspot
Application Java class: android.app.Application Skipping target "_ResolveLibraryProjectImports" because all output files are up-to-date with respect to the input files. Skipping target "_BuildLibraryImportsCache" because all output files are up-to-date with respect to the input files. Skipping target "_GenerateAndroidResourceDir" because all output files are up-to-date with respect to the input files. Skipping target "_GenerateLayoutBindings" because it has no outputs. Skipping target "_ConvertResourcesCases" because all output files are up-to-date with respect to the input files. Skipping target "_CompileResources" because all output files are up-to-date with respect to the input files. Skipping target "_PrepareUpdateAndroidResgen" because all output files are up-to-date with respect to the input files. Skipping target "_UpdateAndroidResgen" because all output files are up-to-date with respect to the input files. Project "TestAndroid.csproj" (_ComputeFilesToPublishForRuntimeIdentifiers target(s)): Done building project "TestAndroid.csproj". Skipping target "_LinkAssembliesNoShrink" because all output files are up-to-date with respect to the input files. Skipping target "_GenerateJavaStubs" because all output files are up-to-date with respect to the input files. Skipping target "_ConvertCustomView" because all output files are up-to-date with respect to the input files. Skipping target "_AddStaticResources" because all output files are up-to-date with respect to the input files. Skipping target "_GeneratePackageManagerJava" because all output files are up-to-date with respect to the input files. Skipping target "_GenerateAndroidAssetsDir" because it has no outputs. Skipping target "_PrepareCreateBaseApk" because all output files are up-to-date with respect to the input files. Skipping target "_CreateBaseApk" because all output files are up-to-date with respect to the input files. Skipping target "_CompileJava" because all output files are up-to-date with respect to the input files. Skipping target "_CompileNativeAssemblySources" because all output files are up-to-date with respect to the input files. Skipping target "_CreateApplicationSharedLibraries" because all output files are up-to-date with respect to the input files. Skipping target "_CompileToDalvik" because all output files are up-to-date with respect to the input files. Skipping target "_BuildApkFastDev" because all output files are up-to-date with respect to the input files. Skipping target "_CopyPackage" because all output files are up-to-date with respect to the input files. Touching "obj\Debug et6.0-android\android_debug_keystore.flag". Skipping target "_Sign" because all output files are up-to-date with respect to the input files. Using cached value from RegisterTaskObject Found device: cf92711d XA0132: The package was not installed. Please check you do not have it installed under any other user. If the package does show up on the device, try manually uninstalling it then try again. You should be able to uninstall the app via the Settings app on the device. Done building project "TestAndroid.csproj" -- FAILED. Build FAILED. 1>Deployment failed to Samsung SM-T535. 1>Deploy failed ========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

deepx avatar Apr 04 '22 16:04 deepx

Godot, I believe, is using the legacy Android/Mono stack, which is why it works. I feel this is specific to net6.0-android as a whole and is not an MAUI thing. @jonathanpeppers does that make sense?

drasticactions avatar Apr 04 '22 17:04 drasticactions

In the first i believed that is a Problem with some User-Restrictions. But the second device (also API21 V5.0.1) without Users has the same problem with the same errors. On that Device never developed a XF or MAUI-App.

FYI: After deploy to the Device, the AppIcon and App are installed. If i start them with a tab on the device directly, i see the splashscreen (Blurry) flashing up and then an Alert "AppMauiTest stopped".

After that to Test i used a newer Phone, Samsung Galaxy-S8 with API 28 (Android 9) it works as expected.

As on the Screenshot i "Deinstall for all Users" as asked in the Errormessage XA0132 Screenshot_1

deepx avatar Apr 04 '22 18:04 deepx

Can you get full adb logcat output when things fail on the older device? See:

https://docs.microsoft.com/xamarin/android/deploy-test/debugging/android-debug-log#accessing-from-the-command-line

First enable more logging:

adb shell setprop debug.mono.log default,debugger,timing,assembly,mono_log_level=debug,mono_log_mask=all

Cause the problem, then save to a file:

adb logcat -d > log.txt

And share it here. Thanks!

jonathanpeppers avatar Apr 13 '22 14:04 jonathanpeppers

@jonathanpeppers hope that helps.

because its exceeding size of 65k Chars i put the file in here log.txt .

deepx avatar Apr 13 '22 14:04 deepx

None of the .NET assemblies were fast deployed:

F/monodroid(14234): No assemblies found in '/data/data/com.companyname.testmaui/files/.__override__' or '<unavailable>'. Assuming this is part of Fast Deployment. Exiting...

Since you got this before:

XA0132: The package was not installed. Please check you do not have it installed under any other user.
If the package does show up on the device, try manually uninstalling it then try again.
You should be able to uninstall the app via the Settings app on the device.

Can you manually uninstall the app, then set <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk> in your .csproj?

That should solve the issue, I think?

jonathanpeppers avatar Apr 13 '22 14:04 jonathanpeppers

@jonathanpeppers Yes, that runs the Application on the Tablet. But i cant use the hot-reload.

On the Emulator it works fine, but on the "real" device i get a new error:

Java.Lang.ClassNotFoundException Message=mono.android.view.View_OnScrollChangeListenerImplementor

[mono-rt] java.lang.ClassNotFoundException: Didn't find class "mono.android.view.View_OnScrollChangeListenerImplementor" on path: DexPathList[[zip file "/data/app/com.companyname.testmaui-1/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.testmaui-1/lib/arm, /vendor/lib, /system/lib]]
[mono-rt] 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
[mono-rt] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
[mono-rt] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
[mono-rt] 	at java.lang.Class.classForName(Native Method)
[mono-rt] 	at java.lang.Class.forName(Class.java:308)
[mono-rt] 	at mono.java.lang.RunnableImplementor.n_run(Native Method)
[mono-rt] 	at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
[mono-rt] 	at android.os.Handler.handleCallback(Handler.java:739)
[mono-rt] 	at android.os.Handler.dispatchMessage(Handler.java:95)
[mono-rt] 	at android.os.Looper.loop(Looper.java:145)
[mono-rt] 	at android.app.ActivityThread.main(ActivityThread.java:6134)
[mono-rt] 	at java.lang.reflect.Method.invoke(Native Method)
[mono-rt] 	at java.lang.reflect.Method.invoke(Method.java:372)
[mono-rt] 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
[mono-rt] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
[mono-rt] 	Suppressed: java.lang.NoClassDefFoundError: mono.android.view.View_OnScrollChangeListenerImplementor
[mono-rt] 		at dalvik.system.DexFile.defineClassNative(Native Method)
[mono-rt] 		at dalvik.system.DexFile.defineClass(DexFile.java:226)
[mono-rt] 		at dalvik.system.DexFile.loa

deepx avatar Apr 13 '22 14:04 deepx

@deepx can you get a new log with that error? Same as: https://github.com/dotnet/maui/issues/5782#issuecomment-1098106729

You might adb logcat -c first, to just clear the log before making the issue happen again.

jonathanpeppers avatar Apr 13 '22 15:04 jonathanpeppers

@jonathanpeppers cant reproduce the error on demand. looks like sometimes its working sometimes not. in this log i canged the default label "Welcome to .NET Multi-platform App UI" to "Welcome to .NET Multi-platform App UI Maui" it doesnt show up on the local device. if i change it in a new debug run, it changes wehen ei change the label or the text of the button. added the logfile maybe you can see somethings wrong. thx log.txt

deepx avatar Apr 13 '22 16:04 deepx

@deepx so the app is crashing sometimes when you perform a hot reload? I'm a little confused by the above error, because mono.android.view.View_OnScrollChangeListenerImplementor doesn't actually exist.

Does the problem happen in a dotnet new maui template? If only on a specific device, what is the model and Android version it's running?

jonathanpeppers avatar Apr 13 '22 16:04 jonathanpeppers

@jonathanpeppers It's running in an 'dotnet new maui' app, when running i change only in the mainwindow.xaml. it all works fin in my emulator and my "normal" mobile device (Samsung Galaxy S8, Android 9) but when i debug with a Samsung Galaxy Tab Android 5.0.2 and another Device Samsung Galaxy S4 Android 5.01 it wont work until i use from u suggested: "EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk". Then it starts on the devices but (not reproduceable) somtime the hot reload work, sometimes it breaks with the error i mentioned in https://github.com/dotnet/maui/issues/5782#issuecomment-1098152238

deepx avatar Apr 13 '22 16:04 deepx

@jonathanpeppers It's running in an 'dotnet new maui' app, when running i change only in the mainwindow.xaml. it all works fin in my emulator and my "normal" mobile device (Samsung Galaxy S8, Android 9) but when i debug with a Samsung Galaxy Tab Android 5.0.2 and another Device Samsung Galaxy S4 Android 5.01 it wont work until i use from u suggested: "EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk". Then it starts on the devices but (not reproduceable) somtime the hot reload work, sometimes it breaks with the error i mentioned in #5782 (comment)

@jonathanpeppers ?

PureWeen avatar Jun 28 '22 20:06 PureWeen

If EmbedAssembliesIntoApk fixes something, then that device probably isn't supported w/ Fast Deployment. Are we just not showing a good error message for some devices?

If you are having an issue with "hot reload" crashing sometimes, that sounds like a second issue?

jonathanpeppers avatar Jun 28 '22 20:06 jonathanpeppers

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Aug 30 '22 15:08 ghost

I'm having the same problem when trying to run Maui on devices with Android API 21 (5.0 and 5.1), only the splash screen appears and ends in sequence.

ddslima avatar Sep 19 '22 20:09 ddslima

Verified this issue with Visual Studio Enterprise 17.2.0 Preview 2.0. Not repro on android physical device (API31) with a MAUI template. MauiApp21.zip

homeyf avatar Apr 18 '23 09:04 homeyf

This happened to me sometime ago when I wanted to deploy a xamarin.android app on an old samsung phone. Later on I tried deploying a Maui android app and found that the same workaround for xamarin worked on Maui.

What you can do is turn of the "Fast development"-options under {project} properties > Android > Options: afbeelding

IliassNassibane avatar May 08 '23 20:05 IliassNassibane

Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you!

ghost avatar May 08 '23 20:05 ghost