Related
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
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.
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_.]
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.
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.
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
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.
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.
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.
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.
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
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..
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.
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!
make sure that your resources don't have any special character or start with number
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.
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.
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.
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.
Not sure if this is a late answer, but this specific error message occurs for one of the two reasons:
(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.
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.
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 :-/
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).
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
I tried setting different Gradle Vm Option from all the answers found on stackoverflow, but nothing seems to be working out
I'm on Android Studio 1.2.2
I'm getting this error when I try to run the app on either on the emulator or the device.
Only thing that is working for me is that I need to setup new project in different directories, but it only works for 3 instances and then bang, this error pops up. It is a tedious job to do above mentioned process for 10x times.
Edit_1 :
I even tried invalidating caches/restart, doesn't work out
Usually running gradle assembleDebug from hand or from Gradle menu (right side of screen -> app -> Tasks -> build -> assembleDebug) is giving much more info.
In my case it showed problems in resources files.
It has happened to me and the cause has been different every time.
The first was an error in an xml file. I figured it out by reverting to the latest stable commit. The error was a missing "/>" closing tag. I don't know why android studio didn't point it out. This has happened to several of my co workers
The second time the fix was adding a line
-Xmx256m
or
-Xmx512m
In:
File->Setting->Build, Deployment &Execution->Build Tools->Gradle->Gradle Vm Option
Hope it helps
This can be because you have specified any command line option in android studio settings. You can check this by going to
File > Settings > Build, Execution, Deployment > Compiler
and see "Command-line-options" and check if anything is give. (In your case -x). If so remove it and click Apply and Ok. It worked in my case...
Downgraded to version 1.0.1 to make everything work flawlessly. I'm using same project files, it works fine on this version n number of times and same project files are giving above empty error on studio version 1.2.2
If you are deleting the resources like the layouts or strings or anything. Make sure everything is deleted properly every dependency is deleted properly.A thorough clean up. That solved the problem for me
The cause is empty because the problem is in your resources xml or manifest
Well, I recognize that this has been asked before, but in browsing the other answers:
IntelliJ IDEA - Can't build anything, always get "package R does not exist"
Error: java: package R does not exist
etc.
none of the solutions work.
This is for a project that was building fine until at least the last couple days, so whatever is causing the problem must be new.
Symptoms:
Attempting to to a Build > Rebuild Project fails. I see the step for compiling generates sources go by in the status bar, but the next compilation step fails with the dreaded "java: package R does not exist."
R is found just fine in the IDE, so only compilation fails, suggesting there is a problem with the compilation of the generated sources. This seems borne out by the fact that in the out/production/[module] directory, only some resource files show up, no compiled classes, nothing in the "generated" sbupackage, a no apk file.
Interestingly, when I connect my phone to the computer and try running the application on the device, new changes are picked up, so something is being successfully built somewhere.
Things I've tried:
Per the other threads I've tried:
Doing a full rebuild.
Restarting IntelliJ (including with invalidating caches)
Restarting the computer.
Checking that the gen package is included under sources.
Checking for any Excludes (there are none)
Deleting the stub R file and forcing IntelliJ to regenerate it (which it does promptly)
Confirming that there is an Android facet on the module.
Double-checking that the manifest xml file has not changed and that the referenced activity is correct.
Checked that exclude output path is not checked (it's greyed as I'm inheriting from the project compile path, but I tried switching and manually unchecking it... no luck).
The only recent changes in xml were:
A new item in a menu file. I tried removing it to see if somehow that was an issue even though there were no errors reported, but the problem persisted.
I moved a View class to a subpackage of its prior package. That View class is referenced once in a layout xml and I confirmed that the xml was updated with the new package name.
So at this point I'm out of ideas. Sorry to rehash a somewhat common question.
I have the same problem and it definitely related to last update of the IDE. My version is IU-139.1117.1
Before the update Build -> 'Rebuild Project' was working ok in a windows and a mac installation of the IDE. I updated windows first and 'Rebuild Project' shows the error 'Package R does not exist' even for a new Android project. Same error apeared in mac installation imediately after the update. 'Make project', 'Make module' and 'Compile' commands on the Build menu are all working ok with no error only 'Rebuild project' raises the error.
For a new Gradle Android project everything works ok. It seems something is wrong with last update.
It is reported issue in IDEA 14.0.3 (http://youtrack.jetbrains.com/issue/IDEA-135234).
You can try to Compile Module (Ctrl-Shift-F9) for the module that contains missing R file. It works for me (but I have to do this every time i add/remove items in resources).
don't use Rebuild Project, use Make Project and refresh your project,maybe you should try it a few more times.
Try File | Invalidate Caches. This is solve my problem.
If you cannot wait for a officially stable build, install IDEA EAP 14.0.4 (IntelliJ IDEA 14.0.4 EAP build 139.1408, released on February 20th, 2015) from https://confluence.jetbrains.com/display/IDEADEV/IDEA+14+EAP
I've just solved all issues and rebuild project works again.
Solved with the 14.1 update of intelliJ IDEA, available now.
I had the same issue on a Windows 7 box today with a Java 7 Gradle project, using IntelliJ 14.1.5.
The problem was that somehow the classpath was "too long", but IntelliJ gave me only those strange "java: package foo does not exist" compile error's.
The usual tricks (see also above) did not help.
The workaround was to shorten the classpath a bit, in my case setting GRADLE_USER_HOME to c:/.gradle (was before c:/users/myusername/.gradle). After resyncing the gradle project everything worked fine.
The problem was therefor obviously IMO some kind of windows filesystem path length restriction.
EDIT: This problem has not already been resolved in the other suggested SO question
I had a fully working app on the market for over a year, with very few crash reports. Then recently I changed my app into a library, so that it could be included within multiple different "wrapper" projects. This was so that I could easily make different version - free, paid, non-google markets, with/without in-app purchasing etc etc.
The new "library+wrapper" app appeared to work fine. I could run it multiple times, without error. But then a day later (when presumably the OS had closed some or all of the app's activities) I tried to run it and it reported
Unable to instantiate application com.mycompany.mygamelibrary.MyGameApplicationClass: java.lang.ClassNotFoundException: com.mycompany.mygamelibrary.MyGameApplicationClass
The class it failed to find is the first class that runs when the program starts up, MyGameApplicationClass - which extends Application. This class is part of the library.
I suspect something goofy in one of the two manifest files.
The manifest of the wrapper project contains the lines...
<application android:icon="#drawable/mygame_icon"
android:screenOrientation="portrait" android:label="My Game Name"
android:name="com.mycompany.mygamelibrary.MyGameApplicationClass">
Any ideas what could have gone wrong?
EDIT: The library was referenced "the correct way" as defined by yorkw's answer to this SO question.
EDIT: I can not repeat the crash at the moment :-( I don't know what it is the OS does when the app is not used for a day or two.
There are two possibilities. Either you, like me, have a spelling error in your manifest file. Have a co-worker or friend read it to make sure the name is correct. Or you have not referenced the project correctly.
The official document describes how to properly link projects in its documentation.
Why it would first seem to work and later stop working is a bit of a mystery. However, I guess that the VM might still have had the necessary references ready to resolve the classes in the library just fine. A restart of the VM removed all those references and trying to resolve them was unsuccessful.
Update: Regarding the edits in the OP: As you confirm that you have correctly referenced the other project, you can check if the project is included in APK, just to be sure. You can rename and open an APK as any other archive (.rar works fine for me). Sometimes, it happened to me, the project is not correctly included in the APK. A cleaning of your workspace usually remedies the problem and so could a restart of your IDE depending on what you are using. To manually conduct a clean in Eclipse for example, use Project->Clean... or try Android Tools->Fix Project Properties by right-clicking on your project.
As you seem to also have fixed the problem by restarting your device, it could be that the libraries were linked incorrectly. A problem that I have never seen myself but as a very common quote says: "Have you tried turning it off and on again?".
For Android Studio:
Build --> Clean Project
Fixed issue.
Have you tried to make a new subclass of MyGameApplicationClass in your 'main' project and set it in the manifest as Application class?
I had a slew of bugs with Android Studio 3.0 Canary 4 and the way I fixed them was by editing the AndroidManifest.xml by adding in some jibberish to the application name. Then, I clicked build. Obviously, a whole mess of new error messages appeared. I changed the name back to what it should be, built the app, and it just ran.
Sometimes, I just don't know...
EDIT: Just ran into this issue on Android Studio 3.0 Canary 4 on my laptop when switching over. I again went through the same process of changing AndroidManifest.xml file to contain a typo, building, and changing back. That didn't work.
I then noticed that instant run was still enabled. Going into settings (by clicking command + , (comma key)) and typing "instant run", I was able to disable instant run, built the app, and the error of class not found went away.
Summary of Steps to Fix [FOR ME]
Invalidate cache / restart
Clean the project
Manually delete the build folder (need to be in project view for this one)
Make an intentionally errant edit to your AndroidManifest.xml file, build the app, observe the errors, remove the errant edit and build again
Disable instant run
Again, I don't mean to insinuate that this will fix everyone's error, but I have now used some combination of these steps on two different machines (MacOS Sierra) and it has been resolved for me. Hope it helps.
In my case, application id and package were mismatched. This should be same as presented in following images...
AndroidManifest.xml
app/build.gradle
In this case you can see, applicationId and package both are same that is com.mycompany.mygamelibrary
May be its a Build Path Configuration problem.I did the following to solve the issue.
1.Right click on your project and go to Java Build Path.
2.Click on Order and Export tab.
3.Check Android Private Libraries and other 3rd part libraries if you have added.
4.Press ok and clean the project.
I hope it will solve the issue.
Once I had the same error message, but maybe the cause isn't the same.
I did a code and worked for a while, then I wanted to improve it and got the same error and I couldn't run it.
I could fix the problem with
the correct Build Path order (as I can see you've already did this)
I check on the Order and Export tab the android-suppor-v4.jar
and the key was the Android SDK Managert->Upgrade everything and (next) Eclipse->Help->Check for updates.
After I upgraded to the latest android plugin and SDK my app compiled and ran again.
I hope this will help you!
I'm not very sure about this but it might be that your system's debug.keystore license validity has expired as it is valid for only 365 days. You just need to delete the debug.keystore from your computer. The debug.keystore will be generated automatically by Eclipse when you compile your Android App.
Same message seen ... this time it turned out to be different output folders for MyApp/gen and MyApp/src in the Build Path (caused by Maven integration).
Unchecking "Allow output folders for source folders" solved the problem.
I had this issue in an Android application that needed an Application class which was created in wrong path inside the Android Studio project. When I moved the class file to the correct package, it was fixed.
This all Process work for me to solve application class Exception.
Step 1: Open Run(window+R) Search -> Prefetch Remove all file (Some file not Delete)
Step 2: Open Run(window+R) Search -> %temp% Remove all file (Some File not Delete)
Step 3: Open Android Studio -> Build -> Clean Project
OR
Select File > Invalidate Caches / Restart > Invalidate and Restart from Android Studio toolbar.
OR
Close and reopen Android project.
OR
Restart System
I ran into this issue several times and both times it seemed to be caused by some instant run feature.
In my case, deleting the application from the device and then installing it from Android Studio again resolved the issue.
I ran into this problem today. The project runs well for over a year but today it reports this issue, and cannot debug on my testing device.
I fixed it by updating to latest gradle version. Hope this can solve your problem.
I am trying to fix a problem in Eclipse for like 3 hours and I haven't made any progress. Tomorrow is the customer coming to look at my app, and I have no time left. This is really frustrating!
This morning when I was coding and I wanted to run my app on my device Eclipse crashed all of a sudden. 'aapt.exe has stopped working'
After this Eclipse wasn't starting anymore. It froze at the splash image.
I looked on the internet and tried different solutions like going back to Java SE 6 update 20, changing .ini file etc. in the end reinstalling Eclipse did the job.
Shortly after that the 'aapt.exe has stopped working' returned. I found a solution by changing my projects target. 1.5, 1.6, 2.2 doesn't matter, as long as it's different than the one before.
Now I get the Error generating final archive: java.io.FileNotFoundException: C:\xxx\bin\resources.ap_ does not exist error.
I tried clean but that doesn't work. Deleting and automatically regenarting R.java also didn't work.
I ran the same code in Netbeans with the Android plugin and there it gives me the 'aapt.exe has stopped working' again :(
Please guys, how can I fix this?
Edit:
I think I may have found the reason. These are the error lines in the console:
org.xmlpull.v1.XmlPullParserException: Binary XML file line #3: <bitmap> requires a valid src attribute
at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:341)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:779)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:720)
at com.android.layoutlib.bridge.ResourceHelper.getDrawable(ResourceHelper.java:150)
at com.android.layoutlib.bridge.BridgeTypedArray.getDrawable(BridgeTypedArray.java:668)
at android.view.View.<init>(View.java:1846)
at android.view.View.<init>(View.java:1795)
at android.view.ViewGroup.<init>(ViewGroup.java:282)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
[2011-01-17 16:37:20 - gegevens.xml] Unable to resolve drawable "com.android.layoutlib.utils.ResourceValue#267e33de" in attribute "background"
The file it's talking about is 'bg.png'. It's a small png file which I repeat in a .xml file.
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/bg" android:tileMode="repeat" />
This file has worked from the first time without any problems.
I deleted it from the drawable folder, waited for an error message, and then added it back. The red x next to the foldername got away, but still nothing different...
A shot in the dark, but if it's just the one PNG file could you delete it from the project and add it back? There must be something breaking the resources file.
I just encountered the same error after performing an SDK update withing Eclipse (Indigo). Normally I would either delete the errors and try to rebuild or clean with success, however this time it didn't fix the problem.
Finally I went to the android sdk folder and manually updated. Upon coming back into eclipse I got the error again, but without rebuilding or cleaning I was able to launch the application onto the device by pressing play for a second time.
EDIT:Apparently this problem is intermittent, as I am now once again unable to run on the device, or export the signed apk.
SOLVED: The problem stems from a corruption in the .metadata folder. I discovered this by re-installing Indigo, but when doing so I didn't remove the original workspace folder. The problem of course showed up again. I deleted the .metadata folder completely, which effectively resets all of your eclipse configuration settings. All deployments and signing work flawlessly now. Just had to setup the environment to my liking again, which takes a few minutes as opposed to the hours I spent troubleshooting this.
I just ran into this same problem after importing my project from another machine, but didn't have any errors in the console like the OP. I unchecked Project->Build Automatically and then did Project->Clean and this solved my problem. I was actually missing several files in the bin/ directory for my project and this fixed them all.
I think this error can come up for a variety of reasons. The following solution is only known to be specific to the same error message appearing when using ADT 14 (released yesterday) with build output set to Verbose:
I ran into the same error using Eclipse 3.7 (Indigo) after upgrading to ADT 14 and SDK 14 on all projects including newly created ones. I found a workaround someone posted on the ADT bug tracker, which is basically to switch Eclipse Settings->Android->Build->Build Output from "Verbose" to "Normal". The post is here.
In my scenario, yesterday upon open Eclipse was trying to download updates and I cancelled it since I was using my cellphone hotspot. I tried the metadata folder delete solution mentioned here and didn't work for me. Going to Window->SDK Manager and updating everything seems to be my solution.
I had the same issue in that I added some images into each resource directory and unfortunately named them .png. There were in fact jpegs and the eclipse plugin was flagging this (unbeknown to me in the console)
The issue I found was that if you clear the console then the logging info is lost and it doesn't log anything again!
Changing the extension from .png to .jpg fixed my issue
Above solution didn't worked for me.
The way I did that is updating not only ADT but SDK as well. To do that just go to Android SDK Manager and just download updates.
IT WORKS!
It's very meaningless but changing build mode from verbose to silent did the trick! Nothing else (cleaning project, re-opening , re-installing) did.
Try running clean, but also uncheck build automatically and click "build project" under the "Project" menu. Once you build manually, you can re-check the "build automatically".
I would also shutdown eclispe, and then kill adb
> adb kill-server
Sometimes this error happens when you create ninepatch with wrong black dots/lines. For example right and bottom lines must be solid with no dashes or empty regions.
Try in
windows-> peferences -> android -> Build -> Build Output
Silent
http://code.google.com/p/android/issues/detail?id=20395
In some cases, this error will disappear after fixing upstream errors. In my case that was a version incompatibility in 'fullwebview.xml'.
There, 'layout_width'/height was set to a value not supported in my build target, 2.1. Changing the value to 'fill_parent' solved the issue.
I encountered this same error but then I saw that my layout.xml was not catching an error for a TextView whose android:text="#string/my_unmapped_string string resource was not mapped in strings.xml. So when I viewed the graphical layout it was showing:
Couldn't resolve .....
When I mapped the resource properly and ran the project again, it worked fine and that bin\resources.ap_ does not exist error was gone :)
In my case, it was the file add-icon.175x175-75.png (valid file name, but invalid resource name) copied into res/drawable by mistake. After removing this file, Eclipse did (in April 2015) a few successful builds with incorrect sources, and only then began to behave sensibly, showing me missing resources and malformed XML (I changed the layout).