Breakpoints is not hitting while debugging a .NET MAUI android application - android

I have been working on a MAUI android application and when debugging, the breakpoints is not hitting and the application enter in a break state. But for windows app it works well.
I think this is an issue with the .NET 6 Android Tooling in visual studio 2022. Is there any solutions for this problem ?

Here is a few steps I did to make things work with debugging MAUI Android apps. I was able to debug and get my regular exceptions and hit breakpoints after this.
Add this code to Android platform main activity OnCreate method
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Then this hander method in the same class
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{ System.Diagnostics.Debug.WriteLine(e.ToString());}
Reset Your Exceptions for CLR. Shortcut is (Ctrl+Alt+E).
Just double-click on the CLR Exceptions checkbox to reset.
Disable Debug Your Code Only in Options

I was also having problems debugging some projects. (Preview 17.1.0) The ones that were failing had the following project settings.
<PropertyGroup>
<TargetFrameworks>net6.0-ios;net6.0-android;net6.0-maccatalyst</TargetFrameworks> ...
Moving Android first fixed my problem
<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks> ...

I had the same problem and it is now working, try this:
Windows -> Settings -> Update & Security -> For Developers -> Developer Mode - On
Solution Properties -> Deploy - On
Visual Studio -> Tools -> Options -> Xml Hot Reaload -> Disable all
The you can just set your project has startup and run it.

Related

Prism Xamarin.Forms monoandroid81 Add a reference to "MonoAndroid

I keep getting this error. (I'm using Android v8.1 and Prism default template)
Severity Code Description Project File Line Suppression State
Error Your project is not referencing the "MonoAndroid,Version=v8.1"
framework. Add a reference to "MonoAndroid,Version=v8.1" in the "frameworks"
section of your project.json, and then re-run NuGet restore.d#
PrismHelloWorld.Android
So I went into my project.assets.json and change the "monoandroid71" to "monoandroid81"
"originalTargetFrameworks": [
"monoandroid71"
...
"monoandroid71": {
"projectReferences": {
...
"frameworks": {
"monoandroid71": {
I also changed
"projectFileDependencyGroups": {
"MonoAndroid,Version=v7.1": [
and ...
"targets": {
"MonoAndroid,Version=v7.1": {
I hit save and rebuild and it works absolutely fine! The problem is something is editing the json file and turning it all back to 71 and 7.1. I am not sure what is doing it but I will hit built and see the error again, about me needing a reference to v8.1.
Has anyone encountered this issue before?
Go to Android project Options -> Application -> Compile using Android version: (Target framework) and choose Android 8.1 (Oreo). Try different options
I just had the same problem on MvvmCross with Xamarin and I did your solution (changing "monoandroid71" to "monoandroid81" and "v7.1" to "v8.1") but it reverts back after closing and reopening the solution. What I did was do the same thing and do a "Restore NuGet Packages" at the end.
got the same issue, and able to fix it using below option,
Change the target version and rebuild.
I had the same issue, what I did was just restarted VS, and its back to normal
I resolved it by:
Right click Android project => Properties => Application => Compile using Android version => Android 7.1
Clean and Build project => build success, and restart IDE.
Right click Android project => Properties => Application => Compile using Android version => Android 8.1
Clean and Build project => build success
File obj/project.assets.json updated to "MonoAndroid,Version=v8.1"

Remove console logs from ionic app (release)

How do I get rid of console logs from an ionic 2 release application?
I am developing an ionic 2 app. When I build the release apk and run on a device, I can still attach to the process from chrome://inspect, and view console logs. I have tried removing the cordova-plugin-console, but that makes no difference.
Edit: I found a package that can remove console logs: https://www.npmjs.com/package/remove-console-logs
Just not sure how I can use it to automatically remove them when I build release. Please help.
Thanks.
You can use uglifyjs.config.js for drop all console logs when is a production build.
1 . Copy uglifyjs.config.js from node_modules into your project folder
2 . In the new config file set the flag drop_console to true if production
var isProduction = process.env.IONIC_ENV === 'prod';
...
compress: {
drop_console: isProduction
}
3 . Set your custom configuration in the package.json
"config": { "ionic_uglifyjs": "uglifyjs.config.js" },
And that's all !
If you can still connect with the debugger then it is not a release build - sounds like you may be unintentionally installing the debug build OR connecting to some other app.
EDIT; Above is not necessarily true - there are instances where you can debug the js/html/css content via chrome in a release build ; specifically if the webview debuggability flag is set in code / not set by the build system etc. - this flag is seperate from the application debug flags so if not properly set you will be able to debug a "release" build / not be able to debug a "debug" build - see remote debugging webviews.
END OF EDIT.
( note you have to sign a release build before it will install )
Is it possible the release install failed and you're still looking at a previous debug build ?
Assuming you have a release build and can't connect to see logs via chrome inspect then ;
console.log calls will still be in the release build unless you comment them out - and possibly visible in other ways eg. android tools sdk\tools\monitor - The only way to be sure they aren't visible is to comment them out. You could use something like ;
console.log = function(){} ;
at the end of your device ready function after any plugins have done anything they're likely to do - though there's still no 100% guarantee with this as a badly behaving 3rd party plugin or library might reassign it later and then your calls will still happen - to be absolutely sure you will need to comment them out.
Have you tried remove console logs ?
cordova plugin rm cordova-plugin-console
Then
cordova build --release android

Use custom system service in app (Android Studio)

First of all, thank you for your help.
Here is my problem.
I have made a custom system service (it does connect through the binder, and hooks into the system server, then into the HAL, etc). One of the main commands is isBacklightOn(). I also ran the make update-api to include it in my ROM build.
I am now ready to test the functionality using an app. I am using the following code:
import android.os.BacklightManager; //My service manager name
...
BacklightManager bm = (BacklightManager) getSystemService(BACKLIGHT_SERVICE);
...
if(!bm.isBacklightOn()) {
//Turn it on.
} else {
//Other Things...
}
My problem occurs because Android Studio will not build the application due to not knowing what the BacklightManager is. How can I build this application to test my code? (import something into Android Manager, force a build ignoring errors, etc.)
It looks like the solution is to build a custom SDK within the AOSP build environment. And then import that into Android Studio

How to make Android Studio 1.1 call generateDebugTestSources instead of assembleDebugTest during "Make" instruction?

I have a project with 1,000+ tests running fine with Robolectric. After switching to Android Studio 1.1 when I go to "Run" -> "All Tests" during the "Make" instruction Android Studio calls Gradle's assembleDebugTest instead of generateDebugTestSources .. In my case this makes the build system to start dexing and packaging the test APK which is useless for me since all the tests are JVM tests.
I found this change that might be causing it:
- if (testCompileType == TestCompileType.ANDROID_TESTS) {
+ if (testCompileType != TestCompileType.NONE) {
String gradleTaskName = properties.ASSEMBLE_TEST_TASK_NAME;
if (StringUtil.isNotEmpty(gradleTaskName)) {
tasks.add(createBuildTask(gradlePath, gradleTaskName));
Is there a way to make it configurable on Android Studio? Version 1.0 was working fine.
Thanks!
If someone is interested in the solution according to the new Unit Testing guide:
http://tools.android.com/tech-docs/unit-testing-support
you need to change the test artifacts to "Unit Testing" as describe on step 5. That way when you run all the tests AS will call the new assembleDebugUnitTest task instead of assembleDebugTest.

Implementing BlueCove in Android

Has anyone successfully worked with BlueCove in Android?
I've tried to add bluecove.jar in my project but i get the message: The library 'bluecove-2.1.0.jar' contains native libraries that will not run on the device.
Has anyone had and solved this issue?
Follow this link:
http://groups.google.com/group/bluecove-developers/msg/847f714034b34126
and in [ Window -> Preference -> Android -> Build ] unckeck first two voices:
1) Automatically refresch resource....
2) Force error.....
I solved in this way

Categories

Resources