Maui: appsettings.json file not copied to device - maui

I am trying to implement an appsettings.json file with my Maui Android app.
I've followed multiple examples of how to get this to work but I think the issue is the json file is not getting copied to the device.
https://montemagno.com/dotnet-maui-appsettings-json-configuration/
I've used Android Studio to browse the Manifest folder on my android device but the file is not there.
I tried creating appsettings.json in the root of the project and also tried in the Resources\Raw.
I tried setting the Build Action to {None, Embedded Resource, Maui Asset, Android Resource}
I've also tried removing "myassembly" in the code below.
var a = Assembly.GetExecutingAssembly();
using var stream = a.GetManifestResourceStream("myassembly.appsettings.json");
var config = new ConfigurationBuilder().AddJsonStream(stream).Build();
builder.Configuration.AddConfiguration(config);
Here's how to reproduce this problem.
I'm using VS2022 17.3.0 Preview 5.0
Create a new .Net Maui App named MauiApp1 for .Net 6.0
Add appsettings.json to the root of the project
Set these properties on appsettings.json:
Build Action to "Embedded Resource"
Copy to Output Directory to "Copy Always"
Debug as either Android Emulator or Physical device
for mine I have Android Emulator - Pixel 5
also Zebra Technologies MC93 Android Scan gun
Wait for the application to deploy. I use Android Studio Device Manager to browse either Emulator or Physical device.
Browse to /data/data/com.companyname.mauiapp1/files/.__override__
look for mauiapp1.appsettings.json -- not found
look for appsettings.json -- not found
shouldn't the file be here??
Any help would be appreciated.
Thanks

Related

Freeze on Copying APK file

I created a new empty project, switched platform to Android and started Build and Run. But when it comes to "Copying APK File to device" it just freezes and I have to restart Unity.
I installed Android SDK & NDK tools just before that (through Unity Hub). Android Build Support was installed by me manually a while ago so it was visible as installed in Add Modules window. I did not do any changes to the project. The most interesting thing is that the apk is built in my Builds folder. Not sure if it works though.
I am using Unity 2019.1.0f2. The device Android version is 9.0 (API level 28) and the minimum API set in Player is 16, so the problem should not be with API.
Does anyone know possible reasons for it?
Try to turn off the following setting on your android device.
Settings -> Developer options -> Monitor apps installed by ADB
This setting(if turned on) will ask a verrification if you want to install the app. It feels like this cuts off the connection with unity which causes it to get stuck.
Unplugging and replugging the device seems to work aswell. In case of big projects this is anoying tho since if you are to quick it will just say it lost connection and it will ask if you want to reconnect, which in turn causes the same problem.
This is the only answer that worked for me:
https://answers.unity.com/questions/1248123/build-run-apk-freezes-on-pushing-content-only-one.html
In short, Player settings -> Publishing settings -> Split application binary
First of I would ask you on what computer did you run this on? (performance wise)
Second you can just copy the .apk file to the phone and install it there. If you got to where it prompts for copying to android your apk file is fine and built.

Add android target to visual studio for Mac

I'm building over a non from scratch project, that a previous developer created in my office.
In a previous version of Unity - Visual Studio for Mac I generated some build for iOS, but now, with the newest version, I get this configuration:
Also, the configuration for Android is disabled.
How I can add Android as target for my project to generate an apk file?
UPDATE 1
VS Configuration.
UPDATE 2 / BUILD CONFING
Please refer to the following link to setup unity to make Android APK:
https://docs.unity3d.com/Manual/android-sdksetup.html
You will need to download: the latest version of java, and the android sdk.
You will need to set the unity path to the sdk
You will need to download and set up the android ndk.
Sounds like a lot of work but its really a lot of waiting. the Android SDK can take some time depending on which versions you wish to support and how far back you go.
Once you have followed the guide above you will be able to change your project to android in the project settings menu.
Good luck!
For mac users with unity looking to set up android:
Instructions for Mac
you should be able to select android here and then click switch platform...

Visual Studio doesn't generate the iOS "ipa" executable with Xamarin

I am trying to generate the ipa file in order to publish it to the Apple Store but Visual Studio (2015 Community Edition) doesn't create it.
I followed the steps from the official Xamarin docs but it doesn't work, I tried selecting "AdHoc", "Release" and "AppStore" (with iPhone platform selected), I have the last Xamarin updates in my Windows and Mac build hosts, the build process ends succesfully but the ipa file doesn't appear in the **Bin > iPhone > Ad Hoc (or Release) folder.
I am using the distribution profile.
I would really appreciate any help.
A combination of clearing the bin/iPhone/Ad-Hoc folder, changing the build number, restarting Visual Studio, and re-connecting to the Mac resolved this for me.

VS2015: Missing Debug targets for TACO

I'm using VS2015 and just updated the Visual Studio Android Emulator (to 1.1.622.2) this morning. Since I've done so, the debug targets have disappeared for all of my TACO projects (the drop-down is empty for all device types, incl. Android and iOS):
I have followed the instructions here, but no CoreCon folder is recreated when I re-build. The build does succeed (i.e. I get an .apk file that works) but I can't deploy to any emulator or local device from Visual Studio. The emulator itself works fine.
Any ideas? I've tried rebuilding the Cordova cache but with no success.

how to connect android studio with emulator that was built from android source

i have followed instructions on http://source.android.com/source/building.html and built for lunch option aosp_arm_eng. The emulator that's available as part of the build is loading fine. Now i am unable to find details how i can make my android studio make use of the emualtor images i just built. Emulator seems to work with AVDs known to it (tools -> android -> AVD manager list) but does not have way to use new images that might have been custom built on the local machine.
I plan to make some changes to android media framework source(frameworks/av/media), rebuild the system image, make the emulator use updated image, and re-test my application using android-studio.