NDK编程遇到的问题

1.expected unqualified-id before string constant

[armeabi] Compile++ thumb: android_peripheral_assist <= BasePolicy.cpp

In file included from AndroidPeripheralAssist/jni/policys/BasePolicy.h:8:0,
                 from AndroidPeripheralAssist/jni/policys/BasePolicy.cpp:7:
AndroidPeripheralAssist/jni/policys/../Config.h:19:7: error: expected unqualified-id before string constant

make: *** [AndroidPeripheralAssist/obj/local/armeabi/objs/android_peripheral_assist/policys/BasePolicy.o] Error 1

网上查了好多说是类定义少了分号,怎么查都没有少分号的问题,最后发现是因为代码是合并两个程序,所以进行重构的时候,两个程序有变量重名:

比如前面定义了:

#define version "V150522"

后面又在一个数组中定义了一个version成员变量:

typedef struct _tagDongleInfo {
int dongleID;
unsigned short vendorID;
unsigned short productID;
int mode;  
char version[VERSION_LEN]; 
}DONGLE_INFO, *PDONGLE_INFO;

确实变量定义的作用域也是要细致考虑的啊,这样不考虑就出现了这样的问题。


2.ndk程序在Android5.0的64bit机器上不能运行,提示error: only position independent executables (PIE) are supported.

在Android.mk中添加了

LOCAL_CFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -pie -fPIE

也不行,最后发现编译时目标文件是生成在armeabi-v7a目录下,而另一个对比的正常运行的deamon是生成在armeabi目录下的

因此尝试将APP_ABI := armeabi-v7a项设置成APP_ABI := armeabi。

问题解决。(但网上了解这个编译选项和浮点运算有关,而deamon计算空鼠恰好会用到浮点运算,所以现在只是解决问题,这样改会不会导致浮点运算异常的问题,继续调查)


$(warning ***************testtext)


3.

代码为以下的时候:

	while ( !renderThread->WorkDoneFlag )
	{
		ALOGV("ovrRenderThread_Submit pthread_cond_wait");
		pthread_cond_wait( &renderThread->WorkDoneCondition, &renderThread->Mutex );
	}
	ALOGV("renderThread->WorkDoneFlag == true");

出现bug:

11-17 17:02:50.901: V/VrCubeWorld(32174): ovrRenderThread_Submit pthread_cond_wait
11-17 17:02:50.903: A/libc(32174): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 32193 (Thread-6673)
11-17 17:02:50.905: D/=SOGOU_LOG=(25453): onStartCommand--frist notify app--isFristNotifyApp = false
11-17 17:02:50.912: D/=SOGOU_LOG=(25453): run--notify packageName---- notify package app start ---
11-17 17:02:51.011: I/DEBUG(353): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-17 17:02:51.011: I/DEBUG(353): Build fingerprint: 'google/shamu/shamu:5.1/LMY47D/1743759:user/release-keys'
11-17 17:02:51.012: I/DEBUG(353): Revision: '33696'
11-17 17:02:51.012: I/DEBUG(353): ABI: 'arm'
11-17 17:02:51.013: I/DEBUG(353): pid: 32174, tid: 32193, name: Thread-6673  >>> com.oculus.vrcubeworldna <<<
11-17 17:02:51.013: I/DEBUG(353): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
11-17 17:02:51.033: I/DEBUG(353):     r0 af30a5e8  r1 7fc00000  r2 00000000  r3 00000000
11-17 17:02:51.033: I/DEBUG(353):     r4 af1476c0  r5 b364cce8  r6 b3643f14  r7 b364ccd4
11-17 17:02:51.033: I/DEBUG(353):     r8 00000001  r9 aef4b108  sl b6e17b91  fp af30965c
11-17 17:02:51.033: I/DEBUG(353):     ip af309748  sp af309650  lr b3655768  pc b36547ec  cpsr 600f0010
11-17 17:02:51.033: I/DEBUG(353): backtrace:
11-17 17:02:51.034: I/DEBUG(353):     #00 pc 000077ec  /data/app/com.oculus.vrcubeworldna-2/lib/arm/libvrcubeworld.so
11-17 17:02:51.034: I/DEBUG(353):     #01 pc 00008764  /data/app/com.oculus.vrcubeworldna-2/lib/arm/libvrcubeworld.so
11-17 17:02:51.034: I/DEBUG(353):     #02 pc 00008d4c  /data/app/com.oculus.vrcubeworldna-2/lib/arm/libvrcubeworld.so (RenderThreadFunction+708)
11-17 17:02:51.034: I/DEBUG(353):     #03 pc 00016baf  /system/lib/libc.so (__pthread_start(void*)+30)
11-17 17:02:51.034: I/DEBUG(353):     #04 pc 00014af3  /system/lib/libc.so (__start_thread+6)
11-17 17:02:51.195: I/WindowManager(810): Screen frozen for +583ms due to Window{34d1b633 u0 NavigationBar}
11-17 17:02:51.503: I/DEBUG(353): Tombstone written to: /data/tombstones/tombstone_03
11-17 17:02:51.504: W/ActivityManager(810):   Force finishing activity 1 com.oculus.vrcubeworldna/com.oculus.gles3jni.MainActivity
11-17 17:02:51.504: I/BootReceiver(810): Copying /data/tombstones/tombstone_03 to DropBox (SYSTEM_TOMBSTONE)
11-17 17:02:51.547: E/JavaBinder(810): !!! FAILED BINDER TRANSACTION !!!
11-17 17:02:51.548: W/ActivityManager(810): Exception thrown during pause
11-17 17:02:51.548: W/ActivityManager(810): android.os.TransactionTooLargeException
11-17 17:02:51.548: W/ActivityManager(810): 	at android.os.BinderProxy.transactNative(Native Method)
11-17 17:02:51.548: W/ActivityManager(810): 	at android.os.BinderProxy.transact(Binder.java:496)
11-17 17:02:51.548: W/ActivityManager(810): 	at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:704)
11-17 17:02:51.548: W/ActivityManager(810): 	at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:825)
11-17 17:02:51.548: W/ActivityManager(810): 	at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:2726)
11-17 17:02:51.548: W/ActivityManager(810): 	at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:2583)
11-17 17:02:51.548: W/ActivityManager(810): 	at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:2497)
11-17 17:02:51.548: W/ActivityManager(810): 	at com.android.server.am.ActivityManagerService.handleAppCrashLocked(ActivityManagerService.java:11500)
11-17 17:02:51.548: W/ActivityManager(810): 	at com.android.server.am.ActivityManagerService.makeAppCrashingLocked(ActivityManagerService.java:11397)
11-17 17:02:51.548: W/ActivityManager(810): 	at com.android.server.am.ActivityManagerService.crashApplication(ActivityManagerService.java:12081)
11-17 17:02:51.548: W/ActivityManager(810): 	at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:11592)
11-17 17:02:51.548: W/ActivityManager(810): 	at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)
11-17 17:02:51.551: E/lowmemorykiller(255): Error writing /proc/32174/oom_score_adj; errno=22
11-17 17:02:51.575: W/SearchServiceClient(1345): Attempt to handover from detached client
11-17 17:02:51.582: W/Launcher(1345): setApplicationContext called twice! old=com.google.android.velvet.VelvetApplication@234f8935 new=com.google.android.velvet.VelvetApplication@234f8935
11-17 17:02:51.595: W/InputDispatcher(810): channel '10ee25b9 com.oculus.vrcubeworldna/com.oculus.gles3jni.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
11-17 17:02:51.595: E/InputDispatcher(810): channel '10ee25b9 com.oculus.vrcubeworldna/com.oculus.gles3jni.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
11-17 17:02:51.595: I/Zygote(367): Process 32174 exited due to signal (11)
11-17 17:02:51.596: I/ActivityManager(810): Process com.oculus.vrcubeworldna (pid 32174) has died
11-17 17:02:51.599: I/OpenGLRenderer(810): Initialized EGL, version 1.4
11-17 17:02:51.602: I/WindowState(810): WIN DEATH: Window{10ee25b9 u0 com.oculus.vrcubeworldna/com.oculus.gles3jni.MainActivity}
11-17 17:02:51.602: W/InputDispatcher(810): Attempted to unregister already unregistered input channel '10ee25b9 com.oculus.vrcubeworldna/com.oculus.gles3jni.MainActivity (server)'
11-17 17:02:51.606: W/ResourceType(1345): Attempt to retrieve bag 0x7f0e0039 which is invalid or in a cycle.



你可能感兴趣的:(工作辅助知识)