I am building a blank project in Eclipse with the Oculus Mobile VR SDK. I am getting the following error:
Android NDK: Trying to define local module 'vrapi' in jni/../../../../../../VrApi/Projects/AndroidPrebuilt/jni/Android.mk.
Android NDK: But this module was already defined by jni/../../../../../../VrApi/Projects/AndroidPrebuilt/jni/Android.mk.
Looks like that Android.mk is somehow included twice. I'm using Oculus Mobile VR SDK 0.6.2.0. The following projects are included in my Eclipse workspace:
LibOVRKernel_Prebuilt
MediaSurface
VrApi_Prebuilt
VrAppFramework_Prebuilt
VrGUI
VrLocale
VrSound
Tried re-creating the workspace twice, but still the same error. How can vrapi module be included twice? The only Android.mk where it says
LOCAL_MODULE := vrapi
is in VrApi_Prebuilt and nowhere else.
Thanks
I fixed this by modifying Android.mk inside VrApi_Prebuilt in the following way.
I added
include $(BUILD_SHARED_LIBRARY)
right before the following block:
ifneq (,$(wildcard $(LOCAL_PATH)/$(LOCAL_SRC_FILES)))
include $(PREBUILT_SHARED_LIBRARY)
endif
I removed .so extension from
LOCAL_SRC_FILES := ../../../Libs/Android/$(TARGET_ARCH_ABI)/lib$(LOCAL_MODULE).so
Hence, the line becomes
LOCAL_SRC_FILES := ../../../Libs/Android/$(TARGET_ARCH_ABI)/lib$(LOCAL_MODULE)
Related
CommandInvokationFailure: Unable to merge android manifests. See the Console for more details.
C:/Program Files/Java/jdk1.8.0_161\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:/Users/Sabasoft Developer/Downloads/tools_r25.2.3-windows\tools" -Dfile.encoding=UTF8 -jar "D:\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -
stderr[
]
stdout[
Warning: [Temp\StagingArea\AndroidManifest-main.xml:12, D:\unity projects\Pizza maker\Temp\StagingArea\android-libraries\GooglePlay\AndroidManifest.xml:3] Main manifest has but library uses targetSdkVersion='24'
]
exit code: 1
Update Java SdK
Update Android SdK
Check target in menifest file and Unity editor. Both should be same.
Remove duplicate .jar under plugins folder if there are any.
You are using a library somewhere in your code (possibly something for GooglePlay?). The library has a manifest.xml file that is likely located in a folder called plugin or one of its subfolders.
The manifest is the file used by android to describe the app: how it starts, what permissions it has, and so on.
Any android project in unity will include a default manifest.xml file. This file is edited by unity with some info relative to you game (the name, and the target version, are part of it).
Now, the libraries you include in your project might need different options and values in the manifest, so Unity libraries for android usually come with another manifest.xml file. This will will be automatically merged with the default one by unity at build time.
Usually, it goes well, the additional line in the manifest from the library get added to the default manifest.
But in your case, there is a conflict between these manifests. The target version is specified both in the library and in your project. So unity can't resolve it.
To fix this, use a target version for your project that is the same or higher than the one of the library. Edit your target version under player settings
We are trying to develop a custom ROM using AOSP's master branch. We have successfully built and run the compiled image on the emulator provided by AOSP.
Now we are trying to add an application in the AOSP so that the AOSP branch compiles and runs with the application present in it, that means when we run the android version our newly added application will act as a default/system application.
We have tried doing that using following steps, but have failed:
Place the App_name folder to /packages/apps
Add Android.mk to /packages/apps/App_name/
Add App_name entry to /build/target/product/core.mk
PRODUCT_PACKAGES := \
... \
SomeApp \
App_name
Note: App_name is the application folder that is developed using android studio and is present the Android-Studio Projects folder.
After performing these steps we compile the entire source code/AOSP and eventually the compilation fails.
Could someone please help me out??
For adding a default application to AOSP , You should create a directory with arbitrary name in packages/apps (name of directory doesn't matter) , then you should put necessary code and resources in it . Notice AOSP build system doesn't use Gradle ,hence you don't need to copy gradle build files (like build.gradle and setting.gradle and etc).
For a typical app you should create these directories :
src : place your java codes here .
res : place your resources directory for examle drawable , layout , ...
assets : if your project has any assests file , place them in this folder
Your AndroidManifest.xml file should be added in top of your directory.After placing your code and resources , create an Android.mk file and write the following lines in it :
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := <Name of your app>
LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Include libraries
LOCAL_JAVA_LIBRARIES := <Java lib dependencies>
LOCAL_STATIC_JAVA_LIBRARIES := android-common
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-appcompat
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_ASSETS_DIR := $(LOCAL_PATH)/assets
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.appcompat
include $(BUILD_PACKAGE)
LOCAL_PACKAGE_NAME is name of your app (for examle camera , app1 , ...) ,you should add this name to /build/target/product/core.mk (no folder name , folder name is not important) .
LOCAL_SRC_FILES is pointer to Java codes.
LOCAL_JAVA_LIBRARIES : if your project has java lib dependency , reference to it here.
LOCAL_RESOURCE_DIR is address of res directory
LOCAL_ASSETS_DIR is address of assets directory
Finally build your app and add it to system image . use these commands
make <name of your app>
make snod
<name of your app> is value of LOCAL_PACKAGE_NAME in your Android.mk file. You don't need to build whole AOSP build tree using something like make -j8 . Just build your app and add it to system image. Default applications are placed in read only system partition.
I searched how to use to_string() in android ndk. After a long search, from this link, i changed the Application.mk file as said. And the cpp source compiled and build properly only from the terminal.
Terminal output :
> ndk-build
Android NDK: WARNING: APP_PLATFORM android-21 is larger than android:minSdkVersion 9 in
/<some path>/Android/Exercise01/AndroidManifest.xml
[armeabi-v7a] Install : libndkfoo.so => libs/armeabi/libndkfoo.so
But in ecplise IDE, still i am getting error as "Function 'to_string' could not be resolved". So from the IDE i am not able to run the android application. (Note : before the usage of std::to_string, the source compiled properly)
I tried to include the header files as below (under project properties->C/C++ general->Path and Symbols->GNU C++)
vstring.h from //android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.9/include/ext
&
basic_string.h from //android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.9/include/bits
But no luck.
Androi.mk File
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
TARGET_PLATFORM := android-21
TARGET_ARCH_ABI := armeabi-v7a
TARGET_ABI := android-21-armeabi-v7a # concatenation of above two variables
# Here we give our module name and source file(s)
LOCAL_MODULE := ndkfoo
LOCAL_C_INCLUDES := $(LOCAL_PATH)/header
LOCAL_SRC_FILES := src/NativeFunction.cpp src/clsArithmeticParser.cpp
include $(BUILD_SHARED_LIBRARY)
Application.mk
#APP_STL := stlport_static
APP_STL:=c++_static
I know, i am doing some small mistake, but not able to find for a long time. Any solution/suggestion appreciated.
Edited :
I am able use the std::to_string & std::stoll through eclipse in the below trick only. These can help some one in rare situation. So adding this point to test the c++11 support through eclipse IDE. The error shown only when the source file or the header file opened. Just close open source file documents (.h, .c, .cpp). Close and reopen the eclipse. Now it is ready to compile and run through the android emulator.
What version of Eclipse IDE do you use? Try to update to the latest Mars version, it may fix your problem.
After referring the answer by #Khaled Lakehal, I myself posting this answer for my question.Hope this may help someone.
Followed the below step to make it work:
Update the eclipse version from Luna to latest Mars 2
Imported the existing project from the old version of the eclipse
using -> import -> Existing Android code into Workspace
Had some problem with the C/C++ project conversion after import. So followed this link to undo the C/C++ project conversion
Converted the project to C/C++ newly.
To remove the error, I referred this link, and selected the "Run with build" only
Close & Reopen the IDE
So now able to use the std::to_string & std::stoll functions.
I have built a C++ shared library with NDK builder in Eclipse (firestly creating a JNI project with no MainActivity), which provided as output the different platforms that I have specified in the Application.mk file. The output is in the /obj/local/ directory, spread over the platforms subdirectories (armabi, mips, ... i.e. all the platforms that I have specified in the above file).
Now, I want to use this shared library inside an Android native project, where my shared library is called inside a project's native library (therefore it is about "native-calling-native").
If I build both the shared library and the Android native aplication for just one type of platform (let's say "armeabi"), everything works fine.
My question is how to create the make files, Android.mk and Application.mk, of the Android native project so that to build for ALL the platforms.
I suppose the key is in the Android.mk file, which, for just one platform build it looks like this (on Linux, for the .so type, C++11 for info):
LOCAL_PATH := $(call my-dir)
# Define the shared library module used by the calling JNI C++ module
include $(CLEAR_VARS)
LOCAL_SRC_FILES := libs/libCreateSharedWithJni.so
LOCAL_MODULE := CreateSharedWithJni
LOCAL_EXPORT_C_INCLUDES := libs/CreateSharedWithJni.h
include $(PREBUILT_SHARED_LIBRARY)
# Define the calling JNI C++ module
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_MODULE := finalmodule
LOCAL_SRC_FILES := CppJniCallShared.cpp
LOCAL_SHARED_LIBRARIES := libCreateSharedWithJni
include $(BUILD_SHARED_LIBRARY)
Thanks!
Got it!
In the above Android.mk file just change the line as following
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libCreateSoWithJni.so
i.e. using the $(TARGET_ARCH_ABI) in the path drives the builder to process all platforms specified in the Application.mk APP_ABI variable.
I use Android NDK with cygwin with Eclipse on Windows.
In my makefile I want to set path of prebuild library using environment variable in eclipse.
So I do the following:
And in makefile:
LOCAL_SRC_FILES = $(QCAR_SDK_ROOT)build/lib/$(TARGET_ARCH_ABI)/libQCAR.so
LOCAL_EXPORT_C_INCLUDES := $(QCAR_SDK_ROOT)build/include
But I get error:
Android NDK: ERROR:jni/Android.mk:QCAR-prebuilt: LOCAL_SRC_FILES points to a missing file
/cygdrive/d/Development/Android/android-ndk-r7/build/core/prebuilt-library.mk:43: *** Android NDK: Aborting . Stop.
make: *** [all] Error 2
Android NDK: Check that jni//cygdrive/D/Development/Android/qcar-android-1-5-4-beta1/build/lib/armeabi/libQCAR.so exists or that its path is correct
Tried defining variable in makefile directly, got the same result.
So, obviously, that path is not what I wanted. How do I set the proper path?
Why not just specify the paths in the make file? (N.B Just noticed you tried that.)
Using Cygwin with Android NDK
This site seems to indicate that the make file won't run correctly within Eclipse and you should run in via Windows Explorer. Are you running this within Eclipse? Try this and see if you still get the issues.
That's a problem of the previous NDK builds that Google fixed with NDK-9. "Updated ndk-build to support absolute paths in LOCAL_SRC_FILES."
See the release notes here:http://developer.android.com/tools/sdk/ndk/index.html
Try to play with LOCAL_PATH variable. As documentation (docs/ANDROID-MK.html in Android NDK package, or here) states:
LOCAL_SRC_FILES
This is a list of source files that will be built for your module.
Only list the files that will be passed to a compiler, since the
build system automatically computes dependencies for you.
Note that source files names are all relative to LOCAL_PATH and
you can use path components
Also, NDK hints you to Check that jni//cygdrive/D/Development/Android/qcar-android-1-5-4-beta1/build/lib/armeabi/libQCAR.so exists or that its path is correct.
Thus, I would try the following:
LOCAL_PATH := /
...or to reset it at all:
LOCAL_PATH :=
You can edit eclipse.ini file and add it there.
e.g. -DLOCAL_SRC_FILES=/home/user/.../
Or declare a path variable. It is a convenient way of sharing a common location among multiple projects within a workspace.
Hope that help you!
Recent NDK releases on Windows do not need cygwin. Worse, they do not recognize the cygdrive notation. You can simply use
QCAR_SDK_ROOT = D:/Development/Android/qcar-android-1-5-4-beta1
correction absolute paths for LOCAL_SRC_FILES do not work for ndk.r7, and even for r9 the ANDROID-MK.doc does not encourage using absolute paths there.