Home > Mobile >  Android studio the NDK programming
Android studio the NDK programming

Time:11-07

I haven't find out where to look a lot of information, hope to have predecessors directions,
Environment:


Project tree:

Activity_main. XML:

MainActivity:

Arthur c. C file:


Because I just learn to use the NDK development many puzzling problems so I say first my train of thought:
Through jni calls with C language Java local function complete development. You need to create a Java local function and generate a C header file to call,. Mk documents compiled links is mainly to solve the problem, MainActivity is the entrance of the android file, I built the question now is how to call the Java classes to implement the modification of text in TextView,
In activities related with graphics in the android are inherited in AppCompatActivity, in theory, I as long as in my own definition Java classes inherit AppCompatActivity and call to obtain the corresponding objects by ID (TextView TV=the findViewById (R.i which ext);) Then call TV. SetText (get string ());. Method can modify the text,
Also don't know if the idea is right?
If it's right I am MainActivity or self-built javaclass increase the corresponding code:
But I after I self-built javaclass class add code compiled by:

The corresponding error:


I add the code in the MainActivity:

The corresponding error:


Above error I go online to check the material are:

This I have done or

This is my predecessors, please look at my what is the problem if you need any details I can edit supplement advice or tell me what material can solve the problem of I also can if you want to points can add first thanked everybody!

CodePudding user response:

Wow, classmate, you this logic is not a fragment, and Java, it is kotlin,
1. The recommended Java and kotlin don't mix;
2. The NDK, you should pass the jni interface, call C generated so libraries, Android. Mk is C compiler generated so rules of the library, library on how to generate so, suggest you have a good look at the Android website (
3. The activity of Android is the page you want to present, is that you can see, and your javaclass, is a jni interface, do not need to inherit AppCompatActivity,

Interface just write like this,

CodePudding user response:

reference 1st floor can't write code monkey reply:
wow, classmate, you this logic is not a fragment, and Java, it is kotlin,
1. The recommended Java and kotlin don't mix;
2. The NDK, you should pass the jni interface, call C generated so libraries, Android. Mk is C compiler generated so rules of the library, library on how to generate so, suggest you have a good look at the Android website (
3. The activity of Android is the page you want to present, is that you can see, and your javaclass, is a jni interface, do not need to inherit AppCompatActivity,

Interface just write like this,


reference 1st floor can't write code monkey reply:
wow, classmate, you this logic is not a fragment, and Java, it is kotlin,
1. The recommended Java and kotlin don't mix;
2. The NDK, you should pass the jni interface, call C generated so libraries, Android. Mk is C compiler generated so rules of the library, library on how to generate so, suggest you have a good look at the Android website (
3. The activity of Android is the page you want to present, is that you can see, and your javaclass, is a jni interface, do not need to inherit AppCompatActivity,

Interface just write like this,


Cs; package com. Example.

Public class javaclass {
The static {
System. LoadLibrary (" native - lib ");
}

Public native String get String ();

}
Like this?

CodePudding user response:

reference 1st floor can't write code monkey reply:
wow, classmate, you this logic is not a fragment, and Java, it is kotlin,
1. The recommended Java and kotlin don't mix;
2. The NDK, you should pass the jni interface, call C generated so libraries, Android. Mk is C compiler generated so rules of the library, library on how to generate so, suggest you have a good look at the Android website (
3. The activity of Android is the page you want to present, is that you can see, and your javaclass, is a jni interface, do not need to inherit AppCompatActivity,

Interface just write like this,


reference 1st floor can't write code monkey reply:
wow, classmate, you this logic is not a fragment, and Java, it is kotlin,
1. The recommended Java and kotlin don't mix;
2. The NDK, you should pass the jni interface, call C generated so libraries, Android. Mk is C compiler generated so rules of the library, library on how to generate so, suggest you have a good look at the Android website (
3. The activity of Android is the page you want to present, is that you can see, and your javaclass, is a jni interface, do not need to inherit AppCompatActivity,

Interface just write like this,


reference 1st floor can't write code monkey reply:
wow, classmate, you this logic is not a fragment, and Java, it is kotlin,
1. The recommended Java and kotlin don't mix;
2. The NDK, you should pass the jni interface, call C generated so libraries, Android. Mk is C compiler generated so rules of the library, library on how to generate so, suggest you have a good look at the Android website (
3. The activity of Android is the page you want to present, is that you can see, and your javaclass, is a jni interface, do not need to inherit AppCompatActivity,

Interface just write like this,

Thank you for your reply me first javaclass here I've changed

reference 1st floor can't write code monkey reply:
wow, classmate, you this logic is not a fragment, and Java, it is kotlin,
1. The recommended Java and kotlin don't mix; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related