Trying to add androidx.viewpager2 to android.mk as below:
LOCAL_STATIC_ANDROID_LIBRARIES += \
androidx.viewpager2_viewpager2
Not able to build code using MMA command and gives below error.
ninja: error:
'out/target/common/obj/JAVA_LIBRARIES/androidx.viewpager2_viewpager2_intermediates/package-res.apk',
needed by
'out/target/product/apps/obj/APPS/app_intermediates/package-res.apk',
missing and no known rule to make it
05:31:24 ninja failed with: exit status 1
failed to build some targets (05:38 (mm:ss))
How can I add androidx.viewpager2 to Android.mk Makefile.
You'll have to add viewpager2-1.0.0.aar into LOCAL_STATIC_JAVA_LIBRARIES (or LOCAL_STATIC_JAVA_AAR_LIBRARIES).
Add following blocks to support/sync with .AAR library file in Android.mk file
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
.
.
LOCAL_PACKAGE_NAME := App_Name
.
LOCAL_PRIVATE_PLATFORM_APIS := true
.
LOCAL_STATIC_JAVA_LIBRARIES := AAR_file-alias
.
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := AAR_file-alias:lib_path/AAR_file.aar
include $(BUILD_MULTI_PREBUILT)
Related
guys,
My XXX.mk for building the Android executable XXX describes like this:
...
LOCAL_STATIC_LIBRARIES := \
libYYY
LOCAL_MODULE := XXX
LOCAL_PROPRIETARY_MODULE := $(ENABLE_VENDOR_MODULE)
LOCAL_32_BIT_ONLY := true
include $(BUILD_EXECUTABLE)
It is the same directory with the prebuilt libYYY.a and an Android.mk like this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/XXX.mk
When executing mm command,
I got the following error:
FAILED: XXX.mk: error: "XXX(EXECUTABLES android-arm) missing libYYY
(STATIC_LIBRARIES android-arm)"
The error is still there even I tried to change LOCAL_STATIC_LIBRARIES to libYYY.a or YYY.
Any suggestion?
I am trying to add external JAR files (e.g., gson or eventbus) to my AOSP build. I tried it in two different ways:
Adding them to prebuilts/misc/common/mylibs/ and creating a Android.mk file for the dir. Then, I merely include the symbolic name of the lib in my app's Android.mk file.
Adding them in a subdir libs in my custom app source code and add it via the app's Android.mk file directly.
However, both approaches are yielding me similar errors, the following for the second method:
ninja: error: 'packages/apps/Car/MyApp/packages/apps/Car/Myapp/libs/gson-2.6.2.jar', needed by 'out/target/common/obj/JAVA_LIBRARIES/gson_intermediate/classes.jack', missing and no known rule to make it.
I noticed the weird repeating path in the error message. Does anybody have an idea what I am doing wrong?
Here is my Android.mk file for the second way:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_PACKAGE_NAME := MyApp
LOCAL_CERTIFICATE := platform
LOCAL_MODULE_TAGS := optional
LOCAL_PRIVILEGED_MODULE := true
LOCAL_STATIC_JAVA_LIBRARIES += jsr305 gson
LOCAL_STATIC_ANDROID_LIBRARIES := android-support-v4
LOCAL_USE_AAPT2 := true
include packages/apps/Car/libs/car-stream-ui-lib/car-stream-ui-lib.mk
include packages/services/Car/car-support-lib/car-support.mk
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := gson:$(LOCAL_PATH)/libs/gson-2.6.2.jar
include $(BUILD_MULTI_PREBUILT)
Removing $(LOCAL_PATH) from the path fixed it.
I tried to include a prebuilt google apk (with no .so file) to my marshmallow AOSP build based on the information found in this link as follows:
In my vendor/manufacturer/device/proprietary/system/app, I created a folder named 'Testapk'.
I saved two files in this 'Testapk' folder, the apk ('Testapk.apk') and an Android.mk file which contains the following instructions:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := Testapk
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
I added the following instruction in my vendor/manufacturer/device/vendor_device.mk :
PRODUCT_PACKAGES += \
Testapk
When making the AOSP build, I get the following error:
make: *** No rule to make target `/Testapk', needed by `out/target/product/mako/obj/APPS/Books_intermediates/Testapk.apk'. Stop.
#### make failed to build some targets (01:00 (mm:ss)) ####
The problem with my Android.mk file was that it had trailing spaces on each line. Everything worked fine after I deleted these trailing spaces.
after the \ the "testapk" should be on a new line.
PRODUCT_PACKAGES += \ Testapk
I am trying to build an application and an interface jar using the android build system in Linux
My application has a dependency with my interface, hence I have to make interface jar ready before application make.
But we faced build/run time issues while using our newly built interface jar.
I have tried to make the application in two different sequence.
Case 1. Building the interface as local module and linking it with apk as LOCAL_JAVA_LIBRARIES.
Case 2. Building the interface as local module and linking it with apk as LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES.
Following are the Android.mk files for main and interface.
1.Main Andriod.mk file:
/source/Android.mk
=======================================
STACK_PATH:= $(call my-dir)
LOCAL_PATH := $(STACK_PATH)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/interface/Android.mk
include $(CLEAR_VARS)
LOCAL_PATH := $(STACK_PATH)
include $(LOCAL_PATH)/application/Android.mk
=======================================
2.Interface Android.mk :
/source/interface/Android.mk
=======================================
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files, src)
LOCAL_MODULE := MyInterface
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_JAVA_RESOURCE_DIRS := src
include $(BUILD_JAVA_LIBRARY)
$(call dist-for-goals, droidcore, $(full_classes_jar):MyInterface.jar)
=======================================
Following are the Android.mk files for application in CASE 1.
Application Android.mk:
/source/application/Android.mk
=======================================
TOP_LOCAL_PATH:= $(call my-dir)
LOCAL_PATH:= $(TOP_LOCAL_PATH)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := MyApplication
LOCAL_JAVA_LIBRARIES := MyInterface
include $(BUILD_PACKAGE)
include $(BUILD_MULTI_PREBUILT)
=======================================
Build completed successfully .But when trying to run this application, it shows this error.
I/dalvikvm( XXXX): Failed resolving Lcom/test/example/application; interface XXX 'Lcom/test/example/interface;'
W/dalvikvm( XXXX): Link of class 'Lcom/test/example/application;' failed
Following are the Android.mk files for application in CASE 2.
Application Android.mk
/source/application/Android.mk
=======================================
TOP_LOCAL_PATH:= $(call my-dir)
LOCAL_PATH:= $(TOP_LOCAL_PATH)
include $(CLEAR_VARS)
$(shell (cp $(LOCAL_PATH)/../out/target/common/obj/JAVA_LIBRARIES/Interface_intermediates/classes-jarjar.jar $(LOCAL_PATH)/applications/libs/MyInterface.jar ))
LOCAL_STATIC_JAVA_LIBRARIES += MyInterface
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := MyApplicationss
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += MyInterface:libs/MyInterface.jar
include $(BUILD_PACKAGE)
include $(BUILD_MULTI_PREBUILT)
=======================================
This resulted in a build error as follows.
build/core/base_rules.mk:166: * source/applications: MODULE.TARGET.JAVA_LIBRARIES.MyInterface already defined by source/interface. Stop.
But when they are built seperately without using the build system, this problem is not there.Also the application runs without error.
When the interface was built to Myinterface.jar using the eclipse, and build the application-apk using this
interface jar(by linking statically) in Linux, the application ran smoothly.
Is there any issue in my Android.mk files? Please help
I think you should have LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES between include $(BUILD_PACKAGE) and include $(BUILD_MULTI_PREBUILT)
See another answer .
Follow the link for Android Build System Details
http://www.kandroid.org/online-pdk/guide/build_system.html
when I tried the NDK build command here is the error i got
D:\AndroidWorkSpace\cppTestProj>D:\android-ndk-r8b-windows\android-ndk-r8b\ndk-b
uild.cmd
Android NDK: WARNING: Unsupported source file extensions in jni/Android.mk for m
odule cppTestProj
Android NDK: LOCAL_SRC_FILES :=
"Compile++ thumb : cppTestProj <= maintestapp.cpp
jni/maintestapp.cpp:1:19: fatal error: iostream: No such file or directory
compilation terminated.
make: *** [obj/local/armeabi/objs/cppTestProj/maintestapp.o] Error 1
The JNI folder has the following files:
maintestapp.cpp
Test_array_type.cpp
Test_array_type.h
Could u pls let me know the issue. Im not using Cygwin for the same. Am I missing any files?
Here is the make file
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := cppTestProj
LOCAL_SRC_FILES := LOCAL_SRC_FILES := maintestapp.cpp \
Test_array_type.cpp
include $(BUILD_SHARED_LIBRARY)
here is the cpp file
#include<iostream>
#include"Test_array_type.h"
#include<stdio.h>
#include<conio.h>
using namespace std;
int main()
{
Test_array_type test_array;
Test_array_type *ptest_array1;
test_array.AddToList(10);
test_array.AddToList(20);
test_array.AddToList("Basha");
test_array.PrintList();
ptest_array1 = test_array.clonelist();
test_array.DeleteFromList(3);
test_array.AddToList(10);
test_array.AddToList(20);
test_array.AddToList(30);
test_array.AddToList(40);
test_array.AddToList(true);
test_array.AddToList("Java Beon APP");
test_array.PrintList();
ptest_array1->PrintList();
getch();
return true;
}
you should not run the 'ndk-build' command from your projects jni folder. To execute the Android.mk file run ndk-bild command within your root directory of project.
Your Android.mk should be look like this
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := cppTestProj
LOCAL_SRC_FILES := maintestapp.cpp \
Test_array_type.cpp
include $(BUILD_SHARED_LIBRARY)
Then run your ndk-build command
You can see this link for sample Android.mk file
Update:
static {
System.loadLibrary("hello-jni");
}
for more information please refer HelloJni.java file of sample project.
Thanks
you need to add LOCAL_C_INCLUDES and include your visual C++ include folders, since you are obviuosly working with it.