简体   繁体   中英

AOSP build failure using soong

I am trying to build an Android Open Source Project automotive image with a preinstalled system application using soong. The android system application is written in Kotlin.

Android.bp

android_app {
    name: "CarApp",

    srcs: ["src/**/*.kt", "src/**/*.java"],

    resource_dirs: [
     "res/"
    ],

    libs: [
     "telephony-common",
    ],
    certificate: "platform",
    privileged: true,
    platform_apis: true,
    optimize: {
        enabled: false,
    },
    dex_preopt: {
        enabled: false,
    },
    static_libs: [
     "android.car",
        "androidx.recyclerview_recyclerview",
        "androidx.recyclerview_recyclerview-selection",
        "androidx.preference_preference",
        "androidx-constraintlayout_constraintlayout",
        "android-support-design"
     ],

     
     plugins: ["dagger2-compiler-2.19"],

}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.media.mycarapp">

    <uses-feature
        android:name="android.hardware.type.automotive"
        android:required="true" />

    <uses-permission android:name="android.car.permission.CAR_SPEED" />
    <uses-permission android:name="android.car.permission.CAR_POWERTRAIN" />
    <uses-permission android:name="android.car.permission.CAR_ENERGY" />

    <application 
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
        <activity android:name=".SetupOptionsList"></activity>
        <activity android:name=".StatusActivity"></activity>
        <activity android:name=".SetupActivity"></activity>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

When I try to build using these files, I get

/out/soong/.intermediates/packages/apps/Car/CarApp/CarApp/android_common/manifest_fixer/AndroidManifest.xml:21:18-86 Error:
    Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from AndroidManifest.xml:21:18-86
    is also present at AndroidManifest.xml:21:18-91 value=(android.support.v4.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:12:5-23:19 to override.

After adding 'tools:replace="android:appComponentFactory" to AndroidManifest.xml, I get an unbound prefix error when the application is being built. The error is as below.

out/soong/host/linux-x86/bin/manifest_fixer --minSdkVersion 30 --targetSdkVersion 30 --raise-min-sdk-version --extract-native-libs=true --uses-non-sdk-api packages/apps/Car/JulioApp/AndroidManifest.xml o
ut/soong/.intermediates/packages/apps/Car/CarApp/CarApp/android_common/manifest_fixer/AndroidManifest.xml
error: unbound prefix: line 13, column 4 

How to resolve this issue?

@Pie - AOSP is definitely in common domain.

If you are specifically trying to build this code using soong, then this answer is not for you. But below I describe an alternative to doing just that.

You don't need to build kotlin code in AOSP. Build the APK in Android Studio, sign with system certificate, and then create a folder under maybe ~/AOSP/packages/apps/<your-app> and add two files under there. You'll find exact information on many different SO questions on how to add an APK to AOSP. So you'll create your Android.mk file and place that apk file there. In your mk file, you'll mention that it is pre-signed.

Next, you'll add this package name in your device.mk as PRODUCT_PACKAGES += <PACKAGE_NAME> . This is will include that app as a system application on the device. No other steps will be required, and you'll find this app under /system/priv-app as well.

Depending on the situation, you may also need priv-app-permissions.xml and include that like so:

PRODUCT_COPY_FILES += \
                    $(LOCAL_PATH)/root/privapp-permissions-<DEVICE>.xml:system/etc/permissions/privapp-permissions-<DEVICE>.xml

Adding Apps to AOSP Build (Cannot link, but search on SO)

  • How do I add an application in AOSP?
  • How can I add a 3rd-party library to an Android AOSP build?
  • Error when adding external JAR to Android AOSP build
  • How to solve Error: This attribute must be localized. (at 'text' with value 'TOP_LEFT')
  • X (java:sdk) should not link to Y (java:platform)
  • Adding a jar file from libs/ to Android.mk
  • Add one android project as a library in AOSP App
  • Default Launcher: How do I set the default launcher in an AOSP build?
  • Add native service to aosp
  • Building a particular module in the android source code
  • Dependencies between 2 Android.mk files

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM