- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 https://www.youtube.com/watch?v=kjsC-lKUgM8尝试调试简单 NDK 应用程序的教程。 我已经完成了视频中的所有操作,除了:
android:debuggable=true
(因为 eclipse 认为它是错误)在 AndroidManifest.xml 中,我已经从 Preferences->Android->NDK
设置了 NDK 路径并在 Project Properties -> C/C++ Build
未选中 Use default build command
并设置在那里 ndk-build NDK_DEBUG=1 APP_OPTIM=debug
. x86 emulator
但是 Samsung Duos S
设备与 Android 4.0.4
最佳答案
以下是我为我们的内部 Android 开发团队编写的教程的摘录。其中大部分来自此博客:http://mhandroid.wordpress.com/
重要笔记:
Open AndroidManifest.xml, select the Application tab, and set
Debuggable=true
. This will make the application debuggable even when it's running on a device that's running in user mode.4. Build the Native Sources. From the Terminal, enter the project directory and enter:
ndk-build -B
您应该看到以下输出:
Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Compile++ thumb : DebuggingTestJNI <= com_sample_test_DebuggingTestActivity.cppStaticLibrary : libstdc++.a
SharedLibrary : libDebuggingTestJNI.so
Install : libDebuggingTestJNI.so => libs/armeabi/libDebuggingTestJNI.so
- In the Eclipse toolbar, you'll see a green bug. Click the little arrow next to the bug and select "Debug Configurations…".
- Double-click "Android Application" in the tree structure on the left. This will create a template for a new Android Application Debug Configuration.
- In the "Name:" field, name it "DebuggingTest Java Debug" to make sure you know this Configuration applies specifically to the DebuggingTest project, and targets your Java source.
- Under "Project:", click the "Browse…" button and select DebuggingTest.
- Click "Apply" to save your changes.
- Click "Close".
- In the Eclipse toolbar, click the little arrow next to the bug and select "Organize Favorites…".
- Click "Add…"
- Select "DebuggingTest Java Debug" and click "OK".
In the Eclipse toolbar, click the little arrow next to the bug and select "DebuggingTest Java Debug". This will deploy and install the DebuggingTest.apk to your connected Android device and start the debugger.
Navigate to the DebuggingTest project directory in your Terminal and type the following:
ndk-gdb
GNU gdb 6.6Copyright (C) 2006 Free Software Foundation, Inc.GDB is free software, covered by the GNU General Public License, and you arewelcome to change it and/or distribute copies of it under certain conditions.Type "show copying" to see the conditions.There is absolutely no warranty for GDB. Type "show warranty" for details.This GDB was configured as "--host=x86_64-linux-gnu --target=arm-elf-linux".(no debugging symbols found)…
ERROR: Could not extract PID of application on device/emulator.Are you sure the application is already started?Consider using --start or --launch= if not.If your Android.mk file is malformed or contains $(info) blocks, you get the following:cp: target
./obj/local/armeabi/gdb.setup' is not a directory /home/Dev/NDK/ndk-gdb: 639: cannot create start DebuggingTest/jni/Android.mk end DebuggingTest/jni/Android.mk ./obj/local/armeabi/gdb.setup: Directory nonexistent /home/Dev/NDK/ndk-gdb: 640: cannot create start DebuggingTest/jni/Android.mk end DebuggingTest/jni/Android.mk ./obj/local/armeabi/gdb.setup: Directory nonexistent start: invalid option: -x Try
start --help' for more information.
ERROR: Another debug session running, Use --force to kill it.
ndk-gdb
不仅确保我们到目前为止所做的一切都是正确的,而且还创建了
app_process
,
gdb.setup
和
libc.so
我们项目的 obj/local/armeabi/子目录中的文件。在后面的步骤中将需要这些文件。
- In your Terminal, type CTRL+Z to stop ndk-gdb.
- In Eclipse, select Run → Terminate.4. Create C/C++ Debug Configuration. We need to create a debug configuration for stepping into C/C++ source code.
- In Eclipse, click the little arrow next to the bug and select "Debug Configurations…".
- Double-click "C/C++ Application" in the tree structure on the left. This will create a template for a new C/C++ Application Debug Configuration.
- In the "Name:" field, name it "DebuggingTest C and CPP Debug" to make sure you know this Configuration applies specifically to the DebuggingTest project, and targets your C/C++ source.
- In the "Main" tab:
- Click "Browse…" on the "C/C++ Application:" field.Navigate to "/home/Test/testing/DebuggingTest/obj/local/armeabi/app_process" and click "OK".
- Click "Browse…" on the "Project:" field.
- Select "DebuggingTest" and click "OK".
- Check the "Disable auto build" box.
- At the bottom of the form, you'll see "Using GDB (DSF) … - Select other…". Press the "Select other…" button.
- In the pop-up, check the "Use configuration specific settings" box.
- Select "Standard Create Process Launcher" in the list and press "OK".
- In the "Debugger" tab:
- Click the combo-box on the "Debugger:" field and select "gdbserver".
- Uncheck the "Stop on startup at:" box.
- In the "Main" sub-tab:
- Click "Browse…" on the "GDB debugger:" field.
- Navigate to "/home/Dev/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gdb" and click "OK". This debugger is distributed with the Android NDK.
- In the "GDB command file:" field, type "/home/Test/testing/DebuggingTest/obj/local/armeabi/gdb2.setup". The gdb2.setup file does not exist yet, but we'll create it shortly.
- Check the "Use full file path to set breakpoints" box.
- In the "Connection" sub-tab:
- Set "Type:" to TCP
- Set "Port number:" to 5039
- Click "Apply" to save your changes.
- Click "Close"
- In the Eclipse toolbar, click the little arrow next to the bug and select "Organize Favorites…".
- Click "Add…"
- Select "DebuggingTest C and CPP Debug" and click "OK".
- In your File Explorer, navigate to "/home/Test/testing/DebuggingTest/obj/local/armeabi/".
- Copy the "gdb.setup" file and then paste it into the same folder. The result should be a file named "gdb (copy).setup".
- Rename "gdb (copy).setup" to "gdb2.setup".
- Open gdb2.setup by double-clicking the file.
- Replace "set solib-search-path ./obj/local/armeabi" with "set solib-search-path /home/Test/testing/DebuggingTest/obj/local/armeabi".
- Replace "file ./obj/local/armeabi/app_process" with "file /home/Test/testing/DebuggingTest/obj/local/armeabi/app_process".
- Remove the line that reads "target remote :5039".
- Save and Close the file.5. Create ndk-gdb-eclipse. One last Eclipse housekeeping item. Eclipse will run the gdb binary itself, so we have to remove the execution of gdb from ndk-gdb. We'll save the original content by doing another Copy-Paste-Rename.
- In your File Explorer, navigate to "/home/Dev/NDK".
- Copy the "ndk-gdb" file and then paste it into the same folder. The result should be a file named "ndk-gdb (copy)".
- Rename "ndk-gdb (copy)" to "ndk-gdb-eclipse".
- Open ndk-gdb-eclipse by doing a right-click → Open With Other Application …
- Select Text Editor from the list of applications
- In the file, locate the line that reads "$GDBCLIENT -x
native_path $GDBSETUP
" (probably at the very bottom) and comment it out by prefixing it with a "#" character.- Save and Close the file.
ndk-gdb-eclipse
而不是
ndk-gdb
.
- Put a breakpoint in the DebuggingTestActivity.java file at line 20 (System.out.println("hello world!")).
- Insert a breakpoint in your main Activity BEFORE any calls into native code are made. onCreate() is generally the best place for this.
- Start the DebuggingTest application in Debug mode by clicking on the little arrow next to the bug and selecting "DebuggingTest Java Debug".
- You'll see a pop-up on the screen labeled "Confirm Perspective Switch". Press "Yes" if you'd like it to switch to your Debug Perspective. I would recommend doing so.
- At this point, you should have hit the breakpoint you set.
onCreate
内功能。此函数将在所有静态之后被调用
loadLibrary
已拨打电话。请注意,在 onCreate 函数之外有一个
System.loadLibrary("DebuggingTestJNI")
静态块内部。此 loadLibrary 调用将在我们输入
onCreate
之前执行函数,确保我们的原生符号在我们到达初始断点时加载。在继续之前,我们必须在断点处停止!
- In your Terminal, navigate to the DebuggingTest directory and type the following command:
ndk-gdb-eclipse
← Remember that we created this file back in step 6- If successful, the command should complete without any response.
- Go back to Eclipse and run your C/C++ debugger by clicking the little arrow next to the bug and selecting "DebuggingTest C and CPP Debug"
- Note: When I do this, I see dozens of errors in my Eclipse console, but things still seem to be working…
- Switch back to your Java Perspective.
- Click the double arrows at the top right of right of your Eclipse window and select Java.
- Open DebuggingTest/jni/com_sample_test_DebuggingTestActivity.cpp
- Set a breakpoint in the first JNI function that will be called by your main Activity.
- Click Run → Resume (F8)
- You'll get the Perspective Switch message again, so feel free to switch back to the Debug Perspective.
关于Android NDK 应用程序无法达到任何断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23987279/
我想使用 ndk 构建一个 3rd 方库 avahi。 avahi 已经有 android 端口(带有有效的 Android.mk)。 我做了什么: 我已经成功创建了一个项目并将所有源代码复制到 jn
由于不再需要Android NDK,因此我尝试将其卸载。在Eclipse中找到的路径似乎已损坏。我应该如何清理这个烂摊子?我尝试了brew,但它说未安装NDK。 (它甚至告诉我未安装SDK!也许不是通
我是 Android Studio 和 Android NDK 的新手。我正在尝试使用 android NDK 为类分配编译一个简单的 hello.c 程序。我已按照以下项目说明进行操作,但出现错误:
当我尝试执行 NDK 构建时,我收到以下错误列表...有人知道吗? encies\FreeImage/D:/Projects.CPP/Engine5/svn/trunk/Dependencies/Fr
我正在使用 android-ndk-profiler-3.1 为我的项目进行 NDK 分析。我在 Android.mk 中进行了如下更改... LOCAL_PATH := $(call my-dir)
我需要使用 cutils 库和头文件在我的 NDK 项目中实现 ashmem,但我在我的系统中找不到与 cutils 相关的任何内容。它位于何处或从何处获得? 最佳答案 Android“cutils”
我有两个独立的项目,一个项目用于构建 Boost 库,另一个项目从构建的 boost 库中调用。 Boost 项目编译良好并生成 libboost.a 文件。我想要实现的是将此库添加到我的其他 NDK
我在ndk-build clean上遇到以下错误 mo@mo-Toshiba ~/Workspace/AndroidApp/jni/android_programming_driver $ ndk-b
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我正在尝试使用 NDK(又使用开放 SLES)在 Android 上创建一个基于流的音频应用程序。我已经完成了基本的流媒体设置。我需要知道 Android 中如何处理欠载(或重载)?错误回调是如何实现
我的 Application.mk 设置为构建 arm 以及 x86 共享库: APP_ABI :- armeabi-v7a x86 我有预建的 openssl 静态库: libcrypto_v7a.
我的 $NDK_HOME 文件夹包含标准库的不同实现。 qdii@nomada /opt/android-ndk/platforms $ ls -l total 24 drwxr-xr-x 5 roo
如何安装android-ndk。我已经为 ndk 设置了路径,但在执行“ndk-build”命令时仍然出现错误。 fya 我正在使用 Windows 操作系统。 最佳答案 它对我有用: 打开命令提示符
构建 Android-ndk 时出现以下错误 请帮助我。 Cygwin.bat @echo off set IS_UNIX= set DEV_ROOT=C:/iliu-Android-NDK-Fibo
我开始使用 android ndk (r8c),为此我安装了新版本的 Ubuntu 12.10 (32bit) 问题,无论我尝试构建什么,我都会遇到让我发疯的怪异错误...... ~/workspac
我正在尝试向我的 Android 项目添加 Crashlytics 支持,该项目使用 NDK 和 gradle CMake。这意味着我的共享项目需要符号。所以如果我想为发布版本创建符号,我会调用 gr
我想知道是否有人设法使用 Android NDK(r8d) 的工具链构建了新的 SDL2。 SDL2 似乎非常接近发布(从昨天开始,它不再是“正在 build 中:http://hg.libsdl.o
我试图在“ndk-build”过程中禁用所有警告,以编译与 Android 上的 JNI 一起使用的 CPP 代码。 我正在使用 LOCAL_CFLAGS := -Wno-error没有成功。 有任何
谁能告诉我如何在android(ndk-build)中建立C-ares库 最佳答案 这是使用NDK standalone toolchain将其构建为ARMv7的静态库的方法: export NDK=
我正在尝试从我的 native 代码中读取一个简单的文本文件。 我把file.txt放在assets文件夹下 在我的事件中,我正在创建 Assets 管理器:assetManager = getAss
我是一名优秀的程序员,十分优秀!