Android 1.5/1.6 issue with style and autogenerated R.java file
I'm having strange issue with R.java file and styles defined in my resources.
Here's some code:
In res/values/strings.xml:
<style parent="android:Theme.Dialog" name="PopupWindowStyle">
<item name="android:windowBackground">@drawable/bg1</item>
<item name="android:textColor">@android:color/black</item>
</style>
In AndroidManifest.xml:
<activity
android:name=".RegisterScreen"
android:icon="@drawable/ico"
android:label="@string/applicationName"
android:theme="@style/PopupWindowStyle"
android:configChanges="locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|fontScale">
</activity>
In autogenerated gen/.../R.java:
public static final class style {
public static final int PopupWindowStyle=0x7f090000;
}
After some changes in the project, eclipse changed autogenerated value for PopupWindowStyle
from 0x7f080000 to 0x7f090000. After that, on Android 1.5, RegisterScreen
activity is displayed without PopupWindowStyle
style - there is an error displayed in logcat:
Skipping entry 0x7f090000 in package table 0 because it is not complex!
On Android 1.6 however everything works fine - PopupWindowStyle
works like it was before it's integer value has changed.
I was testing this i开发者_运维问答ssue, by reverting the source code to older revisions. I can confirm, that this problem started occurring after src code commit, which changed two files completely unrelated to this part of code - and an autogenerated R.java file.
Any idea what could cause that?
I too faced this error today. In my case, there are 2 projects - one an app and the other library. Both contain strings. In the code of library project, the generated R class file had same integral indexes of some strings as that of the app project.
I had to change default.properties of app project to make it included android.library.reference.1=libraryprojectlocation
where libraryprojectlocation is the relative disk location of the library project.
I had the same problem, I had a string array in a res/values/array.xml. When I moved the string array to res/values/strings.xml, the app ran fine. Looking at the android dev site http://developer.android.com/guide/topics/resources/providing-resources.html however they make it clear that it's okay to have more than one xml file in res/values, and in fact they suggest it. So I tried an experiment, I changed the name of the offending xml file to arrays.xml, note the extra "s" at the end, and it worked. I also restarted my avd and eclipse. And I also used the gui to build the xml file instead of typing it in.
Ok. I kinda solved the issue, but I still don't know why it needs to be that way on Android 1.5.
It seems that it was caused by another file: res/values/colors.xml which had only this content:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="threattypelabel">#4f83cc</color>
<color name="threattypebg">#eeeeee</color>
</resources>
After moving those color tags back to res/values/strings.xml it suddenly works fine (tested few times back and forward).
精彩评论