在Android NDK清单文件引用相对路径的资源 [英] Referencing relative path resources from Android NDK manifest file

查看:912
本文介绍了在Android NDK清单文件引用相对路径的资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前距离NDK清单文件有问题,包括资源,我相信这是一个快速修复错误。有很多是在一个大的库项目和操作系统之间共享文件。因此,为了保持这些文件的最新与其他项目和每个发生的更新,一大堆本地标题和时间更新各个项目的最新的API保持源$ C ​​$ C文件需要相对引用路径。

I am currently having trouble including resources from the NDK manifest file and I am sure that it is a quick fix error. There are plenty of files that are shared between projects and operating systems in a large library. Therefore, in order to keep the files up to date with other projects and keep from updating each individual project with the latest API each time an update occurs, a whole bunch of native header and source code files need to be referenced with relative paths.

在Eclipse中,我点击了和整个文件拖(无需将其复制,但通过使用相对路径),将当前应用程序中的项目需要在本地文件夹结构。

Within Eclipse, I have clicked and dragged across the files (without copying them, but by using a relative path) that would be needed by the current application in a local folder structure in the project.

/projectFolder /jni /externalProjectFiles /src /include

使用Eclipse中这个文件夹结构,我有以下结构的Andr​​oid.mk文件:

With this folder structure within Eclipse I have an Android.mk file with the following structure:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := projectLib

LIBRARY_SRC_FOLDER   := $(wildcard $(LOCAL_PATH)/externalProjectFiles/src/*.cpp)

LOCAL_C_INCLUDES := $(LOCAL_PATH)/externalProjectFiles/include

LOCAL_SRC_FILES :=  projectLibNDK.c
LOCAL_SRC_FILES +=  $(LIBRARY_SRC_FOLDER:$(LOCAL_PATH)/%=%)

LOCAL_LDLIBS    := -L$(SYSROOT)/usr/lib -llog -landroid
LOCAL_CFLAGS    :=  -Wno-multichar -D_ANDROID -DLIBDIR="\"c\"" 
LOCAL_CFLAGS    +=  -DUSE_TCP_LOOPBACK -DMDNS_UDS_SERVERPATH=\"/var/run/mdnsd\" -DIN_LIBRARY -DBUILDING_LIBICONV -DUSE_BONJOUR 
LOCAL_CFLAGS    +=  -DXR_TARGET_ANDROID -DKS_BUILDING_KS -Wno-psabi -Wno-multichar -D_GNU_SOURCE -DHAVE_IPV6=0 -DNOT_HAVE_SA_LEN 
LOCAL_CFLAGS    +=  -DUSES_NETLINK -DHAVE_LINUX -DTARGET_OS_LINUX
LOCAL_CPPFLAGS  :=  -frtti -fexceptions

include $(BUILD_SHARED_LIBRARY)

然而,当我尝试以包括projectLibNDC.c第一头它打印的没有这样的文件或目录的错误。

的#includeexternalFile.h

是我服用一种可能的解决办法?结果
我必须提供在Android.mk的相对路径文件本身的文件?这将是更麻烦的一点,而不是引用引用文件的本地文件夹。结果

Is the approach that I am taking a possible solution?
Do I have to provide the relative paths in the Android.mk file itself for the files? That would be a bit more of a hassle instead of referencing a local folder of referenced files.

在理论上,这听起来好像我将能够通过NDK以这种方式来创建一个库。但是,也许我没有正确设置项目。任何助手将是有益的; JNI有扔我身边偶尔的倾向。

In theory, it sounds as though I would be able to create a library through the NDK in this manner. But, perhaps I am not setting up the project properly. Any aide would be helpful; JNI has a tendency to throw me around on occasion.

编辑:这似乎是Eclipse的(这是一个惊人的IDE)没有引用,它一直在其项目设置链接的文件后面的任何胶水。如果我拖引用的文件到项目中,有投入这些文件夹重新present一个链接的文件存在,没有物理文件。这些信息只存储在项目设置明显。这是不是为Android.mk文件很有帮助。搜索结果
这意味着,任何脚本或生成文件不会有任何引用,以什么应该文件被包括在内。不幸的是,我必须从makefile文件本身单独引用文件夹和文件。我可能会留在项目中的引用作为一个提示,从其他程序员自己的存在。不幸的是,我不能设计这样的说法,但是这是我迄今受到的结论。

It would seem that Eclipse (which is an amazing IDE) does not have any glue behind the references to the linked files that it keeps in its project settings. If I drag referenced files into the project, there are no physical files put into those folders to represent a linked files existence. That information is only stored in project settings apparently. Which is not helpful for the Android.mk file.

This means that any scripts or makefiles would not have any reference as to what files are supposed to be included. Unfortunately, I will have to reference folders and files individually from the makefile itself. I might leave the references in the project as a hint to their existence from other programmers. Unfortunate that I cannot design it that way, but that is the conclusion that I have received thus far.

推荐答案

在最后,我决定采取的方法是分别包括在makefile这些文件的相对路径。这不是干净的解决方案,但它的工作,并提供一个体面的环境,更高版本。

In the end, the approach that I decided to take was to include the relative paths to the files in the makefile individually. It was not the cleanest solution but it worked and provided a decent environment to work with later.

...
LOCAL_C_INCLUDES += $(COMMON_COMPUTATION_PATH)
LOCAL_C_INCLUDES += $(COMMON_DATASET_PATH)
...
LOCAL_SRC_FILES += $(COMMON_COMPUTATION_PATH)/matrixRT.cpp $(COMMON_COMPUTATION_PATH)/multiplRT.cpp
LOCAL_SRC_FILES += $(COMMON_COMPUTATION_PATH)/multiplSqRT.cpp $(COMMON_COMPUTATION_PATH)/multiplSq1978RT.cpp
...

以previous库,曾它已经在iOS应用程序中的链接文件开始,我可以将这些资源上拖动到Eclipse项目中的本地文件夹。然后,从PROJ_LOC选择链接到文件。由于这两个项目有,我将使用的所有文件相同的相对路径,这个工作就像一个魅力,从发现和删除对单个的人,我需要救了我。

Starting with a previous library that had linked files in it already within an iOS application, I can drag over those resources into local folders within the Eclipse project. Then select 'Link to files' from PROJ_LOC. Since both projects have the same relative path to all the files that I would be using, this worked like a charm and saved me from finding and dropping over individual ones that I need.

由于共享文件只是零碎的东西就需要在这些目录中我不能创建一个文件夹中引用的源文件外卡离开。不过,我相信,最终这将是最好的要求组织的文件夹结构的移动软件,使我们能够确实只是参考,将在移动项目中所需的文件。

Since the shared files are only piecemeal of what would be needed in those directories I cannot get away with creating a single folder reference to source files with a wild card. However, I believe that in the end it would be best to request an organizational folder structure for mobile software so that we can indeed just reference the files that would be needed in mobile projects.

所以,最后,我不能使用链接的文件从清单文件的引用。如果你的作品user1368342提到,操作系统级链接文件可以作出,并从清单文件中使用。但是,对于跨多个操作系统平台的可移植性的原因,我决定不走这条路。

So in the end, I could not use the linked files as a reference from the manifest files. If it works for you user1368342 has mentioned that an OS level link file could be made and used from within a manifest file. However, for portability reasons across multiple OS platforms I decided not to go that route.

目前至少有一个安装这种方式,用户可以看到包含在正在构建的项目库的链接的文件。他们还可以在屏幕上,并在清单文件时更改的更新并获得更新,以处理从直接从项目编制内引起的任何错误的能力一起。

At least with a setup this way, the user can see the linked files that are included in the project library that is being built. They can also get updates on the screen and in the manifest when files change and get updated, along with the capability to handle any errors that arise from compiling it directly from within the project.

的缺点是,当一个新的文件需要被引入,将需要在一个单一的位置被添加到项目和清单都,代替。但是,这对我来说是可以接受的解决方案。希望谁比谁跨一项问题,如这一个发现有用的办法。

The downside is that when a new file needs to be introduced it will need to be added to both the project and the manifest, instead of in one single location. But, it's an acceptable solution for me. Hopefully anyone else who comes across an issue such as this one finds the approach useful.

这篇关于在Android NDK清单文件引用相对路径的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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