Android App Compile Not Generating Package Resourc

2019-01-23 22:21发布

问题:

When attempting to compile my Xamarin.Android app I get the compile error:

Error 3 The file "obj\Debug\android\bin\packaged_resources" does not exist. MyApp.UI.Droid

This error occurred after I made some changes (added some new classes - cannot remember what it was). But I didn't change any project settings, nor go delete actual files in the obj folder.

What is the cause of this error and how can I fix this?

Some information that may be useful:

  • The project is a Cross-Platform PCL project - Core, Android, and iOS Projects
  • The project uses MVVM Cross

回答1:

I encountered the same issue. Ensure that your resource files do not include any special characters

The actual error you may be encountering is:

Invalid file name: must contain only [a-z0-9_.]

Change your build output verbosity in visual studio to see better log output.



回答2:

I´ve had the same issue.

Then i´ve reviewed my resource file names.

Solution:

One file was using "-" in it´s name. (invalid character)

Then i replaced for "_" (underline).

PS:

=> file name: must contain only [a-z0-9_.]



回答3:

You will need to grub down by switching on Verbose output. What is stopping the generation of packaged_resources?

In VS2013 choose Tools --> Options --> Build and execute, choose verbosity Diagnostic.

In VS2015, the same option is in Tools --> Options --> Projects and Solutions --> Build and Run.

In my case, it was a hyphen character in the name of the action property of an Intent filter, but choosing verbose output will point you to the line that has the problem.



回答4:

Follow the steps below to identify the problem:

1 - In Visual Studio: Tools> Options> Projects and solutions> Build and Run.

1.1 - In the dropdown: MSBuild project build output verbosity:> Diagnostic.

1.2 - Close the dialog box.

2 - View> Output (Ctrl + W, O).

3 - Run the build or rebuild.

In the output find the line:

C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1665,3): error MSB6006: "aapt.exe" exited with code 1.

What is just above this error is what caused the error.



回答5:

i also found that removing the packages in Tools/Preview Channel and Android N AND ALSO Android SDK Build Tools rev 24, done a build and worked.. This is a complete new portable project/android/ios



回答6:

Another possibility is you have an issue with the installed Android SDK build tools. For me, when I removed the package for Revision 24 it worked.



回答7:

From Xamarin Forums:

First of all go and deinstall preview tools in your android sdk manager. If you havent installed it but still get the same error then go and deinstall Android SDK Build Tools Rev. 24.

The Problem we have here is that, if you have Appcombat, RecyclerView or something like that in your project, the library rev of these librarys are below rev 24. They are still on 23.2.1 but not on rev 24. So if you installed Build-Tools Rev 24 and want to build your project the build cant find the rev24 resource package of your librarys.

You can check it on your own Go in the SDK Manager and check "Obsolete" Then go to the folder Extras and there you can see "Android Support Library (Obsolete) Rev 23.2.1. And then check if there is Android Support Library Rev 24 in your Extras Folder. No? And thats the Problem here. We got the Update for Build Tools to early and have to wait for Library Update. Then we all can use Build Tools 24!

So only update to BuildTools Rev 24 when we got an update for support librarys and have the rev24 librarys.



回答8:

Basically the problem is with special character of Resource FILE NAME. In my case, I am keep getting error "The file "obj\Debug\android\bin\packaged_resources" does not exist.":

..\Resources\drawable\company-app-log.png having -(hyphen) between alpha characters is the root-cause of the issue.



回答9:

Using Xamarin Studio here -

Sometimes this is caused by AXML errors.

Which if you turn on detailed / diagnostic in preferences you can search the build output (or your packaging output) for the word ERROR.

For example, somebody checked in some AXML line(s) with -

android:Text="something"

and the uppercase T was causing this error -

Resources/layout/Somefile.axml(11): error APT0000: No resource identifier found for attribute 'Text' in package 'android'

Fixing the errors fixed the original message.



回答10:

Firstly, i suggest you change "show out put from" Build to Xamarin to see the real error and its details as seen in my case

At first

And then please make sure you installed your NDK properly. That was the issue with mine,

and please make sure the NDK directory is also set

hope this helps someone



回答11:

I just lost 7 hours of my day.. You know what I did?

Project.Droid -> Resources -> RightClick on the Resource.Designer.cs -> Delete

I did fu****n' works ! ><

EDIT

Omg it did comes back... Why does Windows has all time so much of bugs... seriously..



回答12:

Same annoying problem with me! But I found a solution: read carefully this article: https://gxconsultancy.wordpress.com/2016/04/04/to-use-xamarin-or-not-to-us-xamarin/

In short:

  • Make sure you have JDK 32bits version 8 at least - same for the JRE, included in the JDK installation kit from Oracle;

  • Set your project for using the Xamarin debugger (right-click your project, hit Properties / Android Options / Packaging / Debugger);

  • And now the most weird: delete the app/Resources/drawable folder; have a working Xamarin project and copy its "drawable" folders to the erratic project (usually there are several subfolders, like drawable-hdpi, drawable-mdpi and so fort).

  • Rebuild your Android project.



回答13:

I had the problem so I deleted build-tools 24.0.0 and I used build-tools 23.0.3 and the problem solved. Try it!



回答14:

make sure that your resources don't have any special character or start with number



回答15:

Encountered same issue in VS 2015 and Xamarin 7.2.0.7. In my case, the issue happened just suddenly, and turned out the issue caused by wrong element name in axml, traced using Tiago's answers above.

So I didn't find the line Tiago mentioned with aapt.exe, but I then I tried to search for keyword failed in output. Then I found one telling me about margin. In android, margin is set using android:layout_margin. I played with element and forgot and put android:margin instead, thus also why it happened so sudden after so many successful run. Fixed it and the build succeeded.



回答16:

In my case the error was caused because I set the version number in the manifest to 1.0. Apparently the version number must be an integer.



回答17:

Had the same problem. My error was in the manifest: I had Version Code (Version number) set at "1.0.0" and it wasn't allowed. It only takes integers so I had to revert to "1".

I mixed up Version Code and Version Name.



回答18:

For me this error was caused by having an invalid attribute value in a layout xml. I had

android:id="button"

changing it to

android:id="@+id/button"

fixed the error.



回答19:

Not sure if this is a late answer, but this specific error message occurs for one of the two reasons:

  1. (Most probably the case): In your layout file, you may have mentioned a resource (drawable/image) incorrectly. For example, the image was in the mipmap folder path but you have pointed it wrongly to the drawable folder path.

  2. Per many comments, there could be a hyphen or special character in one your resources' names or it starts with a number. However, please note, in this specific case, you will mostly see a aapt.exe has stopped or appt.exe has exited with error code 1 error. I am not sure if you will get obj\Debug\android\bin\packaged_resources not found error. My experience says that point 1 above is the case.



回答20:

Got this error in Visual Studio 2017 Xamarin android project on Windows. After lot of experiments with resource's files I found, that filename length and extension of image file in the drawable folder affect the result of compillation!

drawable/abcde.png - compilled ok
drawable/abcdef.png - error, "obj\Debug\android\bin\packaged_resources" does not exist

If rename image to file without .png extension, compilled without errors.

Spended a lot of time and was confused :-/



回答21:

I had the same problem. To solve I had to remove all nuget packages from droid project, and reinstalled xamarin.forms again (has to be same version used in other projects).



回答22:

had the same issue. This was because i had an .png file that had a "-" character in it's name. Just enusure any of your resources don't have the "-" hyphen character