1

I have Xamarin Android project created in Visual Studio. I would like to create unit test project for my mobile app. I tired xUnit Test Project but I have problem with linking both projects: Linking xUnit with Android app

I tried also Unit Test App (android) and I didn't have any problems with linking both projects but in this project I have problems and I don't know how can I initialize/use classes/functions from my main android project. I'm trying using (MainProjectName) but Unit tests project doesn't see any other projects/directories.

EDIT: When I try to build Unit Test App I get an error:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2): Error XA5211: Embedded wear app package name differs from handheld app package name (com.companyname.matchfinder != UnitTests.UnitTests). (XA5211) (UnitTests)
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Mateusz Piwowarski
  • 559
  • 1
  • 6
  • 15

1 Answers1

0

To solve your problem,you can try to open the .csproj file of your Android app and find the project reference you need to work. It might look like this:

<ProjectReference Include="..\MyWearApp\MyWearApp.csproj">
   <Project>{D80E1FEF-653B-448C-B2AA-609C74E88340}</Project>
   <Name>MyWearApp</Name>
   <IsAppExtension>True</IsAppExtension>
</ProjectReference>

The problem is with the extension part. Simply remove the IsAppExtension line and any other than Project and Name.

For more details, you can check: https://learn.microsoft.com/zh-cn/xamarin/android/wear/deploy-test/packaging?tabs=windows

Jessie Zhang -MSFT
  • 9,830
  • 1
  • 7
  • 19