Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problems in NDK Development

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you how to solve problems in NDK development, concise and easy to understand, definitely will make your eyes shine, through the detailed introduction of this article I hope you can gain something.

1. Early ndk development is mainly in the open source project reuse project makefile, etc., you need to modify the specified CC or C++ compilation chain; the specific situation also depends on the project config file;

For simple projects, you can write Android.mk directly; for example, the introduction of GTest and GMock;

Re-create Android.mk, use ndk-build to generate.a file, and introduce the new ndk project together;

In addition, under Gmock; for mock functions, inheritance classes are also needed, which is much more difficult to use than mock on Linux;

In addition, Gtest does not support the judgment of static objects. For assignment within functions, global objects cannot be expected, and only output parameters or return values can be judged.

JNI calls

C++ callback java, different threads according to Jvm to re-acquire env no need to explain more

g_JavaVM->GetEnv((void **)&envnow

g_JavaVM->AttachCurrentThread(&envnow

When saving class objects; g_DMClass = env->findclass ("/com/example/controller") Not even if g_DMClass is global; stable local ref encountered; jclass tmp = env->findclass required ("/com/example/controller");g_DMClass = (jclass)env->NewGlobalRef(tmp); However, in the child thread encountered FIndClass empty problem, always did not find a suitable explanation, some articles mentioned is the child thread class lookup mechanism problem, but did not provide an accurate solution to the above content is how to solve NDK development problems, you learned knowledge or skills? If you want to learn more skills or enrich your knowledge reserves, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report