Xamarin run activity from other project in same solution - c#

I have a xamarin solution with two android projects. I would like to run android activity in project1 from project2. I ‘ve seen threads related to this topic (like How to call an activity in another project?
Call activity from another project) and tried many suggested solutions but In the end I always get „Android.Content.ActivityNotFoundException: 'Unable to find explicit activity class {companyname.project2/companyname.project2.Droid.View.LoginView}; have you declared this activity in your AndroidManifest.xml?'” error. Is this possible in xamarin if yes how? Am I doing something wrong? Here is my source code:
Project1:
namespace BigAppManager {
    [Activity (MainLauncher = true, Name = "com.companyname.bigappmanager.MainActivity", Label = " Logowanie", ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, NoHistory = true, LaunchMode = LaunchMode.SingleInstance)]
    public class MainActivity : MvxActivity<MainActivityViewModel> {
        protected override void OnCreate (Bundle savedInstanceState) {
            base.OnCreate (savedInstanceState);
            Xamarin.Essentials.Platform.Init (this, savedInstanceState);
            
            SetContentView (Resource.Layout.activity_main);
            Button button = FindViewById<Button> (Resource.Id.button);
            button.Click += ClickButton;
        }
        private void ClickButton (object sender, EventArgs e) {
  
            //Intent intent = new Intent("companyname.project2.Droid.View.LoginView");
            //StartActivity(intent);
            Intent intent = new Intent (Intent.ActionMain);
            intent.AddCategory (Intent.CategoryLauncher);
            // intent.SetClassName("companyname.project2", "companyname.project2.Droid.View.LoginView");
            intent.SetComponent (new ComponentName ("companyname.project2", "companyname.project2.Droid.View.LoginView"));
            StartActivity (intent);
        }
        public override void OnRequestPermissionsResult (int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults) {
            Xamarin.Essentials.Platform.OnRequestPermissionsResult (requestCode, permissions, grantResults);
            base.OnRequestPermissionsResult (requestCode, permissions, grantResults);
        }
    }
}
Project2:
    
[Activity(Name = "companyname.project2.Droid.View.LoginView", Label = " Logowanie", ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, NoHistory = true, LaunchMode = LaunchMode.SingleInstance)]
    public class LoginView : MvxActivity<LoginViewModel>
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.LoginView);
        }
    }
Project 2 android manifest intent filter:
<activity android:name="companyname.project2.Droid.View.LoginView">
<intent-filter>
<action android:name="companyname.project2.View.LoginView"></action>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

I don't think Manifests are merged by default. So if you look at the resulting AndroidManifest.xml in obj/Debug/android when building, you will probably notice that the LoginView entry is missing.
You can try adding the following NuGet package to your App project and see if that will merge the manifests: https://www.nuget.org/packages/Xamarin.Android.ManifestMerger/1.0.0-preview03
Otherwise, you will need to add the same entry manually in your Apps manifest for the LoginView.
EDIT:
Make sure you use the correct intent. This works fine for me:
var intent = new Intent(this, typeof(LoginView));

Related

Unable to find explicit activity class when open deeplink

I had Xamarin.Android App with deeplinks on API32. After I updated API to 33, Deeplinks has broken. I had this exception in my logs:
Time Device Name Type PID Tag Message
02-14 08:25:48.878 OnePlus IN2015 Error 16453 AcceptInvitation android.content.ActivityNotFoundException: Unable to find explicit activity class {PACKAGENAME/crc645ff435851f1c2612.MainActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared <intent-filter>?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2184)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1831)
at android.app.Activity.startActivityForResult(Activity.java:5555)
at hcm.platform_startActivityForResult(:com.google.android.gms#230413045#23.04.13 (190408-505809224):2)
at hcl.startActivityForResult(:com.google.android.gms#230413045#23.04.13 (190408-505809224):2)
at com.google.android.chimera.android.Activity.startActivityForResult(:com.google.android.gms#230413045#23.04.13 (190408-505809224):2)
at hgx.startActivityForResult(:com.google.android.gms#230413045#23.04.13 (190408-505809224):2)
at hcl.public_startActivityForResult(:com.google.android.gms#230413045#23.04.13 (190408-505809224):2)
at hcm.startActivityForResult(:com.google.android.gms#230413045#23.04.13 (190408-505809224):3)
at android.app.Activity.startActivityForResult(Activity.java:5508)
at hcm.platform_startActivityForResult(:com.google.android.gms#230413045#23.04.13 (190408-505809224):1)
at hcl.startActivityForResult(:com.google.android.gms#230413045#23.04.13 (190408-505809224):1)
at com.google.android.chimera.android.Activity.startActivityForResult(:com.google.android.gms#230413045#23.04.13 (190408-505809224):1)
at hgx.startActivityForResult(:com.google.android.gms#230413045#23.04.13 (190408-505809224):1)
at hcl.public_startActivityForResult(:com.google.android.gms#230413045#23.04.13 (190408-505809224):1)
at hcm.startActivityForResult(:com.google.android.gms#230413045#23.04.13 (190408-505809224):1)
at android.app.Activity.startActivity(Activity.java:6011)
at hcm.platform_startActivity(:com.google.android.gms#230413045#23.04.13 (190408-505809224):2)
at hcl.startActivity(:com.google.android.gms#230413045#23.04.13 (190408-505809224):2)
at com.google.android.chimera.android.Activity.startActivity(:com.google.android.gms#230413045#23.04.13 (190408-505809224):2)
at hcl.public_startActivity(:com.google.android.gms#230413045#23.04.13 (190408-505809224):2)
at hcm.startActivity(:com.google.android.gms#230413045#23.04.13 (190408-505809224):3)
at android.app.Activity.startActivity(Activity.java:5978)
at hcm.platform_startActivity(:com.google.android.gms#230413045#23.04.13 (190408-505809224):1)
at hcl.startActivity(:com.google.android.gms#230413045#23.04.13 (190408-505809224):1)
at com.google.android.chimera.android.Activity.startActivity(:com.google.android.gms#230413045#23.04.13 (190408-505809224):1)
at kmv.x(:com.google.android.gms#230413045#23.04.13 (190408-505809224):4)
at kmw.onPostExecute(:com.google.android.gms#230413045#23.04.13 (190408-505809224):3)
at android.os.AsyncTask.finish(AsyncTask.java:771)
at android.os.AsyncTask.-$$Nest$mfinish(Unknown Source:0)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:240)
at android.os.Looper.loop(Looper.java:351)
at android.app.ActivityThread.main(ActivityThread.java:8355)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
I tried to google a solution to this problem, tried a lot:
Changed ProGuard settings,
I checked various variations of calling MainActivity with the name of the assembly and just with a dot,
Updated my libraries and SDK,
I tried to prescribe other activities,
I checked the assemblies work both in debug and in release,
Analyzed dex files.
Nothing really helps.
Own analysis showed that the problem is that there are two MainActivities in
the list of activities.
I am also attaching AndroidManifest:
...
<application android:requestLegacyExternalStorage="true"
android:allowBackup="true" android:icon="#mipmap/icon"
android:largeHeap="true" android:supportsRtl="true"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:localeConfig="#xml/locales_config"
android:name=".MyApplication">
...
<activity android:name=".MainActivity" android:exported="true">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="https" />
<data android:scheme="http" />
<data android:host="SITE.com" />
<data android:host="OWN.LINK" />
</intent-filter>
</activity>
...
</application>
MainActivity class has MainLauncher attribute.
Help me please! I spent a day on this and I'm afraid that without help I can be stuck for a long time. Seems like the error might be obvious.
[Activity(ScreenOrientation = ScreenOrientation.Portrait, NoHistory = true, MainLauncher = true)]
public class MainActivity : AppCompatActivity
{
...
}
UPD:
Sometimes I had this exception:
Time Device Name Type PID Tag Message
02-14 08:38:29.150 OnePlus IN2015 Info 28812 MonoDroid Caused by: java.lang.ClassNotFoundException: Didn't find class "PACKAGENAME.MainActivity" on path: DexPathList[[zip file "/data/app/~~jXWlqXqgllqjZ1bi2qN5dg==/PACKAGENAME-gqSZGEIemXo6mh-lUysz-w==/base.apk"],nativeLibraryDirectories=[/data/app/~~jXWlqXqgllqjZ1bi2qN5dg==/PACKAGENAME-gqSZGEIemXo6mh-lUysz-w==/lib/arm64, /data/app/~~jXWlqXqgllqjZ1bi2qN5dg==/PACKAGENAME-gqSZGEIemXo6mh-lUysz-w==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
at androidx.core.app.CoreComponentFactory.instantiateActivity(SourceFile:45)
at android.app.Instrumentation.newActivity(Instrumentation.java:1347)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3745)
... 12 more
From the generated Manifest.xml file you posted, I couldn't find the following intent-filter:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
so, you can recheck if you have set the MainLauncher = true correctly for your Activity.
You can refer to my setting,just as follows:
[Activity(Label = "SearchBarDemos", Icon = "#mipmap/icon", Theme = "#style/MainTheme", MainLauncher = true,Exported =true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[
IntentFilter
(
new[] { Android.Content.Intent.ActionView },
Categories = new[]
{
Android.Content.Intent.CategoryDefault,
Android.Content.Intent.CategoryBrowsable
},
DataSchemes = new[] { "myapp" }
)
]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
}
And you can refer to a similar thread here: Navigate from one app to another using Xamarin.
Note:
If you have set ActivityAttribute MainLauncher = true for your MainActivity, you don't need to set it on fileManifest.xml,which easily leads to generating two MainActivitys you said.
On other words,you don't need to add any code into the generating Manifest.xml file.
For more information,please check:Working with the Android Manifest.
The "ActivityNotFoundException" error generally occurs when an Android app is trying to launch an Activity using an Intent, but the specified Activity class cannot be found or does not exist. You can try below some hit and trial methods:
Issue can be because of incorrect activity class name so make sure that the activity class name in your Intent is correct, including the package name.
Also make sure that the activity class must be declared in your AndroidManifest.xml file, or it will not be recognized by the Android system.
If the Activity class is present in your code, but you still encountering this error, it could be because the Activity class is not being included in your APK file. This can happen if the class is not being referenced properly in your code, or if the build process is excluding the class from the APK.
If the Activity class is being launched through a deep link, just make sure that the correct Intent filters are set up for the Activity in your AndroidManifest.xml file.
It's also possible that the update from API 32 to API 33 could have caused changes in the Android framework that are affecting your deep links. You may want to check the Android Developer documentation for any changes in the way that deep links are handled in API 33, and make any necessary updates to your code accordingly.
I hope these findings may help you out to rectify your doubt.
Thanks.

Xamarin Android Library Binding - Class does not contain a definition

Xamarin Play Core (the package for reviews & tasks needed to launch reviews) split for v2.0.0 into individual packages, so I'm trying to create a Xamarin Android bindings library for the review and tasks. I successfully got tasks working but I am getting this error for the review nuget when it should just work according to their docs. It might be a simple fix, I thought I just had to add these lines in the metadata file but that didn't fix it:
<attr path="/api/package[#name='com.google.android.play.core.review']/class[#name='IReviewManager']" name="extends">Java.Lang.Object</attr>
<attr path="/api/package[#name='com.google.android.play.core.review.testing']/class[#name='FakeReviewManager']" name="extends">Java.Lang.Object</attr>
Here's the error I get:
...PlayCoreUpdateTest/PlayCoreUpdateTest.Android/InAppReviewService.cs(35,35): Error CS1061: 'FakeReviewManager' does not contain a definition for 'LaunchReviewFlow' and no accessible extension method 'LaunchReviewFlow' accepting a first argument of type 'FakeReviewManager' could be found (are you missing a using directive or an assembly reference?) (CS1061) (PlayCoreUpdateTest.Android)
I know the magic happens in the generated api.xml file, so here's a code dump of it. In there I do see the FakeReviewManager, but I don't see the RequestReviewFlow, when it should be there
It's still a work in progress but those are the only remaining issues, here's the GitHub code.
I watched Jonathan Dick's video on creating Xamarin library bindings and tried the Microsoft FAQ options here too
I know my functions in InAppReviewService.cs are correct because that's what the official docs tell us to use, and it's what we were using before for v1.10.
Update: I did notice there's an api.xml.class-parse file beside api.xml, that does contain the missing method LaunchReviewFlow inside the FakeReviewManager class. I'm trying to understand why it didn't show up in api.xml. Here's a dump for that one. I did notice that in the api.xml.class-parse file, there are these lines
return="com.google.android.play.core.tasks.Task<java.lang.Void>"
jni-return="Lcom/google/android/play/core/tasks/Task<Ljava/lang/Void;>;"
...
jni-signature="(Landroid/app/Activity;Lcom/google/android/play/core/review/ReviewInfo;)Lcom/google/android/play/core/tasks/Task;"
which that the v2.0 AAB file points to a play core tasks library even though it recommends pointing to the GMS version of Tasks
To counter that, I tried to add variations of these lines, but none of that helped:
<add-node path="/api/package[#name='com.google.android.play.core.review.testing']/class[#name='FakeReviewManager']">
<method abstract="false" deprecated="not deprecated" final="false" name="launchReviewFlow" jni-signature="(Landroid/app/Activity;Lcom/google/android/play/core/review/ReviewInfo;)Lcom/google/android/gms/tasks/Task;" bridge="false" native="false" return="com.google.android.gms.tasks.Task<java.lang.Void>" jni-return="Lcom/google/android/gms/tasks/Task<Ljava/lang/Void;>;" static="false" synchronized="false" synthetic="false" visibility="public" return-not-null="true">
<parameter name="p0" type="android.app.Activity" jni-type="Landroid/app/Activity;" not-null="true" />
<parameter name="reviewInfo" type="com.google.android.play.core.review.ReviewInfo" jni-type="Lcom/google/android/play/core/review/ReviewInfo;" not-null="true" />
</method>
<method abstract="false" deprecated="not deprecated" final="false" name="requestReviewFlow" jni-signature="()Lcom/google/android/gms/tasks/Task;" bridge="false" native="false" return="com.google.android.gms.tasks.Task<com.google.android.play.core.review.ReviewInfo>" jni-return="Lcom/google/android/gms/tasks/Task<Lcom/google/android/play/core/review/ReviewInfo;>;" static="false" synchronized="false" synthetic="false" visibility="public" return-not-null="true" />
</add-node>

Xamarin C# , I Cant Run Plugin.BLE Codes

I'm trying to make a very simple and basic mobile app for controlling my Arduino with Bluetooth.
Don't have many C# experiences, but it was going well until the Bluetooth part comes.
I've searched everywhere and found this https://github.com/xabre/xamarin-bluetooth-le
and started to do instructions in the readme. But I've got errors every time.
first, I copied these codes to androidmanifest.xml
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
after that, I added these codes to mainpage.xml.cs
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
var ble = CrossBluetoothLE.Current;
var adapter = CrossBluetoothLE.Current.Adapter;
var state = ble.State;
}
}
But that caused 2 errors: Error CS0103 The name 'CrossBluetoothLE' does not exist in the current context BlueT
and I added using Plugin.BLE; so errors disappeared. and I continued to write;
adapter.DeviceDiscovered += (s,a) => deviceList.Add(a.Device);
await adapter.StartScanningForDevicesAsync();
after I paste these, I got that errors:
Error CS4033 The 'await' operator can only be used within an async
method. Consider marking this method with the 'async' modifier and
changing its return type to 'Task
Error CS0103 The name 'deviceList' does not exist in the current
context
I tried everything but couldn't solve this problem, and I'm sorry like I said, don't have many # or Android programming experiences, just want to send these slider and button data to my Arduino:
This is my mobile controller app

Xamarin.Android - Getting Location Providers returns empty every time

I'm learning to develop for Android through Xamarin right now and I'm following this basic tutorial on Xamarin's website. I created a class-level variable LocationManager _mgr; and call InitializeLocationManager(); inside of my OnCreate(Bundle bundle) method. InitializeLocationManager() is implemented as follows:
public void InitializeLocationManager()
{
_mgr = (LocationManager)GetSystemService(LocationService);
Criteria locCriteria = new Criteria { Accuracy = Accuracy.Coarse, PowerRequirement = Power.Medium };
IList<string> acceptableLocationProviders = _mgr.GetProviders(false);
if (acceptableLocationProviders.Any())
{
locationProvider = acceptableLocationProviders.First();
}
else
{
locationProvider = string.Empty;
}
Console.WriteLine($"Using {locationProvider} as our location provider.");
}
The line Criteria locCriteria = new Criteria { Accuracy = Accuracy.Coarse, PowerRequirement = Power.Medium }; differs from the tutorial because along my troubleshooting journey, someone said that it worked for them. When I simply use Accuracy = Accuracy.Fine I get the same exact results.
The line that is written to the console every single time is Using as our location provider", obviously meaning the empty string.
The class (MainActivity) extends from Activity and implements ILocationListener correctly. The codefile is declared to use System.Linq, so IList methods .Any() and .First() both work correctly.
Why is this not working? I've followed the tutorial nearly identically, save for some variable names. I have ensured that I have location turned on with my testing device. I am not on WiFi, and when I was, it still did not work. I'm on 4G LTE, and it does not work.
Any ideas would be much appreciated.
Thanks so much.
EDIT: UPDATE: I added the following piece of code to my OnCreate() method:
if( ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) == Android.Content.PM.Permission.Granted )
{
Console.WriteLine($"We've got permission!");
}
else
{
Console.WriteLine($"We don't have permission you idiot!");
}
And the line written is We don't have permission you idiot! every time. My AndroidManifest.xml has these lines:
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.LOCATION_HARDWARE" />
<uses-feature android:name="android.hardware.location.gps" />
<application android:allowBackup="true" android:label="#string/app_name"></application>
My AssemblyInfo.cs file has these lines, just like the tutorial:
[assembly: UsesPermission(Manifest.Permission.Internet)]
[assembly: UsesPermission(Manifest.Permission.AccessFineLocation)]
[assembly: UsesPermission(Manifest.Permission.AccessCoarseLocation)]
My application does not request permissions on startup. What is going on?
If LocationManager.GetProviders returns an empty Java ArrayList when requesting provider even if they are turned off/unavailable, then you have not requested permission to course|fine location.
First, either manually add the permission to the manifest:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Or even better, use the Build / Android application / Required Permissions options panel:
Second, if targeting Marshmallow/API-23 or later, make sure you are requesting runtime location permission (and still include the permission entries in the manifest).
https://blog.xamarin.com/requesting-runtime-permissions-in-android-marshmallow/
Note: That you are not using the location criteria that you are defining, you need pass it into the GetProviders method:
IList<string> acceptableLocationProviders = _mgr.GetProviders(locCriteria, false);

UWP: Cannot load PWM Controllers using Lightning on Raspberry Pi 2?

i justed started working on an older Project i started once, but unfortunately the PWM Controller is not working anymore with the Lightning Driver. I am using Visual Studio 2017, the RPi2 is running at 10.0.15063.414 and I've installed the following Nuget-Packages:
Microsoft.IoT.Lightning (v1.1.0)
Microsoft.NETCore.UniversalWindowsPlatform (v5.3.3)
WinRTXamlToolkit.Controls.DataVisualization (v2.3.0)
The Project includes references to
Analyzer
Microsoft.IoT.Lightning
Microsoft.NETCore.UniversalWindowsPlatform
%ClassesLibrary%
UniversalWindows
Windows IoT Extensions for the UWP
WinRTXamlToolkit.Controls.DataVisualization,
where %ClassesLibrary% is an user-defined Project containing some classes for my Project. In the configuration web Interface of Windows IoT Core in the devices section, the Direct Memory Mapped Driver (Current Driver) is selected.
My initialization Code Looks like this
private static async Task InitOnboardHardware()
{
if (LightningProvider.IsLightningEnabled)
{
LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider();
GpioController gpioController = GpioController.GetDefault();
var pwmControllers = await PwmController.GetControllersAsync(LightningPwmProvider.GetPwmProvider());
if (pwmControllers != null)
{
m_PWMController = pwmControllers[1];
//m_PWMController = (await PwmController.GetControllersAsync(LightningPwmProvider.GetPwmProvider()))[1];
m_PWMController.SetDesiredFrequency(100);
m_RPin = m_PWMController.OpenPin(18);
m_GPin = m_PWMController.OpenPin(23);
m_BPin = m_PWMController.OpenPin(24);
m_WPin = m_PWMController.OpenPin(25);
m_RPin.SetActiveDutyCyclePercentage(0);
m_GPin.SetActiveDutyCyclePercentage(0);
m_BPin.SetActiveDutyCyclePercentage(0);
m_WPin.SetActiveDutyCyclePercentage(0);
m_RPin.Start();
m_GPin.Start();
m_BPin.Start();
m_WPin.Start();
m_IsHardwareInitialized = true;
}
}
}
The PwmController.GetControllersAsync-method never completes and my application gets stuck on starting up. Also the commented Shorter Version is not working anymore?!
I have really no clue what i could be missing. Therefore, i would greatly appreciate any help.
Thank you in advance!
EDIT: I also tried another sample (https://github.com/lprichar/WindowsIotPwmExample), where i replaced the embedded C/C++ lightning library by the NuGet Package (same Version as in my Project). The sample also Fails: the Pins are all null, because PwmController.GetControllersAsync never completes :-(
EDIT2: I forgot to mention that my package.appxmanifest file also includes the following changes
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10"
IgnorableNamespaces="uap mp iot">
as well as
<Capabilities>
<Capability Name="internetClient" />
<iot:Capability Name="lowLevelDevices" />
<DeviceCapability Name="109b86ad-f53d-4b76-aa5f-821e2ddf2141" />
</Capabilities>
Please also see my comment to the first post. I had to Change this line
GpioController gpioController = GpioController.GetDefault();
to an async method call
GpioController gpioController = await GpioController.GetDefaultAsync();
and now everythings runs fine!

Categories