请问在android4.0中,使用protobuf.jar包的android应用不可用

yuanhotel 发布于 2012/12/25 17:07
阅读 3K+
收藏 0

罗老师,你好!

   我们公司用的是A10s的版子,最新版本是android4.0-v1.4。我们开发的应用,用到google的protobuf2.2.0a(应用原来用的是2.3.0因为报错,就改成与android系统一样的版本)。只要用到protobuf的地方报错。报错如下:

E/ServiceAccessing( 2145): searchDicALL
E/ServiceAccessing( 2145): java.lang.UnsupportedOperationException: This is supposed to be overridden by subclasses.
E/ServiceAccessing( 2145): 	at com.google.protobuf.GeneratedMessage.getUnknownFields(GeneratedMessage.java:180)
E/ServiceAccessing( 2145): 	at cn.com.xinli.android.service.protocol.BoxSearch$SearchDictReq.getSerializedSize(BoxSearch.java:683)
E/ServiceAccessing( 2145): 	at cn.com.xinli.android.service.net.ServiceAccessing.searchDicALL(ServiceAccessing.java:541)
E/ServiceAccessing( 2145): 	at cn.com.xinli.android.business.BusinessDataSerch.initData(BusinessDataSerch.java:166)
E/ServiceAccessing( 2145): 	at cn.com.xinli.android.doudian.service.SyncService.onHandleIntent(SyncService.java:52)
E/ServiceAccessing( 2145): 	at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
E/ServiceAccessing( 2145): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/ServiceAccessing( 2145): 	at android.os.Looper.loop(Looper.java:137)
E/ServiceAccessing( 2145): 	at android.os.HandlerThread.run(HandlerThread.java:60)
D/HomeTabSecondFragment( 2145): resultCode = 1
D/dalvikvm( 2145): GC_CONCURRENT freed 540K, 31% free 9287K/13447K, paused 2ms+3ms
I/BusinessDataSerch( 2145): channel:interface.count=33,update.count=33
I/BoxSearch.SearchPacketType.DictReq.getNumber():( 2145): 65570
I/searchDicReq.getAccount():( 2145): user
E/ServiceAccessing( 2145): searchDicALL
E/ServiceAccessing( 2145): java.lang.UnsupportedOperationException: This is supposed to be overridden by subclasses.
E/ServiceAccessing( 2145): 	at com.google.protobuf.GeneratedMessage.getUnknownFields(GeneratedMessage.java:180)
E/ServiceAccessing( 2145): 	at cn.com.xinli.android.service.protocol.BoxSearch$SearchDictReq.getSerializedSize(BoxSearch.java:683)
E/ServiceAccessing( 2145): 	at cn.com.xinli.android.service.net.ServiceAccessing.searchDicALL(ServiceAccessing.java:541)
E/ServiceAccessing( 2145): 	at cn.com.xinli.android.business.BusinessDataSerch.initData(BusinessDataSerch.java:166)
E/ServiceAccessing( 2145): 	at cn.com.xinli.android.doudian.service.SyncService.onHandleIntent(SyncService.java:52)
E/ServiceAccessing( 2145): 	at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
E/ServiceAccessing( 2145): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/ServiceAccessing( 2145): 	at android.os.Looper.loop(Looper.java:137)
E/ServiceAccessing( 2145): 	at android.os.HandlerThread.run(HandlerThread.java:60)
提示里面少方法:

我看了一下android4.0的源代码(./external/protobuf)中的Android.mk进行编译时,只编译了部分功能如下:

JAVA_LITE_SRC_FILES := \
    java/src/main/java/com/google/protobuf/UninitializedMessageException.java \
    java/src/main/java/com/google/protobuf/MessageLite.java \
    java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java \
    java/src/main/java/com/google/protobuf/CodedOutputStream.java \
    java/src/main/java/com/google/protobuf/ByteString.java \
    java/src/main/java/com/google/protobuf/CodedInputStream.java \
    java/src/main/java/com/google/protobuf/ExtensionRegistryLite.java \
    java/src/main/java/com/google/protobuf/AbstractMessageLite.java \
    java/src/main/java/com/google/protobuf/FieldSet.java \
    java/src/main/java/com/google/protobuf/Internal.java \
    java/src/main/java/com/google/protobuf/WireFormat.java \
    java/src/main/java/com/google/protobuf/GeneratedMessageLite.java
编译源代码如下,变量如上(因少类,我将java目录下的29个java源文件添加进去,最后生成的jar还是原来的12个,不知道怎么解决?)

# Java lite library (for device-side users)
# =======================================================
include $(CLEAR_VARS)

LOCAL_MODULE := libprotobuf-java-2.3.0-lite
LOCAL_MODULE_TAGS := optional
LOCAL_SDK_VERSION := 8

LOCAL_SRC_FILES := $(JAVA_LITE_SRC_FILES)

include $(BUILD_STATIC_JAVA_LIBRARY)

# Java lite library (for host-side users)
# =======================================================
include $(CLEAR_VARS)

LOCAL_MODULE := host-libprotobuf-java-2.3.0-lite
LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES := $(JAVA_LITE_SRC_FILES)

include $(BUILD_HOST_JAVA_LIBRARY)
问题:

1,在编译完android源代码后,能不能找到生成lite版的protoc可执行命令?

2,如何修改Android.mk,以便能生成完整版的protobuf.jar.并直接打包到android系统的内核中?

加载中
返回顶部
顶部