我正在为Android开发Titanium模块。我将自定义菜单xml“context_menu.xml”添加到模块项目的 / platform / android / res / menu / 文件夹中。
它可以成功打包但是当在另一个移动项目中包含该模块时,它总是在构建期间引发错误:
[错误]无法找到生成的R.java文件
这是context_menu.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/acion_highlight"
android:title="@string/highlight"
android:showAsAction="always"/>
<item android:id="@+id/action_addNote"
android:title="@string/addNote"
android:showAsAction="always"/>
</menu>
那有什么不对?
[编辑:在logcat中添加日志]
05-09 04:47:47.476: D/AndroidRuntime(1120): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
05-09 04:47:47.476: D/AndroidRuntime(1120): CheckJNI is OFF
05-09 04:47:47.476: D/dalvikvm(1120): Unable to stat classpath element '/system/framework/filterfw.jar'
05-09 04:47:47.480: D/dalvikvm(1120): Trying to load lib libjavacore.so 0x0
05-09 04:47:47.480: D/dalvikvm(1120): Added shared lib libjavacore.so 0x0
05-09 04:47:47.484: D/dalvikvm(1120): Trying to load lib libnativehelper.so 0x0
05-09 04:47:47.488: D/dalvikvm(1120): Added shared lib libnativehelper.so 0x0
05-09 04:47:47.528: D/AndroidRuntime(1120): Calling main entry com.android.commands.pm.Pm
05-09 04:47:47.528: W/ActivityManager(324): No content provider found for permission revoke: file:///data/local/tmp/MyApp.apk
05-09 04:47:47.680: W/ActivityManager(324): No content provider found for permission revoke: file:///data/local/tmp/MyApp.apk
05-09 04:47:47.724: D/dalvikvm(324): GC_CONCURRENT freed 465K, 18% free 12077K/14663K, paused 11ms+1ms, total 27ms
05-09 04:47:47.724: D/dalvikvm(324): WAIT_FOR_CONCURRENT_GC blocked 1ms
05-09 04:47:47.740: D/dalvikvm(324): GC_FOR_ALLOC freed 347K, 20% free 11856K/14663K, paused 13ms, total 13ms
05-09 04:47:47.748: D/dalvikvm(324): GC_FOR_ALLOC freed 180K, 19% free 11899K/14663K, paused 11ms, total 11ms
05-09 04:47:47.768: D/dalvikvm(324): GC_FOR_ALLOC freed 62K, 19% free 11963K/14663K, paused 11ms, total 11ms
05-09 04:47:47.768: I/dalvikvm-heap(324): Grow heap (frag case) to 11.822MB for 109405-byte allocation
05-09 04:47:47.772: D/dalvikvm(324): GC_FOR_ALLOC freed 127K, 20% free 11943K/14791K, paused 12ms, total 12ms
05-09 04:47:47.840: D/dalvikvm(324): GC_CONCURRENT freed 407K, 16% free 12462K/14791K, paused 11ms+1ms, total 25ms
05-09 04:47:47.912: D/dalvikvm(324): GC_CONCURRENT freed 912K, 15% free 12688K/14791K, paused 11ms+1ms, total 27ms
05-09 04:47:47.912: D/dalvikvm(324): WAIT_FOR_CONCURRENT_GC blocked 6ms
05-09 04:47:48.040: D/dalvikvm(324): GC_CONCURRENT freed 1171K, 15% free 12711K/14791K, paused 12ms+1ms, total 38ms
05-09 04:47:48.040: D/dalvikvm(324): WAIT_FOR_CONCURRENT_GC blocked 14ms
05-09 04:47:48.092: D/dalvikvm(324): GC_CONCURRENT freed 1191K, 15% free 12716K/14791K, paused 11ms+2ms, total 30ms
05-09 04:47:48.092: D/dalvikvm(324): WAIT_FOR_CONCURRENT_GC blocked 8ms
05-09 04:47:48.156: D/dalvikvm(324): GC_CONCURRENT freed 1072K, 14% free 12723K/14791K, paused 11ms+2ms, total 27ms
05-09 04:47:48.312: D/dalvikvm(324): GC_CONCURRENT freed 1189K, 14% free 12737K/14791K, paused 11ms+1ms, total 25ms
05-09 04:47:48.320: D/dalvikvm(324): WAIT_FOR_CONCURRENT_GC blocked 3ms
05-09 04:47:48.532: D/dalvikvm(324): GC_CONCURRENT freed 1132K, 14% free 12752K/14791K, paused 11ms+12ms, total 40ms
05-09 04:47:48.796: D/dalvikvm(324): GC_CONCURRENT freed 1154K, 14% free 12753K/14791K, paused 11ms+1ms, total 33ms
05-09 04:47:48.928: D/dalvikvm(324): GC_CONCURRENT freed 1093K, 14% free 12766K/14791K, paused 11ms+1ms, total 29ms
05-09 04:47:49.252: I/PackageManager(324): Removing non-system package:hk.edu.ouhk.MyApp
05-09 04:47:49.252: I/ActivityManager(324): Force stopping package hk.edu.ouhk.MyApp uid=10047
05-09 04:47:49.312: I/PackageManager(324): Package hk.edu.ouhk.MyApp codePath changed from /data/app/hk.edu.ouhk.MyApp-1.apk to /data/app/hk.edu.ouhk.MyApp-2.apk; Retaining data and using new
05-09 04:47:49.332: I/PackageManager(324): Running dexopt on: hk.edu.ouhk.MyApp
05-09 04:47:49.364: D/dalvikvm(1130): Unable to stat classpath element '/system/framework/filterfw.jar'
05-09 04:47:49.408: D/dalvikvm(1130): DexOpt: 'Lorg/apache/commons/codec/binary/Base64;' has an earlier definition; blocking out
05-09 04:47:49.408: D/dalvikvm(1130): DexOpt: 'Lorg/apache/commons/codec/binary/Hex;' has an earlier definition; blocking out
05-09 04:47:49.416: D/dalvikvm(1130): DexOpt: 'Lorg/w3c/dom/UserDataHandler;' has an earlier definition; blocking out
05-09 04:47:49.488: D/dalvikvm(1130): DexOpt: not verifying/optimizing 'Lorg/apache/commons/codec/binary/Base64;': multiple definitions
05-09 04:47:49.492: D/dalvikvm(1130): DexOpt: not verifying/optimizing 'Lorg/apache/commons/codec/binary/Hex;': multiple definitions
05-09 04:47:49.492: I/dalvikvm(1130): DexOpt: not resolving ambiguous class 'Lorg/apache/commons/codec/binary/Hex;'
05-09 04:47:49.520: I/dalvikvm(1130): DexOpt: not resolving ambiguous class 'Lorg/apache/commons/codec/binary/Base64;'
05-09 04:47:49.520: I/dalvikvm(1130): DexOpt: not resolving ambiguous class 'Lorg/apache/commons/codec/binary/Base64;'
05-09 04:47:49.556: D/dalvikvm(1130): DexOpt: not verifying/optimizing 'Lorg/w3c/dom/UserDataHandler;': multiple definitions
05-09 04:47:49.576: I/dalvikvm(1130): DexOpt: not resolving ambiguous class 'Lorg/apache/commons/codec/binary/Hex;'
05-09 04:47:49.612: I/dalvikvm(1130): DexOpt: not resolving ambiguous class 'Lorg/apache/commons/codec/binary/Base64;'
05-09 04:47:49.616: D/dalvikvm(1130): DexOpt: load 35ms, verify+opt 186ms, 2392724 bytes
05-09 04:47:49.628: I/ActivityManager(324): Force stopping package hk.edu.ouhk.MyApp uid=10047
05-09 04:47:49.628: W/PackageManager(324): Code path for pkg : hk.edu.ouhk.MyApp changing from /data/app/hk.edu.ouhk.MyApp-1.apk to /data/app/hk.edu.ouhk.MyApp-2.apk
05-09 04:47:49.628: W/PackageManager(324): Resource path for pkg : hk.edu.ouhk.MyApp changing from /data/app/hk.edu.ouhk.MyApp-1.apk to /data/app/hk.edu.ouhk.MyApp-2.apk
05-09 04:47:49.644: D/PackageManager(324): New package installed in /data/app/hk.edu.ouhk.MyApp-2.apk
05-09 04:47:49.656: D/dalvikvm(586): WAIT_FOR_CONCURRENT_GC blocked 0ms
05-09 04:47:49.656: I/ActivityManager(324): Force stopping package hk.edu.ouhk.MyApp uid=10047
05-09 04:47:49.664: D/dalvikvm(586): GC_EXPLICIT freed 135K, 5% free 8223K/8583K, paused 1ms+1ms, total 8ms
05-09 04:47:49.668: D/dalvikvm(529): WAIT_FOR_CONCURRENT_GC blocked 0ms
05-09 04:47:49.676: D/dalvikvm(529): GC_EXPLICIT freed 447K, 7% free 10264K/10951K, paused 0ms+1ms, total 9ms
05-09 04:47:49.680: D/PackageManager(324): generateServicesMap(android.accounts.AccountAuthenticator): 2 services unchanged
05-09 04:47:49.680: D/PackageManager(324): generateServicesMap(android.content.SyncAdapter): 4 services unchanged
05-09 04:47:49.680: D/BackupManagerService(324): Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:hk.edu.ouhk.MyApp flg=0x8000010 (has extras) }
05-09 04:47:49.688: I/InputReader(324): Reconfiguring input devices. changes=0x00000010
05-09 04:47:49.688: D/dalvikvm(324): WAIT_FOR_CONCURRENT_GC blocked 0ms
05-09 04:47:49.716: D/dalvikvm(324): GC_EXPLICIT freed 692K, 14% free 12743K/14791K, paused 11ms+4ms, total 30ms
05-09 04:47:49.720: D/PackageManager(324): generateServicesMap(android.accounts.AccountAuthenticator): 2 services unchanged
05-09 04:47:49.720: D/PackageManager(324): generateServicesMap(android.content.SyncAdapter): 4 services unchanged
05-09 04:47:49.720: D/BackupManagerService(324): Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:hk.edu.ouhk.MyApp flg=0x8000010 (has extras) }
05-09 04:47:49.720: V/BackupManagerService(324): removePackageParticipantsLocked: uid=10047 #1
05-09 04:47:49.732: I/InputReader(324): Reconfiguring input devices. changes=0x00000010
05-09 04:47:49.740: V/BackupManagerService(324): addPackageParticipantsLocked: #1
05-09 04:47:49.756: D/dalvikvm(324): WAIT_FOR_CONCURRENT_GC blocked 0ms
05-09 04:47:49.776: W/ResourceType(324): Failure getting entry for 0x7f060000 (t=5 e=0) in package 0 (error -75)
05-09 04:47:49.776: W/ResourceType(324): Failure getting entry for 0x7f060000 (t=5 e=0) in package 0 (error -75)
05-09 04:47:49.776: W/InputMethodManagerService(324): Found no subtypes in a system IME: com.android.inputmethod.pinyin
05-09 04:47:49.776: W/RecognitionManagerService(324): no available voice recognition services found
05-09 04:47:49.804: D/dalvikvm(324): GC_EXPLICIT freed 1821K, 23% free 11414K/14791K, paused 1ms+2ms, total 50ms
05-09 04:47:49.808: D/AndroidRuntime(1120): Shutting down VM
05-09 04:47:49.808: D/dalvikvm(1120): GC_CONCURRENT freed 99K, 78% free 450K/2048K, paused 0ms+0ms, total 1ms
05-09 04:47:49.808: D/jdwp(1120): Got wake-up signal, bailing out of select
05-09 04:47:49.808: D/dalvikvm(1120): Debugger has detached; object registry had 1 entries
05-09 04:47:49.808: I/AndroidRuntime(1120): NOTE: attach of thread 'Binder_3' failed
05-09 04:47:49.812: D/OpenGLRenderer(529): TextureCache::callback: name, removed size, mSize = 137, 32256, 1218792
05-09 04:47:49.812: D/OpenGLRenderer(529): TextureCache::get: create texture(0xb818d7a8): name, size, mSize = 143, 32256, 1251048
答案 0 :(得分:0)
问题解决了。 根本原因是必需的xml未正确定义。 “context_menu.xml”指的是我没有包含在res / values / strings.xml中的字符串定义“action_highlight”和“action_addNote”
希望它能帮助Android开发新手。