'Xamarin Android Archive error. Invalid Android Archive (no .APK files)

I am trying to publish an APK for a PCL Xamarin project. I am following these steps: Publishing An Application and at the 'Archive for Publishing' step I get the following error after a small wait:

"Failed to create App archive 'MyProject_Test.Droid' Invalid Android Archive (no .APK files)"

I have rebuild my Solution and tried running Visual Studio with Administration Privileges. If you need any log files or details from me, I will provide those you request (not sure which log files will help with this)

I am using Visual Studio 2017 Enterprise.

My project file contents:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <ProjectGuid>{58739EF0-7612-43F3-BF3D-E752CCCCFF44}</ProjectGuid>
    <OutputType>Library</OutputType>
    <RootNamespace>IsoMetrix_Mobile.Droid</RootNamespace>
    <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
    <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
    <AndroidResgenClass>Resource</AndroidResgenClass>
    <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
    <AndroidApplication>True</AndroidApplication>
    <AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
    <TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
    <AssemblyName>IsoMetrix_Mobile.Droid</AssemblyName>
    <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
    <SccProjectName>SAK</SccProjectName>
    <SccLocalPath>SAK</SccLocalPath>
    <SccAuxPath>SAK</SccAuxPath>
    <SccProvider>SAK</SccProvider>
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug</OutputPath>
    <DefineConstants>DEBUG;</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidLinkMode>None</AndroidLinkMode>
    <ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>full</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
    <ConsolePause>false</ConsolePause>
    <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
    <BundleAssemblies>false</BundleAssemblies>
    <EnableProguard>false</EnableProguard>
    <AndroidSupportedAbis>armeabi;armeabi-v7a</AndroidSupportedAbis>
</PropertyGroup>
<ItemGroup>
    <Reference Include="FormsViewGroup, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\Xamarin.Forms.2.3.1.114\lib\MonoAndroid10\FormsViewGroup.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="Java.Interop" />
    <Reference Include="SQLite-net, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\sqlite-net-pcl.1.1.2\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLite-net.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="SQLitePCL.batteries, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\SQLitePCL.bundle_green.0.9.2\lib\MonoAndroid\SQLitePCL.batteries.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="SQLitePCL.raw, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\SQLitePCL.raw.0.9.2\lib\MonoAndroid\SQLitePCL.raw.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="SQLitePCLPlugin_esqlite3, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\SQLitePCL.plugin.sqlite3.android.0.9.2\lib\MonoAndroid\SQLitePCLPlugin_esqlite3.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Core" />
    <Reference Include="Mono.Android" />
    <Reference Include="Xamarin.Android.Support.Animated.Vector.Drawable, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.Animated.Vector.Drawable.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="Xamarin.Android.Support.Design, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\Xamarin.Android.Support.Design.23.3.0\lib\MonoAndroid43\Xamarin.Android.Support.Design.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\Xamarin.Android.Support.v4.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\Xamarin.Android.Support.v7.AppCompat.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.AppCompat.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="Xamarin.Android.Support.v7.CardView, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\Xamarin.Android.Support.v7.CardView.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.CardView.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="Xamarin.Android.Support.v7.MediaRouter, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\Xamarin.Android.Support.v7.MediaRouter.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.MediaRouter.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="Xamarin.Android.Support.v7.RecyclerView, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\Xamarin.Android.Support.v7.RecyclerView.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.RecyclerView.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="Xamarin.Android.Support.Vector.Drawable, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.Vector.Drawable.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\Xamarin.Forms.2.3.1.114\lib\MonoAndroid10\Xamarin.Forms.Core.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="Xamarin.Forms.Platform, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\Xamarin.Forms.2.3.1.114\lib\MonoAndroid10\Xamarin.Forms.Platform.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\Xamarin.Forms.2.3.1.114\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="Xamarin.Forms.Xaml, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    <HintPath>..\..\packages\Xamarin.Forms.2.3.1.114\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll</HintPath>
    <Private>True</Private>
    </Reference>
</ItemGroup>
<ItemGroup>
    <ProjectReference Include="..\IsoMetrix_Mobile\IsoMetrix_Mobile.csproj">
    <Name>IsoMetrix_Mobile</Name>
    </ProjectReference>
</ItemGroup>
<ItemGroup>
    <Compile Include="Activities\IBasePresenter.cs" />
    <Compile Include="Activities\IBaseView.cs" />
    <Compile Include="Activities\Login\LoginContract.cs" />
    <Compile Include="Activities\Login\LoginFragment.cs" />
    <Compile Include="Activities\Login\LoginPresenter.cs" />
    <Compile Include="Activities\ModuleInstanceSelection\ModuleInstanceListAdapter.cs" />
    <Compile Include="Activities\ModuleInstanceSelection\ExpandableSolutionProcessListAdapter.cs" />
    <Compile Include="Activities\Login\LoginActivity.cs" />
    <Compile Include="Activities\ModuleInstanceSelection\ModuleInstanceSelectionActivity.cs" />
    <Compile Include="Activities\ModuleInstanceSelection\ProcessSelectionActivity.cs" />
    <Compile Include="Activities\ModuleInstance\Control\Checkbox.cs" />
    <Compile Include="Activities\ModuleInstance\Control\Datepicker\Datepicker.cs" />
    <Compile Include="Activities\ModuleInstance\Control\Dropdown\Dropdown.cs" />
    <Compile Include="Activities\ModuleInstance\Control\Dropdown\DropdownAdapter.cs" />
    <Compile Include="Activities\ModuleInstance\Control\Dropdown\DropdownClickListener.cs" />
    <Compile Include="Activities\ModuleInstance\Control\Label.cs" />
    <Compile Include="Activities\ModuleInstance\Control\NumberBox.cs" />
    <Compile Include="Activities\ModuleInstance\Control\Unsupported.cs" />
    <Compile Include="Activities\ModuleInstance\Control\Textbox.cs" />
    <Compile Include="Activities\ModuleInstance\Control\Timepicker\Timepicker.cs" />
    <Compile Include="Activities\ModuleInstance\RecordListActivity.cs" />
    <Compile Include="Activities\ModuleInstance\Control\Timepicker\TimePickerFragment.cs" />
    <Compile Include="Activities\ModuleInstance\Control\Datepicker\DatePickerFragment.cs" />
    <Compile Include="Activities\ModuleInstance\RecordViewActivity.cs" />
    <Compile Include="Activities\ModuleInstance\Control\ControlFactory.cs" />
    <Compile Include="Activities\Utils.cs" />
    <Compile Include="Core\DependencyServices\AuthenticationAndroid.cs" />
    <Compile Include="Core\Helper.cs" />
    <Compile Include="Resources\Resource.designer.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="Core\DependencyServices\SQLiteAndroid.cs" />
</ItemGroup>
<ItemGroup>
    <None Include="app.config" />
    <None Include="packages.config" />
    <None Include="Resources\AboutResources.txt" />
    <None Include="Properties\AndroidManifest.xml" />
    <None Include="Assets\AboutAssets.txt" />
    <AndroidResource Include="Resources\layout\ProcessSelection.axml">
    <SubType>Designer</SubType>
    </AndroidResource>
    <AndroidResource Include="Resources\layout\ProcessListItem.axml">
    <SubType>Designer</SubType>
    </AndroidResource>
    <AndroidResource Include="Resources\layout\ModuleInstanceListItem.axml">
    <SubType>Designer</SubType>
    </AndroidResource>
    <AndroidResource Include="Resources\layout\ModuleInstanceSelection.axml">
    <SubType>Designer</SubType>
    </AndroidResource>
    <AndroidResource Include="Resources\layout\ModuleInstanceRecordViewer.axml">
    <SubType>Designer</SubType>
    </AndroidResource>
    <AndroidResource Include="Resources\layout\TextViewItem.axml">
    <SubType>Designer</SubType>
    </AndroidResource>
    <AndroidResource Include="Resources\layout\ModuleInstanceRecordList.axml">
    <SubType>Designer</SubType>
    </AndroidResource>
    <AndroidResource Include="Resources\layout\Login_Act.axml" />
    <AndroidResource Include="Resources\layout\Login_Frag.axml" />
</ItemGroup>
<ItemGroup>
    <AndroidResource Include="Resources\values\Strings.xml" />
    <AndroidResource Include="Resources\drawable-hdpi\Icon.png" />
    <AndroidResource Include="Resources\drawable-mdpi\Icon.png" />
    <AndroidResource Include="Resources\drawable-xhdpi\Icon.png" />
    <AndroidResource Include="Resources\drawable-xxhdpi\Icon.png" />
    <AndroidResource Include="Resources\drawable-xxxhdpi\Icon.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
<Import Project="..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
    <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets'))" />
    <Error Condition="!Exists('..\..\packages\Xamarin.Forms.2.3.1.114\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Xamarin.Forms.2.3.1.114\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets'))" />
</Target>
<Import Project="..\..\packages\Xamarin.Forms.2.3.1.114\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.1.114\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
</Project>


Solution 1:[1]

For anyone that happens onto this the way I managed to get it working:

  1. Close VS
  2. Go to your project folder
  3. Open the bin folder and delete everything
  4. Re-open VS and build your solution and then try the archive option

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gulfaran Younis