2

i want to integrate car-ui-lib into my project. i manually create Android.mk in (src/main/jni) file from this google git After i build my project the android studio create cpp folder and add my Android.mk file there by using this piece of code in build.gradle module.

   sourceSets { main {
        res.srcDirs = ['src/main/res']
    } }

    externalNativeBuild {
        ndkBuild {
            path "src/main/jni/Android.mk"
        }
    }

    useLibrary 'android.car'

Now the issue is, the car-ui components still not show, i try these imports:

import com.android.car.ui.toolbar.TabLayout;
import com.android.car.ui.core.CarUi;

but still it says "Cannot resolve symbol ui"

I also try below Android.mk code but the issue remains the same.

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
CAR_UI_RRO_SET_NAME := oem
LOCAL_MODULE := car-ui
CAR_UI_RESOURCE_DIR := $(LOCAL_PATH)/res
CAR_UI_RRO_TARGETS := $(CAR_UI_RRO_PACKAGE_NAMES)
CAR_UI_GENERATE_RRO_SET := $(call my-dir)/generate_rros.mk
LOCAL_STATIC_ANDROID_LIBRARIES := car-ui-lib
include $(BUILD_STATIC_LIBRARY)

I also tried their official documentation but still nothing works. Any tutorial/help would be appreciated :)

Muhammad Saad
  • 713
  • 1
  • 9
  • 31
Tara
  • 692
  • 5
  • 23

2 Answers2

1

Android.mk/Android.bp are makefiles of AOSP build system, they are not compatible with Android Studio (or Gradle). With the former you build Android OS and system apps, with the latter you build regular apps.

What you need to do is to create a new folder in AOSP tree and build it from here. You can start by copying that paintbooth test app (don't forget to change package name). Then you can build the app through "make YourPackageName" and push to your device with "adb root && adb remount && adb sync". Please note this requires building and flashing your entire own system image first (doing and flashing a full AAOS build).

twasilczyk
  • 186
  • 4
  • so, how i can embedded my custom folder into emulator? can you send me the kick start tutorial for AOSP? i really don't understand how to structured my project. – Tara Mar 15 '21 at 14:42
0

While this line useLibrary 'android.car' in your Gradle config will allow you to use the car-ui-lib, there are still many apis that aren't available in the public version. The car-ui-lib is still under hard development I believe, so if you really need to use code from your Android Studio project, you will need to use the car-ui-lib jar that you can find when you build the AAOS. You can find it under this path:

out/target/common/obj/JAVA_LIBRARIES/android.car_intermediates/classes.jar

If you move your project from Android Studio to the platform, then you will be able to use those apis, given that you have the right configuration in your makefile: LOCAL_STATIC_ANDROID_LIBRARIES := car-ui-lib.

narko
  • 3,645
  • 1
  • 28
  • 33