当前位置: 首页 > 知识库问答 >
问题:

在Xamarin Android项目的Android资产中添加文件夹会引发构建错误

夏奕
2023-03-14

无法在Xamarin Android项目的资产中添加目录和子目录。

IDE:Mac版本的Visual Studio社区:7.3。2(构建12)

操作系统:MacOS High Sierra版本:10.13。2.

错误:/Library/Frameworks/Mono。framework/External/xbuild/Xamarin/Android/Xamarin。Android常见的目标(2,2):错误MSB3025:源文件“Assets/Dir/”实际上是一个目录。“复制”任务不支持复制目录。(MSB3025)(资产检查)

/库/框架/单声道。framework/External/xbuild/Xamarin/Android/Xamarin。Android常见的目标(2,2):错误MSB3025:源文件“Ashtml" target="_blank">sets/Dir/SubDir/”实际上是一个目录。“复制”任务不支持复制目录。(MSB3025)(资产检查)

Note能够在Windows 10系统中使用Visual Studio社区成功构建。

.csproj文件

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="..\packages\Xamarin.Build.Download.0.4.3\build\Xamarin.Build.Download.props" Condition="Exists('..\packages\Xamarin.Build.Download.0.4.3\build\Xamarin.Build.Download.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{A6BF443D-8B89-4044-B951-E346FA8E68D3}</ProjectGuid>
    <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <RootNamespace>ScormReader.Droid</RootNamespace>
    <AssemblyName>ScormReader.Droid</AssemblyName>
    <TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
    <AndroidApplication>True</AndroidApplication>
    <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
    <AndroidResgenClass>Resource</AndroidResgenClass>
    <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
    <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
    <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
    <AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
  </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>
    <AndroidSupportedAbis>arm64-v8a;armeabi;armeabi-v7a;x86</AndroidSupportedAbis>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidManagedSymbols>true</AndroidManagedSymbols>
    <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Core" />
    <Reference Include="Mono.Android" />
    <Reference Include="Xamarin.Android.Support.Annotations">
      <HintPath>..\packages\Xamarin.Android.Support.Annotations.25.3.1\lib\MonoAndroid70\Xamarin.Android.Support.Annotations.dll</HintPath>
    </Reference>
    <Reference Include="Xamarin.Android.Support.Compat">
      <HintPath>..\packages\Xamarin.Android.Support.Compat.25.3.1\lib\MonoAndroid70\Xamarin.Android.Support.Compat.dll</HintPath>
    </Reference>
    <Reference Include="Xamarin.Android.Support.Core.UI">
      <HintPath>..\packages\Xamarin.Android.Support.Core.UI.25.3.1\lib\MonoAndroid70\Xamarin.Android.Support.Core.UI.dll</HintPath>
    </Reference>
    <Reference Include="Xamarin.Android.Support.Core.Utils">
      <HintPath>..\packages\Xamarin.Android.Support.Core.Utils.25.3.1\lib\MonoAndroid70\Xamarin.Android.Support.Core.Utils.dll</HintPath>
    </Reference>
    <Reference Include="Xamarin.Android.Support.Media.Compat">
      <HintPath>..\packages\Xamarin.Android.Support.Media.Compat.25.3.1\lib\MonoAndroid70\Xamarin.Android.Support.Media.Compat.dll</HintPath>
    </Reference>
    <Reference Include="Xamarin.Android.Support.Fragment">
      <HintPath>..\packages\Xamarin.Android.Support.Fragment.25.3.1\lib\MonoAndroid70\Xamarin.Android.Support.Fragment.dll</HintPath>
    </Reference>
    <Reference Include="Xamarin.Android.Support.Vector.Drawable">
      <HintPath>..\packages\Xamarin.Android.Support.Vector.Drawable.25.3.1\lib\MonoAndroid70\Xamarin.Android.Support.Vector.Drawable.dll</HintPath>
    </Reference>
    <Reference Include="Xamarin.Android.Support.Animated.Vector.Drawable">
      <HintPath>..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.25.3.1\lib\MonoAndroid70\Xamarin.Android.Support.Animated.Vector.Drawable.dll</HintPath>
    </Reference>
    <Reference Include="Xamarin.Android.Support.v7.AppCompat">
      <HintPath>..\packages\Xamarin.Android.Support.v7.AppCompat.25.3.1\lib\MonoAndroid70\Xamarin.Android.Support.v7.AppCompat.dll</HintPath>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="MainActivity.cs" />
    <Compile Include="Resources\Resource.designer.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Resources\AboutResources.txt" />
    <None Include="Properties\AndroidManifest.xml" />
    <None Include="Assets\AboutAssets.txt" />
    <None Include="packages.config" />
  </ItemGroup>
  <ItemGroup>
    <AndroidResource Include="Resources\layout\Main.axml" />
    <AndroidResource Include="Resources\values\Strings.xml" />
    <AndroidResource Include="Resources\mipmap-hdpi\Icon.png" />
    <AndroidResource Include="Resources\mipmap-mdpi\Icon.png" />
    <AndroidResource Include="Resources\mipmap-xhdpi\Icon.png" />
    <AndroidResource Include="Resources\mipmap-xxhdpi\Icon.png" />
    <AndroidResource Include="Resources\mipmap-xxxhdpi\Icon.png" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Resources\drawable\" />
  </ItemGroup>
  <ItemGroup>
  </ItemGroup>
  <ItemGroup>

  </ItemGroup>
  <ItemGroup>
    <AndroidAsset Include="Assets\Parent\" />
    <AndroidAsset Include="Assets\Parent\Child\" />
  </ItemGroup>
  <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
  <Import Project="..\packages\Xamarin.Build.Download.0.4.3\build\Xamarin.Build.Download.targets" Condition="Exists('..\packages\Xamarin.Build.Download.0.4.3\build\Xamarin.Build.Download.targets')" />
  <Import Project="..\packages\Xamarin.Android.Support.Annotations.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Annotations.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Annotations.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Annotations.targets')" />
  <Import Project="..\packages\Xamarin.Android.Support.Compat.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Compat.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Compat.targets')" />
  <Import Project="..\packages\Xamarin.Android.Support.Core.UI.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Core.UI.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.UI.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Core.UI.targets')" />
  <Import Project="..\packages\Xamarin.Android.Support.Core.Utils.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Core.Utils.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Core.Utils.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Core.Utils.targets')" />
  <Import Project="..\packages\Xamarin.Android.Support.Media.Compat.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Media.Compat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Media.Compat.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Media.Compat.targets')" />
  <Import Project="..\packages\Xamarin.Android.Support.Fragment.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Fragment.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Fragment.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Fragment.targets')" />
  <Import Project="..\packages\Xamarin.Android.Support.Vector.Drawable.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Vector.Drawable.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Vector.Drawable.targets')" />
  <Import Project="..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Animated.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" />
  <Import Project="..\packages\Xamarin.Android.Support.v7.AppCompat.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.v7.AppCompat.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.AppCompat.25.3.1\build\MonoAndroid70\Xamarin.Android.Support.v7.AppCompat.targets')" />
</Project>

共有1个答案

陈宜修
2023-03-14

“复制”任务不支持复制目录。

我在我的MacOS上复制了你的问题,并找到了修复方法。添加子目录时,csproj文件中添加了导致此错误的项。编辑csproj文件并删除引用子目录的行将解决此问题。

我的。csproj文件:

<ItemGroup>   
    <AndroidAsset Include="Assets\New Folder\hi.txt">
        <Generator>RazorTemplatePreprocessor</Generator>
        <LastGenOutput>hi.cs</LastGenOutput>
    </AndroidAsset>    
    <AndroidAsset Include="Assets\New Folder1\" /> 
</ItemGroup>

删除引用子目录的第一个AndroidAsset:

 类似资料:
  • Android Studio又一次改变了项目架构……现在是了

  • 我想有一个地方来存储我的图像文件,以便在我的Java项目中使用(一个非常简单的类,它只是将图像加载到面板上)。我找遍了所有的地方,都找不到如何做到这一点。我该怎么做? 我已经尝试向项目添加一个新文件夹,向项目添加一个新类文件夹,向项目添加一个新源文件夹。无论我做什么,我总是得到一个。文件夹总是说它们在构建路径上,所以我不确定该怎么做。 编辑:对我起作用的东西是将文件夹添加为类文件夹,然后将其删除,

  • 我试图使用一个自定义字体,我读到我想把字体放在资产/字体。我使用的是Android Studio,似乎我没有资产文件夹。所以我创造了一个。但当我将assets文件夹放在src/main中时,我的应用程序会崩溃。我使用这个代码来加载我的字体。 我做错了什么?

  • 我的构建环境突然出现问题,我不知道为什么。我可以使用gradlew desktop运行我的项目:run然而,当我尝试使用右键单击run as desktop application(当然是在桌面项目上)从Eclipse运行项目时,它突然找不到我的包。阿特拉斯档案。毫无疑问,该文件存在。我已经多次刷新了我的eclipse项目,并且该项目使用gradle命令行运行良好。昨天天气很好。我能想到的唯一一件

  • 我正试图将本地url加载到webview,但我不想使用assets文件夹,因为它是只读的,而且我需要从Web服务更新文件。 Web服务调用运行良好,并将html文件保存到设备上的文件夹中,使用 这将在应用程序的存储空间中创建一个文件夹'app_live',并用HTML填充该文件夹。 现在,当我把它加载到我的Webview中时,应用程序显示“网站不可用”,尽管livefolder.isdir()返回

  • 我在尝试Xamarin。表格。我创建了一个名为"App2"的解决方案。Visual Studio自动创建以下项目: App2(便携式) 当我尝试编译Android项目(App2.Droid)时,我得到以下错误: 下载失败。请下载https://dl-ssl.google.com/android/repository/android_m2repository_r22.zip并将其放入C:\Users