I found a solution that works for me!
The first hurdle to climb will look something like this: error: package net.mulliken.pinenotenotebook.databinding does not exist
I found that Android Studio automatically generates these files. It was in app/build/generated/data_binding_base_class_source_out/debug/out/net/mulliken/pinenotenotebook/databinding
. In order to incorporate this in my build I made a symbolic link from my Android studio workspace to databinding_src
in my packages folder.
After that it still didn't work because it could not find the view binding package. You will probably get an error like this: error: package androidx.viewbinding does not exist
I found that google has a repo that includes this package and so I cloned it into my AOSP workspace under frameworks
.
[me aosp/frameworks] $ git clone -b studio-main https://android.googlesource.com/platform/frameworks/data-binding data-binding
I then created a new symbolic link from that path into my package directory so that the compiler could find that class:
[me packages/apps/MyAPP] $ ln -s ../../../../frameworks/data-binding/extensions/viewbinding/src/main/java/ androidx_viewbinding_src
At the end of the day my Android.bp
file looks like this:
android_app {
name: "PineNoteNotebook",
static_libs: [
"androidx.appcompat_appcompat",
"com.google.android.material_material",
"androidx-constraintlayout_constraintlayout",
"androidx.navigation_navigation-fragment",
"androidx.navigation_navigation-ui",
],
certificate: "platform",
srcs: [
"./**/*.java",
],
resource_dirs: ["res"],
product_specific: true,
sdk_version: "current",
optimize: {
enabled: false
},
required: ["libpinenote"],
}
And my package tree looks like this:
.
├── Android.bp
├── AndroidManifest.xml -> /home/mulliken/AndroidStudioProjects/PineNoteNotebook/app/src/main/AndroidManifest.xml
├── androidx_viewbinding_src -> ../../../../frameworks/data-binding/extensions/viewbinding/src/main/java/
├── databinding_src -> /home/mulliken/AndroidStudioProjects/PineNoteNotebook/app/build/generated/data_binding_base_class_source_out/debug/out
├── res -> /home/mulliken/AndroidStudioProjects/PineNoteNotebook/app/src/main/res/
└── src -> /home/mulliken/AndroidStudioProjects/PineNoteNotebook/app/src/main/java/
LOCAL_DATA_BINDING := true
but it didn't work for me. – Vories