Eclipse的ADT" ...无法解析"与Android NDK和C文件 [英] Eclipse ADT "... could not be resolved" with Android NDK and C files

查看:133
本文介绍了Eclipse的ADT" ...无法解析"与Android NDK和C文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Eclipse的索引我的NDK项目的问题。还有很多类似的线程在那里,但没有,似乎触及问题的同一来源的。我有一个OpenGL ES的应用程序,我需要在端口到Android纯粹用C,我想作为一个NativeActivity的,preferably无连接到它的Java运行用。在code编译正常使用 NDK的构建大量重写后,但在IDE中有很多误区,如键入GLfloat 无法解析。一个APK被产生,我可以亚行和所有安装它,但我希望能够使用IDE,特别是用于调试。

如果我选择了线的上下文菜单打开宣言,如的#include< GLES2 / gl2.h> 然后Eclipse是能够显示文件我看到的 GLfloat 的定义是有,但我没有得到任何信息,而悬停在任何在该文件中,所以我猜索引只是跳过它以某种方式?头在Android NDK目录下的文件不被索引就好了,比如那些在 JNI 文件夹和子文件夹如 JNI / PNG 。我有 NDKROOT 根定义的C / C ++编译 - >环境,与自身能力的项目并使用CDT视图。

一件事我注意到的是,当我成立了项目最初我该索引提供了Android的NDK的信息没问题的.cpp 文件,但只要我把它改成 .C 错误开始出现。我是IM pression认为Android NDK是供C使用只有基本的C ++的支持,但在样品中环顾四周,这样我就看到一堆的.cpp 文件,所以我很困惑。我试过设置 LOCAL_CPP_EXTENSION + = .C 在我的 Android.mk ,但造成的Eclipse构建过程中挂起。我没有尝试过的最后一件事是重命名所有的文件,所以他们可以得到一个C ++编译器编译,而不是,但我不明白为什么这应该是必要的,我有一些像zlib的第三方库包括源,我会而不甘示弱用。

Android.mk

  LOCAL_PATH:= $(叫我-DIR)包括$(CLEAR_VARS)定义所有-CPP-文件 - 下
$(patsubst ./%,%,\\
    $(壳CD $(LOCAL_PATH); \\
        找到$(1)-name* .c在 - 和 - 不是-name*)\\

endefLOCAL_MODULE:= MyProject的
LOCAL_SRC_FILES:= $(调用所有-CPP-文件 - 下。)
LOCAL_LDLIBS:= -llog -landroid -lEGL -lGLESv2 -lOpenSLES
LOCAL_STATIC_LIBRARIES:= android_native_app_glue
LOCAL_C_INCLUDES + = $(LOCAL_PATH)/杨松
LOCAL_C_INCLUDES + = $(LOCAL_PATH)/ zlib的
LOCAL_C_INCLUDES + = $(LOCAL_PATH)/ PNG包括$(BUILD_SHARED_LIBRARY)$(呼叫进口模块,机器人/ native_app_glue)

Application.mk

  APP_PLATFORM:= Android的9
APP_ABI:= ALL


解决方案

这可能是不解决问题的正确方法,但你可以找到文件 $ {WORKSPACE_LOC} /。元/ .plugins / com.android.ide.eclipse.ndk / $ {} ProjName .pathinfo 。它是一个文本文件,在简单格式。首先,尝试删除该文件,并重建项目。如果这没有帮助,你可以添加

<$p$p><$c$c>i,d:/android/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/$p$pbuilt/windows/lib/gcc/arm-linux-androideabi/4.6/include
i,d:/android/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/$p$pbuilt/windows/lib/gcc/arm-linux-androideabi/4.6/include-fixed
I,D:/ Android的/ Android的NDK-R9 /平台/ Android的14 /弓臂/ usr / include目录

手动(上面的例子是Windows)。

更新一个更好的解决办法是建立ADT一起工作的索引的正确,看的 Android NDK构建,方法无法解析 Eclipse编译成功,但仍给语义错误

I am having problems with the Eclipse indexer for my NDK project. There's a lot of similar threads out there but none that seem to touch on the same source of problems. I have an OpenGL ES application that I need to port over to Android written purely in C that I'd like to run as a NativeActivity, preferably having no Java attached to it. The code compiles fine using ndk-build after a lot of rewriting, but from the IDE there's a lot of errors such as Type 'GLfloat' could not be resolved. An APK gets produced and I can install it with adb and all, but I want to be able to use the IDE, especially for debugging.

If I choose 'Open Declaration' in the context menu for a line such as #include <GLES2/gl2.h> then Eclipse is able to display the file and I see the GLfloat definition is there but I get no info while hovering over anything in that file so I guess the indexer just skips it somehow? Header files not in the Android NDK directory get indexed just fine, such as those in the jni folder and subfolders like jni/png. I have NDKROOT root defined under C/C++ Build -> Environment, a project with native capabilities and using the CDT view.

One thing I noticed was that when I set up the project initially I had a .cpp file which the indexer had no problem providing Android NDK information for, but as soon as I changed it to .c the errors started appearing. I am under the impression that the Android NDK is made for use with C with only basic C++ support but looking around in the samples and such I just see a bunch of .cpp files so I am confused. I've tried setting LOCAL_CPP_EXTENSION += .c in my Android.mk but that caused Eclipse to hang during build. The last thing I haven't tried is renaming all the files so they get compiled with a C++ compiler instead but I don't see why this should be necessary and I have some third-party libraries like zlib included by source that I'd rather not fiddle with.

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

define all-cpp-files-under
$(patsubst ./%, %, \
    $(shell cd $(LOCAL_PATH) ; \
        find $(1) -name "*.c" -and -not -name ".*") \
)
endef

LOCAL_MODULE    := MyProject
LOCAL_SRC_FILES := $(call all-cpp-files-under, .)
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv2 -lOpenSLES
LOCAL_STATIC_LIBRARIES := android_native_app_glue
LOCAL_C_INCLUDES += $(LOCAL_PATH)/jansson
LOCAL_C_INCLUDES += $(LOCAL_PATH)/zlib
LOCAL_C_INCLUDES += $(LOCAL_PATH)/png

include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/native_app_glue)

Application.mk

APP_PLATFORM := android-9
APP_ABI := all

解决方案

This may is not be the right way to fix the problem, but you can find the file ${WORKSPACE_LOC}/.metadata/.plugins/com.android.ide.eclipse.ndk/${ProjName}.pathinfo. It is a text file, in simple format. To begin with, try to delete this file, and rebuild the project. If this does not help, you can add

i,d:/android/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/lib/gcc/arm-linux-androideabi/4.6/include
i,d:/android/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/lib/gcc/arm-linux-androideabi/4.6/include-fixed
i,D:/Android/android-ndk-r9/platforms/android-14/arch-arm/usr/include

manually (the example above is for Windows).

Update a better workaround is to set up ADT to work with indexer correctly, see Android NDK build, Method could not be resolved or Eclipse compiles successfully but still gives semantic errors.

这篇关于Eclipse的ADT&QUOT; ...无法解析&QUOT;与Android NDK和C文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆