5

So, I am getting this error on building Android Release. On debug things are fine. It wont even clean the solution. Things were fine and now after updating to latest Xamarin. This is what my Droid project top few lines look like

<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="..\packages\Xamarin.Build.Download.0.6.0\build\Xamarin.Build.Download.props" Condition="Exists('..\packages\Xamarin.Build.Download.0.6.0\build\Xamarin.Build.Download.props')" />
  <PropertyGroup>```
zyzzyxx
  • 323
  • 2
  • 9

5 Answers5

14

For me, simply restarting the visual studio fixed this issue.

  • 1
    I got this issue when upgrading xamarin.build.download from 0.4.11 to 0.10.0. Also some other packages, but nothing worked until made sure all dependent projects were on the same version of xamarin.build.download (I missed one) and I restarted VS a few times in the process – stepheaw Apr 15 '20 at 14:06
  • 1
    I restarted VS, cleaned the solution then built it. Errors were gone. – Akshay Gaur Apr 23 '20 at 20:47
4

A simple way is set android:usesCleartextTraffic="true" on you AndroidManifest.xml

android:usesCleartextTraffic="true"

Your AndroidManifest.xml look like

<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.dww.drmanar">
   <application
       android:icon="@mipmap/ic_launcher"
       android:label="@string/app_name"
       android:usesCleartextTraffic="true"
       android:theme="@style/AppTheme"
       tools:targetApi="m">
       <activity
            android:name=".activity.SplashActivity"
            android:theme="@style/FullscreenTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
       </activity>
    </application>
</manifest>

I hope this will help you.

Bram Jongebloet
  • 306
  • 1
  • 2
  • 10
  • So that problem seems to go away, but on Appcenter build, another problem is appearing, which does not happen on local machine. :```Unhandled exception: System.IO.IOException: Sharing violation on path /Users/runner/runners/2.161.1/work/1/s/src/obj/Release/android/src/com/google/android/gms/maps/R.java ``` – zyzzyxx Dec 04 '19 at 16:50
  • is your appcenters android sdk up to date? – Bram Jongebloet Dec 04 '19 at 16:57
  • Oh yeah, targeting everything latest. It appears that using MonoDroid 6.4 seems to cause this issue and not 6.0. – zyzzyxx Dec 04 '19 at 17:03
  • ah hummm sounds interesting. But is it fixed? – Bram Jongebloet Dec 04 '19 at 17:09
  • So, android:usesCleartextTraffic="true" seems to fix the issue, but now the build process is crapping at this section: `````` – zyzzyxx Dec 04 '19 at 18:19
  • Updating the platform and tools in Android SDK manager resolved this issue for me. – Rickey Dec 05 '19 at 18:47
  • @zyzzyxx - did you delete `bin` and `obj` folders? To make sure project is truly cleaned. – ToolmakerSteve Dec 05 '19 at 20:29
  • @ToolmakerSteve yes, I did. Also, I have noticed that, with newer version of Xamarin.build packages, if the nuget package versions are different across the assembly, I'm getting these errors. So, making them uniform seems to solve the problem. – zyzzyxx Jan 22 '20 at 12:32
4

android:usesCleartextTraffic="true" did not fix it for me.

I left that attribute in, because it might be enough in the future.

What fixed it was downgrading Xamarin.Build.Download nuget from 0.7.1 to 0.4.12-preview3. 0.4.11 also worked - that was what I was using prior to today, when I updated all nugets.

I also tried 0.7.0 and 0.5.0-rc1. Both had same problem as 0.7.1.


All my Android SDKs and Tools are up-to-date.
Targeting Android 9.0 Pie (API 28), minimum (25), launching to an emulator running Oreo 8.1 (27).

(iOS builds and run successfully with Xamarin.Build.Download 0.7.1; the problem only happened on Android.)

ToolmakerSteve
  • 18,547
  • 14
  • 94
  • 196
  • 3
    It actually happened for me on iOS as well. 0.4.1 worked fined, but later versions were giving this error. – RadioLog Dec 12 '19 at 10:36
0

I have Xamarin.Build.Download version 0.8.0 and apparently for me the issue was that the shared code project didn't have a reference to the package, it happens in both, android and iOS, installing the package in the three projects apparently solves the issue.

0

In my Case this error was hiding another error behind. Using VS2017 V15.9.12, and i was juggling between 2 VS windows with 2 open Xamarin Android projects that had some library projects in common. Restarting the PC fixed the issue.

Matteo
  • 89
  • 2
  • 13