NDK Single-Step commissioning

Source: Internet
Author: User

Reprint:


Recently because the project needs to use the NDK, the only trouble is the Java and the C-side of the joint, a lot of search on the Internet, said to use GDB or print logs, so the debugging efficiency is very low, Also very inconvenient. Let's share a simple way to debug a visual interface in a single step. Development environment, I was downloaded on the official website of the latest Integrated ADT+SDK+CDT development tool "Adt-bundle-windows-x86-20130522.zip"
Ndk I was using the "android-ndk-r8e". The building of the environment is free. There are many examples online. Let me just take an example of what has been written, assuming that your JNI files are already written,
the first step, and the project is converted to C + +. Works right--"new--" other. According to the mark of Figure 1, figure 2, the direct finish can be
The second step, the right of the project-"properties--" C + + Build. Settings refer to Figure 3. Then set up C + + general, set reference Figure 4.
Third step, project right-->android tools--"ADD support liberary
Fourth step, set breakpoints in Jni C, then project Debug as--" Android Native Applications can be run. The so file is automatically compiled into the corresponding directory and does not need to be compiled with other tools.
A few points to note. I encountered an error in the place. Will prompt Android for inconsistent errors. , you can add "app_platform: = android-<8>" 8 in the Mk file corresponds to the minimum version set in your Androidmanifest.xml file. The
is also likely not to enter a breakpoint because you entered the breakpoint too early. You can get a button or something, write the function that calls JNI in the button response time, wait for the project to run for about 35 seconds, then click button to trigger the event.
There is one more thing. To remember to add the NDK path, window--"preferences--" android--"NDK, if there is no NDK option, install a NDK plugin will have, haha.

If nothing happens, you can step up. Time is more hurried, writing is relatively simple, it may be more cumbersome, free and perfect.



Java, development, online, project

1.jpg (47.28 KB, download number: 33)

Figure 1

2.jpg (74.33 KB, download number: 25)

Figure 2

3.jpg (123.45 KB, download number: 26)

Figure 3

4.jpg (139.25 KB, download number: 23)

Figure 4

5.jpg (240.23 KB, download number: 24)

Figure 5




1. After doing so, the following error is reported: Error while setting up port forwarding
Com.android.ddmlib.AdbCommandRejectedException:cannot bind to socket:no error Google check all kinds of information, took 2 hours, the results restart the computer, just fine, hey.
2. In the JNI layer breakpoint can sometimes go in, sometimes do not go in, but also very card, the effect is not good, and eventually hit log
The. CPP code for the 3.JNI layer appears with the following error:


Solution: The introduction of the jni.h can be (no definition), the specific approach to refer to the second step.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.