I'm currently having a issue with Mono for Android.
In my application I'm currently saving my variables between sessions using SharedPreferences.
Now whenever I have changed any of the XML or AXML files since the last build, the compiler will rebuild my entire project (clean->build). The deployment of the app will therefore always do the "Removing previous version" step first , be it on a emulator or a Android device. This will also remove all variables in the SharedPreferences class, resulting in having to reinitialize those pieces of data, which becomes very tedious if I'm working on the XML files.
Is there any way to prevent that the project will be rebuild if the XML files are modified. Or is there any way to prevent the SharedPreference data from being removed if the application gets re-installed?
Extra info:
Build target: API 10
Mono for Android Version:4.2.3
IDE: Visual Studio 2010 Ultimate SP1
Emulator: API 10 Atom x86 default emulator
Device: Samsung Galaxy Wonder (Android 2.3.3)
A rebuild is necessary when resource files change since it can result in a change to the generated Resource class. That said, Mono for Android does provide an option to preserve application data between deploys to help in situations like this.
If you look under Options-> Mono for Android you'll see a checkbox labeled "Preserve application data/cache on device between deploys" to turn on this feature.
Related
I'm new to MAUI so I followed the instructions on Microsoft's Build Your First App page. I ran the Android emulator and everything worked fine.
I then followed this page to build a flashlight app, but when I ran it, the emulator started fine, but the app never loaded.
In the output window in Visual Studio, I saw this:
[mono] debugger-agent: Unable to connect to 10.0.2.2:54762
I created a brand new .NET MAUI app, made no changes and ran that, same result.
I followed the deployment issues section on this page to no avail.
Also, when I ran sdkmanager --update, I got the following output:
[=== ] 10% Computing updates...
Updating:
platform-tools
emulator
Warning: Failed to read or create install properties file.
[=== ] 10% Installing Android Emulator
where it's saying it failed to read/install the properties file.
I also tried Razwill-1930's answer on this page, again, to no avail.
I'm running .NET 6 in Visual Studio 17.3.5 on Windows 11 Pro.
What am I doing wrong?
Update
I downloaded another emulator and that one works fine, which for my purposes, I'm OK with not being able to use the Pixel 6 emulator that gets installed with the .NET MAUI workload in VS. How can I get it going?
I ended up deleting the emulator (Pixel 5 - API 31) and then reinstalling it.
That worked.
Not sure why that worked, the Android Device Manager didn't re-download the files.
Hey, banging the TV sometimes works too.
The issue is with your emulator, I would highly recommend you recreate the emulator. Points to remember when doing so:
Make sure you have the latest version of the API version's Image
Select Arm64 as your processor (has lesser lag).
Hardware-based GUI has better performance.
Just FYI Assigning too much RAM won't make it faster
I upload an app on google play store. I am using xamarin / visual studio and I have bundle my app. so this is aab, not apk. also I am using visual studio so I dont have gradle file
it is giving me 2 warnings
Warning-1
This App Bundle contains Java/Kotlin code, which might be obfuscated. We recommend you upload a deobfuscation file to make your crashes and ANRs easier to analyze and debug. Learn More
Warning-2
This App Bundle contains native code, and you've not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug. Learn More
My Question: how do i create deobfuscation & symbol files? are these just empty text files?
On Google Play store console - I found a section where I can upload mapping & symbol files, but not deobfuscation file
App Bundle Explorer > Downloads > Assets >
Re-Trace mapping file > upload
Native Debug Symbols > upload
For this, you can refer to document Preparing an Application for Release.
You can follow the following steps to build the app for release:
Specify the Application Icon – Each Xamarin.Android application should have an application icon specified. Although not technically necessary, some markets, such as Google Play, require it.
Version the Application – This step involves initializing or updating the versioning information. This is important for future application updates and to ensure that the users are aware of which version of the application they have installed.
Shrink the APK – The size of the final APK can be substantially reduced by using the Xamarin.Android linker on the managed code and ProGuard on the Java bytecode.
Protect the Application – Prevent users or attackers from debugging, tampering, or reverse engineering the application by disabling debugging, obfuscating the managed code, adding anti-debug and anti-tamper, and using native compilation.
Set Packaging Properties – Packaging properties control the creation of the Android application package (APK). This step optimizes the APK, protects its assets, and modularizes the packaging as needed. Additionally, you can provide your users with an Android App Bundle that's optimized for their devices.
Compile – This step compiles the code and assets to verify that it builds in Release mode.
Archive for Publishing – This step builds the app and places it in an archive for signing and publishing.
Especially part Shrink the APK and Protect the Application.
Pay attention to Application Protection with Dotfuscator:
Even with debugging disabled, it is still possible for attackers to re-package an application, adding or removing configuration options or permissions. This allows them to reverse-engineer, debug, or tamper with the application. Dotfuscator Community Edition (CE) can be used to obfuscate managed code and inject runtime security state detection code into a Xamarin.Android app at build time to detect and respond if the app is running on a rooted device.
Dotfuscator CE is included with Visual Studio . To use Dotfuscator, click Tools > PreEmptive Protection - Dotfuscator.
To configure Dotfuscator CE, please see Using Dotfuscator Community Edition with Xamarin. Once it is configured, Dotfuscator CE will automatically protect each build that is created.
I am trying to deploy my Xamarin.Android application from visual studio to my smartphone which is Huawei P10. During compilation a popup shows up:
After you close the popup an error shows up:
Severity Code Description Project File Line Suppression State
Error XA0136: The 'run-as' command failed with 'run-as: package has corrupt installation: com.companyname.app1'.
The currently installation of the package in corrupt. Please manually uninstall the
package from all the users on device and try again. If that does not work you can disable Fast Deployment.
Fast Deployment can be disabled in the Visual Studio project property pages or edit the project file in a text editor and set the 'EmbedAssembliesIntoApk' MSBuild property to 'true'.
Tools and Devices used:
Visual Studio 2019 version 16.10.1
Xamarin Android
Deploy to Huawei P10 Android 9.0 API 28
Any suggestions pls on what is the problem.
Thanks
UPDATE: If you disable Fast Deployment works fine
According to Xamarin, you have to activate the developer mode for this. In addition, debugging via USB must be approved. You can find the exact statement here on GitHub. If you don't know how to activate the mode, you can find instructions here.
Alternatively, if all these steps did not work you can disable 'Fast development'. Either do this in your project or via Visual Studio.
Fast deployment is known to fail on devices which block run-as, which often includes devices older than Android 5.0. Fast deployment also fails for system applications (android:sharedUserId="android.uid.system") since run-as is also blocked for system applications.
If these solutions work let me know!
I also got this issue when trying to run the app in emulator. But I fixed it by changing to new android emulator
I have written a simple c# app to let my son do some stats on dice rolling for a game he is developing.
I created a simple interface using Visual Studio 2017 and Universal Windows.
After loads of silly errors - and lots of less silly ones, I finally have an app that runs as I want it to in debug mode.
I now want to publish it so he can copy the files and run it on his Windows computer.
Now I am sure this is really easy - but after 2 days of google searching, MSDN searching and searching this forum I am no nearer knowing what I need to do.
I have changed the solution configuration to Release and the platform to x86. I have run Build and Deploy solution form the build menu and have loads of files in my bin/x86/release file partial list from windows explorer.
But none of the exe files seem to do anything (the app5.exe waits a while sometimes, but no sign of the app anywhere).
I am obviously missing some critical preparatory step, but I can't find out what it is.
Some of the MSDN notes talk about Publish (this is greyed out or not present, but Deploy appears).
Can anyone please point me to some idiot proof documentation to help me work out what I should be doing.
I am new to Visual Studio, new to C# and new to windows app development - so my app has been pulled together from web research and using common sense :)
I have assumed that what I am trying to do is pretty easy - but I am not yet convinced.
To sell your Universal Windows Platform (UWP) app or distribute it to other users, you need to package it. If you don't want to distribute your app through Microsoft Store, you can sideload the app package directly to a device. Since you used the VS, you can follow this document to package a UWP app with Visual Studio: https://learn.microsoft.com/en-us/windows/uwp/packaging/packaging-uwp-apps#sideload-your-app-package.
After you package your app, if you want to sideload your app, you can follow the How do I sideload an app on desktop part in the following document:
https://learn.microsoft.com/en-us/windows/application-management/sideload-apps-in-windows-10#how-do-i-sideload-an-app-on-desktop
More details, you can get from this topic:
https://learn.microsoft.com/en-us/windows/uwp/packaging/
When I open a sample Blinky application in Visual Studio, compile and run it, it gets automatically deployed to the target configured WindowsIoT device. After that, on Windows 10 machine where I compile it, the application binaries are located in the bin sub-folder of the project folder as one would expect.
I would like to automate the deployment, so that I could run deployment code
without Visual Studio, specify target device and the binaries location and it would deploy it. I cannot find any API that allows
to deploy apps to Windows IoT, how do I do that?
This shiny Windows IoT stuff is a new area, and there is not a lot of info available apart from the samples and the getting started page. Any pointers are appreciated.
Update: As noted in comments, once one start thinking of mass production, they will probably need to conciser ICD. This, is not, however the problem I'm trying to solve currently. I would like to figure out how I can provide Over-the-Air updates to my UWP application running on Raspberry Pi and Windows IoT. I also would you like to know how I can automate build / deployment in general, but that may be automatically solved if I have a proper OTA solution.
There is a set of instructions on how to do it, which can be found in the same github repo you are linking in your question, but in a different folder. Note, that you need an appx for these instructions to work, and it's not created by the solution build by default.
This page provide (non IoT specific) instructions on using VS to build the appx. And this blog post talks about the command line tool that can be used for making appx.
Note, that the last two links are also talking about publishing an application to app store, so you'll need to make some mental adjustments around that.