Can I compile Java code with Android makefile

删除回忆录丶 提交于 2019-12-20 05:53:47

问题


I'm investigate about Android makefile. Here are the code and Android.mk

#include <iostream>

int main()
{
    std::cout << "Hello World!" << std::endl;
    return 0;
}
------------------------------------------------
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
        hello.cpp
LOCAL_MODULE:= hello
include $(BUILD_EXECUTABLE)

In command line i run $ndk-build --> generate executable file. It successfully.

Then my project leader ask me about using Android makefile with Java source code. I create Main.java and Android.mk. I replace hello.cpp with Main.java then $ndk-build. But it doesn't work.

Could anyone help me the Android.mk file what command line should i use? --------------------------Other question-------------------------------------

"The Android NDK is a set of tools that allows Android application developers to embed native machine code compiled from C and/or C++ source files into their application packages".

When I use source with .c or .cpp, then run ndk-build to compile executable or library file. As I understand, for java source code, we need other tool SDK/JDK to compile.

But can I use Android makefile to compile Java code, are there any command like jdk-build? Do I need use JNI moethod in Java source code? Because if I generate Java codeonly, then run $ndk-build. it generate output file but there is warning

Android NDK: Unsupported source file extension

来源:https://stackoverflow.com/questions/59385354/can-i-compile-java-code-with-android-makefile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!