4

After I recently installed the latest Eclipse ADT bundle I get some errors in an old project I was working on:

No known package when getting value for resource number 0x7f080028
android.content.res.Resources$NotFoundException: String resource ID #0x7f080028
at android.content.res.Resources.getText(Resources.java:222)
at android.content.res.Resources.getString(Resources.java:275)
at android.content.Context.getString(Context.java:183)
...

In my R-file there is the correct connection between the string I'm looking for and the resource ID.

I tried several things to solve my issue:

  • clean all projects
  • rename all resource-names to lower case names
  • restart computer

I used "adt-bundle-windows-x86_64-20130522" (it compiled without runtime errors) before and downloaded "adt-bundle-windows-x86_64-20140702" because of an error occurred during an update.

Any suggestions?

MD1948
  • 292
  • 2
  • 13
  • Same issue: http://stackoverflow.com/questions/26488866/android-no-known-package-when-getting-value-for-resource-number – MD1948 Oct 21 '14 at 14:51

2 Answers2

6

EDIT: Looks like a new build-tools version (21.0.2) has been released that addresses this issue! The best fix is now to update to this version, rather than revert to an older version or swap out aapt.exe files.


My short answer: use an older version of the Android SDK Build-tools, for now. There's likely a bug with including certain types of files in the assets directory in versions 21 and 21.0.1 of the build-tools--or at least that's why I was receiving the error messages after updating.

My long answer:

I just spent the better half of this morning with the same issue. Frustratingly enough, only two out of three of the projects I work on presented it, but it at least gave me a starting point. I found that the failing projects included a zip file in their assets folders while the working project did not. Removing this zip file allowed all apps to run, but that's obviously not a good enough solution.

I'm going to go out on a limb here and assume that there's a bug in the newest Android SDK Build-tools release (revisions 21 and 21.0.1) that fails to properly build the APK if there's a zip file in the assets folder with certain properties (I didn't research enough to figure out the exact triggers). Just zipping an empty text file wasn't enough to trigger this, but I managed with a small 13KB zip file. I don't know whether any other types of files cause this.

For an immediate fix I just went back to using an older version of the build tools. As seen here, that involves modifying the project.properties file to include sdk.buildtools=20 (for Eclipse users) or the build.gradle file to include buildToolsVersion "20" to the android section (for Android Studio users). Version 20 worked to get me back up to speed, while version 21 breaks my apps. Your current list of installed Android SDK Build-tools versions can be seen in the Android SDK Manager, under Tools.

Riley C
  • 1,249
  • 1
  • 9
  • 5
  • I can confirm this... Been having the same problems all day long with one project (Eclipse, updated ADT, etc). It had a .jar in the assets folder (3rd party instructions to put it here). With build tools 20, it worked fine. With 21, it failed. Moved the .jar to /libs, worked perfect with build tools 21. – Kyle Oct 21 '14 at 18:17
  • 2
    Looks like the AOSP Issue Tracker has already caught wind of this bug, so I left a comment and starred it. The suggested fix (to replace `aapt.exe` in android-sdk\build-tools\21.0.1) worked for me without having to make any other modifications. https://code.google.com/p/android/issues/detail?id=77813 – Riley C Oct 21 '14 at 20:22
  • 2
    The new Build-tools version 21.0.2 fixed the problem! Thanks a lot! – MD1948 Oct 22 '14 at 08:32
  • @MD1984 Thanks for the confirmation, I edited my post to reflect the new release. That was fast! – Riley C Oct 22 '14 at 15:44
0

I was facing the same issue for the past 3 hours, after tiring search of Google and other websites

came to a conclusion that this error (Cannot resolve symbol :R )

occurs specially with gradel tools version 21.0, 21.0.1, 21.0.2 and 21.1

BUT it is resolved in build-tools 21.1.1.

For Android IDE users , following steps can work.

  1. go to your project's Gradel Scripts folder.
  2. select the folder build.gradel(app) { not the other build.gradel("your mainActivity classname").
  3. open the build.gradel(app) file,

             CHANGE the buildToolsVersion to "21.1.1" from your old buildToolsVersion..
    

    4.Sync your project one more time. 5.That's it.

It worked for me.