0

I have a system app that I am building using Android.mk. In my app layout, I want to use AppBarLayout from com.google.android.material. Here is the Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_PACKAGE_NAME := ServiceTool
LOCAL_MODULE_OWNER := XXXXXX
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_PRIVATE_PLATFORM_APIS := true
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_DEX_PREOPT:=false

LOCAL_USE_AAPT2 := true

LOCAL_STATIC_ANDROID_LIBRARIES := androidx.fragment_fragment \
                                  androidx.appcompat_appcompat \
                                  androidx-constraintlayout_constraintlayout \
                                  androidx.legacy_legacy-support-v4 \

LOCAL_STATIC_JAVA_LIBRARIES := android.hardware.light-V2.0-java \
                                open-csv \
                                classestool \
                                material-1.0.0 \
                                libdiagwrapper 


LOCAL_MANIFEST_FILE := AndroidManifest.xml

LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res

LOCAL_SRC_FILES     := $(call all-subdir-java-files) \

include $(BUILD_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))


###################JARLIB
include $(CLEAR_VARS)

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
open-csv:libs/opencsv-4.6.jar \
classestool:libs/classes.jar \
material-1.0.0:libs/material-1.0.0.aar \
libdiagwrapper:libs/libdiagwrapper.jar \

   include $(BUILD_MULTI_PREBUILT)
###################

I added the file material-1.0.0.aar in a folder libs. It compiles well. However, when I am going to the Activity using the AppBarLayout in its layout, the app crash and I am getting this exception:

12-26 16:07:23.746 12686 12686 E AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class com.google.android.material.appbar.AppBarLayout 12-26 16:07:23.746 12686 12686 E AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class com.google.android.material.appbar.AppBarLayout 12-26 16:07:23.746 12686 12686 E AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at java.lang.reflect.Constructor.newInstance0(Native Method) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:343) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:647) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:467) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at com.motorolasolutions.servicetesttool.tests.ltetests.LteTestActivity.onCreate(LteTestActivity.java:206) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7144) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7135) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2932) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3087) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1817) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6746) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 12-26 16:07:23.746 12686 12686 E AndroidRuntime: Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/material/R$style;

Where does it come from?

Bazouk55555
  • 557
  • 6
  • 24

0 Answers0