简体   繁体   English

Eclipse首选项中Android NDK的无效路径

[英]Invalid path for Android NDK in Eclipse Preferences

I'm looking to incorporate the NDK for C++ code use in my Android project. 我希望在我的Android项目中纳入C ++代码使用的NDK。 I'm using Eclipse Android IDE and I've just downloaded android-ndk-r9-darwin-x86_64.tar.bz2 for OSX 64bit. 我正在使用Eclipse Android IDE,并且刚刚下载了适用于OSX 64位的android-ndk-r9-darwin-x86_64.tar.bz2。 I've uncompressed the ndk and have it in my home folder, but when I attempt to setup the path inside Eclipse prefs, I get this error 我已经解压了ndk并将其保存在主文件夹中,但是当我尝试在Eclipse prefs中设置路径时,出现此错误

NDK的路径无效

I've looked at this similar question ( Eclipse error: invalid path for ndk? ) for answers, but every suggestion didn't solve the problem. 我已经看过这个类似的问题( Eclipse错误:ndk的路径无效? ),但是每个建议都不能解决问题。 Other relevant information, I have Make 3.8.1, up-to-date SDK, Sequoyah. 其他相关信息,我拥有最新的Make 3.8.1 SDK(Sequoyah)。

I had the same problem and documented the solution to this problem. 我遇到了同样的问题,并记录了解决该问题的方法。 It are the first 2 steps of the next link you'll need: http://aplacetogeek.wordpress.com/android-with-opencl-tutorial/ 这是您需要的下一个链接的前两个步骤: http : //aplacetogeek.wordpress.com/android-with-opencl-tutorial/

Edit: 编辑:

The solution is this: 解决方法是这样的:

Step 1: setup Android NDK 步骤1:设定Android NDK

  1. Download the NDK from: http://developer.android.com/tools/sdk/ndk/index.html 从以下网址下载NDK: http//developer.android.com/tools/sdk/ndk/index.html
  2. I unzipped it in the adt-bundle but you can unzip it anywhere you want. 我将其解压缩到adt-bundle中,但是您可以将其解压缩到任何位置。 Note or remember the path you used. 注意或记住您使用的路径。 I'll need it in the next steps! 下一步将需要它!
  3. Go to Window -> Preferences -> Android -> NDK 转到窗口->首选项-> Android-> NDK
  4. Browse to android-ndk-r9c. 浏览至android-ndk-r9c。 Example: /home/dries/AndroidDev/adt-bundle-linux-x86_64-20131030/android-ndk-r9c 示例: /home/dries/AndroidDev/adt-bundle-linux-x86_64-20131030/android-ndk-r9c
  5. Click apply and ok 单击应用并确定

Step 2: configure Android NDK for your project 步骤2:为您的项目配置Android NDK

  1. Right click on your project folder. 右键单击您的项目文件夹。 Choose android tools -> add native support (! the bottom one !) and click finish. 选择android工具->添加本机支持(!最下面的一个!) ,然后单击“完成”。
  2. The file you just created is going to be your own .so file. 您刚创建的文件将是您自己的.so文件。 This will be your personal library with the functions you create yourself in the JNI folder. 这将是您的个人库,其中包含您在JNI文件夹中创建的功能。
  3. Now you should see a JNI folder in your project with a .cpp and an Android.mk file in it. 现在,您应该在项目中看到一个JNI文件夹,其中包含.cpp和一个Android.mk文件。
  4. Go to project -> properties -> C/C++ build -> build variables -> add 转到项目->属性-> C / C ++构建->构建变量->添加

    Name: NDKROOT 名称:NDKROOT

    Value: your android-ndk-r9c folder you also added to NDK in step 1. 值:您在步骤1中也添加到NDK的android-ndk-r9c文件夹。

  5. Click Ok 点击确定

  6. Go to C/C++ build and uncheck Use default build path. 转到C / C ++构建,然后取消选中“使用默认构建路径”。 Change the build path to ${NDKROOT}/ndk-build . 将构建路径更改为${NDKROOT}/ndk-build Make sure you did not end the NDKROOT value on / ! 确保您没有在/上结束NDKROOT值。
  7. Click apply 点击申请

You should be able to use the NDK now and compile without errors. 您现在应该可以使用NDK并进行编译而不会出现错误。

Found a work-around solution to my question with the help from this forum: https://groups.google.com/forum/#!topic/android-ndk/YPFPa9Fen7Y 在以下论坛的帮助下,找到了解决我问题的解决方案: https : //groups.google.com/forum/#!topic/android- ndk/ YPFPa9Fen7Y

I downloaded an old copy of the NDK (r5b) and there were no errors when setting up the path, as opposed to r9 the most recent version. 我下载了NDK(r5b)的旧副本,并且与最新版本的r9相比,设置路径时没有错误。 As the forum says, the problem lies with Sequoyah which has not updated since 2011 and can not recognize the new structure of that the NDK is laid out in. Hope this helps someone in the future. 正如论坛所言,问题在于Sequoyah,自2011年以来未进行更新,并且无法识别NDK所采用的新结构。希望这对将来有所帮助。 (If you find a direct solution though, let me know.) (不过,如果您找到直接的解决方案,请告诉我。)

Instead of downloading another version of the NDK, I simply created links inside the build folder to the toolchains , prebuilt and platforms which recreates the folder hierarchy of the r4 NDK. 无需下载NDK的另一个版本,我只是在build文件夹内创建了到toolchainsprebuiltplatforms链接,这些链接重新创建了r4 NDK的文件夹层次结构。

Doing this made the plugin happy, and I only have one version of the NDK on my computer. 这样做使插件感到高兴,并且我的计算机上只有一个版本的NDK。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM