简体   繁体   English

Visual Studio 2017 - Xamarin - 文件“obj \\ Debug \\ android \\ bin \\ packaged_resources”不存在

[英]Visual Studio 2017 - Xamarin - The file “obj\Debug\android\bin\packaged_resources” does not exist

I'm fighting with that issue for 2 days already and can't find any solution. 我已经对这个问题进行了2天的斗争,但找不到任何解决方案。

I have an Xamarin Android app in Visual Studio 2017 consisting of three projects: 我在Visual Studio 2017中有一个Xamarin Android应用程序,包含三个项目:

  1. Xamarin.Android project (main one) Xamarin.Android项目(主要)
  2. Android-specific unit tests run on the device - project of type NUnit 3 Test Project (Android) created using NUnit Templates for Visual Studio 特定于Android的单元测试在设备上运行 - 使用NUnit模板为Visual Studio创建的NUnit 3 Test Project (Android)类型的NUnit 3 Test Project (Android)
  3. Platform-independent unit tests project (project of type Unit Test Project (.NET Framework) ) 独立于平台的单元测试项目( Unit Test Project (.NET Framework)类型的Unit Test Project (.NET Framework)

Everything worked just fine until now. 一切都运作良好,直到现在。 When I selected my main project as the Startup one, my app was deployed to the device/emulator. 当我选择我的主项目作为启动项目时,我的应用程序已部署到设备/模拟器。 When I selected my Android-specific unit tests project, the test project was deployed and unit tests executed by nUnit Xamarin Runners on the device/emulator. 当我选择特定于Android的单元测试项目时,部署测试项目并在设备/模拟器上由nUnit Xamarin Runners执行单元测试。

However few days ago I updated my Visual Studio 2017 with the newest available update and now, when trying to build this android-specific unit tests project I get the following error : 但是几天前我用最新的可用更新更新了我的Visual Studio 2017,现在,当我尝试构建这个特定于android的单元测试项目时, 我收到以下错误

The file "obj\\Debug\\android\\bin\\packaged_resources" does not exist.

I've searched everywhere, including this and this SO topics. 我到处搜索,包括这个这个 SO主题。 I also totally reinstalled Visual Studio 2017 and Xamarin with Android SDK included. 我还完全重新安装了包含Android SDK的Visual Studio 2017和Xamarin。 Nothing helped. 什么都没有帮助。 From what I read I suspect there is something wrong with the versions of Android SDK Build-tools I have installed. 根据我的阅读,我怀疑我安装的Android SDK Build-tools版本有问题。 Here's what I have currently installed in SDK Manager: 这是我目前在SDK Manager中安装的内容: 在此输入图像描述

As the other SO threads suggested, I tried uninstalling the newest Android SDK Build-tools (25.0.2) and installed version 23.0.3 (all my projects target Android 6.0), but it also doesn't help, I still have the same error. 正如其他SO线程建议的那样,我尝试卸载最新的Android SDK Build-tools(25.0.2)并安装了版本23.0.3(我的所有项目都针对Android 6.0),但它也没有帮助,我仍然有相同的错误。

Maybe it's worth adding that this issue may have started to happen when I tried to implement RecyclerView in my app reading this tutorial, where they suggested to install Android 7.1.1 (API 25) in SDK Manager. 也许值得补充的是,当我尝试在我的应用程序中阅读教程时实现RecyclerView时,这个问题可能已经开始发生,他们建议在SDK Manager中安装Android 7.1.1(API 25) However I undoed my all changes after that and even reintalled VS2017 + Xamarin. 然而,在此之后我撤消了我的所有更改,甚至重新命名了VS2017 + Xamarin。

Do you have any other idea why this can be ? 你知道为什么会这样吗? I'd really appreciate any help. 我真的很感激任何帮助。 Thanks! 谢谢!

EDIT 2017-04-09: 编辑2017-04-09:

Egh, I removed VS2017, installed VS2015 with brand new Android SDK and still the same issue :( 呃,我删除了VS2017,用全新的Android SDK安装VS2015仍然是同样的问题:(

I've finally found what was the issue. 我终于找到了问题所在。 It wasn't related to any component from SDK Manager or VS version. 它与SDK Manager或VS版本中的任何组件无关。

Following localization tutorial from developer.xamarin.com , I played a bit with Strings.xml in my Android project. developer.xamarin.com的本地化教程之后,我在Android项目中使用了Strings.xml I wanted to have my Activities Label taken from resources as well, so in the ActivityAttribute I defined: 我想从资源中获取我的活动标签,因此在我定义的ActivityAttribute

[Activity(Label = "@string/peopleListTitle")]

and added this value in Strings.xml file: 并在Strings.xml文件中添加了此值:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-------Other resources values ----->
    <string name="peopleListTitle">People List</string>
</resources>

In that case my build is failing with above-mentioned error: 在这种情况下,我的构建失败并出现上述错误:

The file "obj\\Debug\\android\\bin\\packaged_resources" does not exist

When I change ActivityAttribute to use a string directly: 当我更改ActivityAttribute以直接使用字符串时:

[Activity(Label = "People List")]

the build is passing without any issues. 构建过程没有任何问题。

I managed to find a solution, but actually I don't know why it's not building when I try to use Label text defined in Strings.xml . 我设法找到了一个解决方案,但实际上我不知道为什么当我尝试使用Strings.xml定义的Label文本时它没有构建。

BTW, I managed to find what's the problem by setting build output verbosity to Diagnostic in Tools -> Options -> Projects and Solutions -> Build and Run which gives a detailed info why the build failed in the Output window. 顺便说一句,我设法通过在工具 - >选项 - >项目和解决方案 - >构建和运行中为Diagnostic设置构建输出详细程度来找到问题是什么它在“输出”窗口中提供详细信息,说明构建失败的原因。

I had the same problem. 我有同样的问题。 After removing the dash "-" sign from the image file name, the problem is solved. 从图像文件名中删除短划线“ - ”符号后,问题就解决了。 Bad error message! 错误信息错误! It should not be: 它不应该是:

The file "obj\\Debug\\android\\bin\\packaged_resources" does not exist. 文件“obj \\ Debug \\ android \\ bin \\ packaged_resources”不存在。

Writing an error message like this causing the Developer to think about something else while the problem is the illegal file name. 编写这样的错误消息导致Developer在问题是非法文件名时考虑其他事情。

I had the same issue when I added a new image as a resource. 当我添加新图像作为资源时,我遇到了同样的问题。 There was a ' - ' in the file name ( Invalid resource name character ). 文件名中有一个“ - ”( 无效的资源名称字符 )。 I renamed & removed that character and all good. 我重命名并删除了那个角色并且一切都很好。 Resource name can only consist of 0-9,az or AZ or combination of any. 资源名称只能包含0-9,az或AZ或任意组合。

I had the same problem, and i removed all image file name have "-" character. 我有同样的问题,我删除所有图像文件名称都有“ - ”字符。 My problem solved 我的问题解决了

Another reason for this error is that you may have a float number as your version number. 此错误的另一个原因是您可能有一个浮点数作为您的版本号。 In my case I changed it to a integer and everything worked fine. 在我的情况下,我将其更改为整数,一切正常。 (I found the error by switching the build output to Detailed ) (我通过将构建输出切换为Detailed找到了错误)

Simply it worked. 只是它有效。

  1. In one case I copied and pasted previous working "packaged_resources" in the bin folder.[the problem was it did not reflect the UI changes] 在一个案例中,我复制并粘贴了以前在bin文件夹中工作的“packaged_resources”。[问题是它没有反映UI的变化]
  2. Other I opened the visual studio as administrator. 其他我作为管理员打开了视觉工作室。
  3. Next changed the "Minimum target to Android" to lower apis in the project properties windows. 接下来将“最小目标转换为Android”更改为项目属性窗口中的api。
  4. I suggest not touching the code behind of the design. 我建议不要触及设计背后的代码。 If you get this error simply pull some button from the tool bar into the design and visual studio will come to its consciousness that there is change in UI. 如果你得到这个错误,只需从工具栏中拉出一些按钮进入设计,视觉工作室就会意识到UI的变化。 Next click on save all so that it make necessary change in the designer file. 然后单击“全部保存”,以便在设计器文件中进行必要的更改。

Mine was a different solution (and only half a day lost): I was having trouble getting Hockey app to match crashes against the correct version of the app and realised it uses VersionCode not VersionName so I change my code to "0.0.34" the same as the name. 我是一个不同的解决方案(只有半天丢失):我无法让Hockey应用程序与正确版本的应用程序匹配崩溃,并意识到它使用VersionCode而不是VersionName所以我将我的代码更改为“0.0.34”与名称相同。 For some still unknown reason the app built and deployed to devices for about 3 days before I started getting this error The file "obj\\Debug\\android\\bin\\packaged_resources" does not exist. 由于一些仍然未知的原因,应用程序在我开始收到此错误之前构建并部署到设备大约3天The file "obj\\Debug\\android\\bin\\packaged_resources" does not exist. Setting it back to a numeric value fixed the problem. 将其重新设置为数值可解决问题。

I found the problem by looking back through my GIT logs and rebuild each push until I found the one that caused the problem. 我通过回顾我的GIT日志并重建每次推送找到了问题,直到找到导致问题的那个。

It just because the Version Code,I set Code by '1.0', The file "obj\\Debug\\android\\bin\\packaged_resources" does not exist. 它只是因为版本代码,我将代码设置为'1.0', 文件“obj \\ Debug \\ android \\ bin \\ packaged_resources”不存在。 ;And I set it by '1',everything is ok. ;我把它设置为'1',一切都好。

Had the same error, the way I got over it was crank up the Android SDK manager and install all updates and remove any obsolete packages. 有同样的错误,我克服它的方式是启动Android SDK管理器并安装所有更新并删除任何过时的包。 This happened to me because I was targeting something newer which was not installed. 这发生在我身上,因为我的目标是更新的未安装的东西。

在此输入图像描述

Check to see if there are any unused entries in resources.designer.cs if there are any manually remove those entries. 如果有任何手动删除这些条目,请检查resources.designer.cs中是否有未使用的条目。 This will fix the issue. 这将解决问题。

After following several online suggestions - updating SDK, updating Xamarin etc - none of which worked for me. 以下几个在线建议 - 更新SDK,更新Xamarin等 - 没有一个对我有用。

Finally found that I had an activity for a Android provider to Alarm clock in my AndroidManifest file as below 终于发现我在我的AndroidManifest文件中有一个Android提供商的闹钟活动,如下所示

 <activity 
     android:name="com.njcommuter.droid/android.provider.AlarmClock" 
     android:label="AlarmClock"
     .....
     />

Removing this line - and rebuilding worked fine without any errors and was able to deploy solution successfully. 删除此行 - 并且重建工作正常,没有任何错误,并且能够成功部署解决方案。

Note : testing this by putting the line back, and I get same error again on rebuilding. 注意:通过将线放回来测试它,并且在重建时我再次得到相同的错误。 It can be linked to using any android provider which creates the package for it, not necessarily AlarmClock only. 它可以链接到使用任何为其创建包的android提供程序,而不仅仅是AlarmClock。

This error is, somewhat of, a wrapper for what can be multiple reasons that that the file was not created. 这个错误在某种程度上是一个包装器,可能是因为没有创建该文件的多种原因。 The key is to look in the detailed output and look for the underlying error causing the file creation failure. 关键是查看详细输出并查找导致文件创建失败的基础错误。

In my case, I had corrupted icon.png files (generated right from from the VS xamarin nunit template, no less!). 在我的情况下,我损坏了icon.png文件(从VS xamarin nunit模板生成,不会少!)。 Once I put in valid png files, everything was built fine. 一旦我输入有效的png文件,一切都很好。

Another reason for this error, if that the android NDK (not android SDK) isn't right, change de version can resolve the problem: go to Tools/Options/Xamarin/android Configurator and change de folder, in my case I've three, the last one can't compile, but the second folder with version xx.r11c do it. 这个错误的另一个原因,如果说android NDK(不是android SDK)不对,更改de版本可以解决问题:转到Tools / Options / Xamarin / android Configurator并更改de文件夹,在我的情况下我是三,最后一个无法编译,但是版本为xx.r11c的第二个文件夹就可以了。

在此输入图像描述

在此输入图像描述

For me it was Target Android Version.I had it set to 对我而言,它是Target Android Version。我已将它设置为

编译版本

but changing it to Compiling version(for me it was the latest platform) resolved the issue. 但将其更改为编译版本(对我来说这是最新的平台)解决了这个问题。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM