How to add .so files to an apk? - c#

I'm having difficulties implementing serial communication in .NET MAUI 7.
I have confirmed that the project at Xamarin.Android.SerialPort works properly.
However, it does not work in my project.
I get an error at [new SerialPort.SerialPortWrapper.SerialPort].
errorCapture
How can I add the libserial.so file to my project APK?
It's too difficult.
Please help.
I have added the open source project from the link to my project, but it does not work.

Related

Can I finally get an .AAB file format from MAUI?

Hello internet people.
I am trying to publish an android app using MAUI to playStore for testing. After reading the documentation, I however keep getting an APK file, but I actually need an .AAB file.
What can I do to achieve this?
Thanks.
Thanks to Gerald and Fildor in the comments to the question.
I have to update the Maui Project Properties, almost like it is done in the Xamarin counterpart.
Below are the steps I took:
Open your solution explorer to the MAUI project
Right click on the solution and go to properties
Go to the Android/Properties in the menu
Set the solutions to Bundles before following the documentation
After which I got the .aab files

This error is preventing me from building my UWP app on a new Xamarin Form project

I'm beginning my first Xamarin project. I started with setting up an android project and I have gotten it working with the emulator.
But after following the instructions of this video
(https://www.youtube.com/watch?v=mbIvG8ripcw&t=590s&ab_channel=GeraldVersluis)
I get the following error when I try to build:
Expected "!$([System.String]::new('%(ReferenceCopyLocalPaths.Identity)').EndsWith('System.Runtime.dll'))" to evaluate to a boolean instead of "!$([System.String]::new('E:\(PATH TO APP FOLDER)\Notes App\NotesApp\NotesApp\bin\Debug\netstandard2.0\NotesApp.dll').EndsWith('System.Runtime.dll'))", in condition "'$(_CoreFrameworkPackageId)' != ''
AND !$([System.String]::new('%(ReferenceCopyLocalPaths.Identity)').EndsWith('System.Runtime.dll'))
AND '%(ReferenceCopyLocalPaths.NuGetPackageId)' == '$(_CoreFrameworkPackageId)'". NotesApp.UWP
^^ The error code I get for this is MSB4100
I also keep having the Nuget packages Xamarin.Forms and the Microsoft.NETCore.UniversalWindowsPlatform go missing from the references of my project even though they are installed within it. After restarting VS multiple times and toggling on/off settings that alters the project/solution heavily they pop back into existance.
These packages when they go missing give me 10s and I even saw once, 200 errors and they all disappear after turning on and then off again, for example "Compile with .NET Native tool chain" in the build settings.
But the big error above still remains.
========================================
All Nuget packages are up to date and VS is up to date (and I used the repair tool).
I've removed the UWP project and created a new one, and I get the same result.
If anyone can help me solve this and let me know if I've made a silly mistake it would be appreciated. I would like to master this.
If you need any more info let me know, thanks.
Update 1
I've reinstalled my nuget packages and restarted VS and this is my screen. Note I have the package on screen installed but not showing up in my references. Plus some warnings that go away when they feel like it.
Update 2
I created a brand new xamarin android and uwp project template, did not touch a thing, and I tried to build and deploy the uwp project and I get this error
I created a project that was not buring by many layers of folders, in my C drive and not my external exFAT E drive and it now works.
Thanks for your help guys.

Importing and using .cs library in to main project (C#)

I'm totally new to programming in c# with visual studio and I would need your help to resolve a problem I'm having.
I created a UWP (Universal Windows Platform) Application that I can remotly run on my Raspberry PI 3.
For this project I need communication with a RFID reader that is plugged in to my raspberry PI true SPI.
I found some code that indicates how to do this but I'm unable to add this library in to my project, below the link can be found of what I'm trying to do. I would like to import the Library Mfrc522Lib.cs in to my project and use it in my main form. Can anyone indicate me how I need to do this?
Link : https://stackoverflow.com/questions/34284498/rfid-rc522-raspberry-pi-2-windows-iot#=
Thanks a lot!
What you wanna do is include Mfrc522Lib.cs into your project.
Right click your Main project file in visual studio and select add option, from there select Exisiting item and add Mfrc522Lib.cs.
Its better to copy the Mfrc522Lib.cs to the physical path of your project
file.

Creating a new project from exported template in VS doesn't bring in any code

I have exported templates for WPF projects plenty of times in the past with success - Right now I have a dotnet core 2 console app (C#).
I've exported a project template within VS, and the output looks similar to any other WPF project I have exported, the .vstemplate file looks correct.
I create a new project in VS using the exported dotnet core 2 template, but all it brings in is the dependencies. It brings in no folders, no code, etc.
I see no errors etc, however I also don't have a properly imported project...On left is the solution explorer of a new project created using the template, and on the right is some of the contents of the .vstemplate, showing that there are missing files it should be bringing in. Those files are also present within the exported template.
for reference, The name of the exported project is BinanceBase (on the right) and on the left is the new project, BinanceCandleScraper.
This is a known problem with .NETCore project templates in the current version of VS2017. The primary bug report is here. Fwiw, developercommunity.visualstudio.com is always the site you want to search first whenever you encounter VS2017 issues.
Chasing the links lands you on Iris Classon's web page, she diagnosed the underlying problem. And discovered the workaround, you have to edit the project template by hand. Inside the <TemplateData> element, you have to edit:
<CreateInPlace>true</CreateInPlace>
Credit to Iris for figuring this out, I can't tell how she did it.

"Invalid Swift Support" Using Native Swift Library in Xamarin.iOS

I just implemented a native library, Charts (original native library), and its working on my phone and simulator. Unfortunately, when I submit it to iTunes connect, it kicks it back after processing and says:
Invalid Swift Support - The SwiftSupport folder is missing. Rebuild
your app using the current public (GM) version of Xcode and resubmit
it.
I'm using XCode to publish the archive to iTunes connect, but don't know how to do what this StackOverflow solution is saying. Since I don't use XCode to start the build process, I'm using Xamarin Studio 6, not sure how to set that setting.
So ideally, I need to "Set the flag EMBEDDED_CONTENT_CONTAINS_SWIFT to YES in the target settings".
Anybody have any ideas on how to do this? At a roadblock on releasing the beta until I can get this uploaded.
Thanks for your help!
What's your Xcode version? Make sure to be using the latest and GM one, I believe it to be 7.3. The script described on the Readme copy the files from Xcode folder.
If you unpack the IPA created after the script ran you can check for the folder's existence.
When rebuilding and binding the library the option "Set the flag EMBEDDED_CONTENT_CONTAINS_SWIFT to YES in the target settings" Didn't work for me as well.
Apple stated when trying to publish: "Invalid Frameworks folder". Xcode will embed files as in: 'Payload/YOURAPP.app/Frameworks/Charts.framework/Frameworks/libswiftCore.dylib', but in the final App it should be as in: 'Payload/YOURAPP.app/Frameworks/libswiftCore.dylib' and 'SwiftSupport/libswiftCore.dylib'.
To solve the problem the library does it in the build process. And you need the script to fix the 'SwiftSupport' folder. I didn't found a way to tamper with Xamarin Studio 'Archive for Publish' function.
Update: You can just use this script I threw together to fix your IPA so it's properly formatted, download the Auto IPA Packager on Github. It's a simplification of the IPA Packager I reference below, and handles all of the steps below too.
So, I've finally made it submit properly to the App Store, just had to hop through a few more steps than I expected. A lot of my confusion was because I didn't want to leave out other artifacts. I've decided to list the process here so it's very clear for anybody deploying an iOS app in the future that needs to use this tool.
Download the IPA Packager from GitHub.
Then go to Xamarin Studio, and Build > Archive for Publishing.
I've been using XCode to export my archives. Open XCode, Window > Organizer. Find your app archive, and click "Export" and follow the appropriate steps, then save it.
Locate the .ipa file and change it to .zip, and extract it.
Next, in the extracted files, locate the "AppNameFolder > Payload > AppName.app".
Load terminal and execute the following:
sh package_ipa.sh /AppNameFolder/Payload/AppName.app /AppNameFolder/AppName.ipa
AppName.ipa should now be created. This file should be ready to upload to the App Store. However, if your AppNameFolder has a "Symbols" directory you should follow the additional steps below...
Optional: If you have symbol files, you should change the AppName.ipa to AppName.zip and extract the files.
Drag the "AppNameFolder > Symbols" directory into the extracted AppName folder, then zip the contents of the folder and change the extension back to .ipa.
I had some issue getting #jamesbar2 solution to work. Here are my manual steps for uploading Xamarin builds with Swift packages.
Archive your app for Publishing.
When the Archives window pops up, go to it in Finder (right click on it and select "Reveal in Finder").
When Finder appears, we need to access the archive's content (right click and select "Show Package Contents").
Inside of the archive package, create a folder called "SwiftSupport".
Inside of the package navigate to "Product/Applications/YourAppName.app/Frameworks" (You will need to right click on the .app and select "Show Package Contents").
Copy all the swift ".dylib" files inside of the Frameworks directory.
Navigate back to "SwiftSupport" and paste those copied libraries.
Now Launch Xcode and load Organizer (Window -> Organizer).
Find your app in the Archives and "Upload to App Store...".
I was only able to get this to work using Xcode Organizer, using Xamarin always failed.
Note: I am using Visual Studio for Mac Community 7.3.2 (build 12).
Update:
I recently had issues with uploading, with TestFlight rejection email saying something like:
The file libswiftCore.dylib doesn’t have the correct code signature. blah, blah, blah.
To fix this problem instead of copying the Frameworks from your app Framework folder, grab them from Xcode. You can find them at:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos
Note TestFlight would reject my build if I added all the Frameworks to SwiftSupport folder. Only include the Frameworks that your app is using.

Categories