Search code examples
androidandroid-virtual-deviceandroid-automotive

Is there any way to develop Android system application using entirely Android Studio and its emulator?


I am trying to develop a custom settings app for Android Automotive OS where I will have to grant permissions such as android.car.permission.CAR_CONTROL_AUDIO_VOLUME from android.car library to the application. In order to be able to do this, I reckon that my application needs to be a system application.

Is there any way I can develop a system application without using an actual device or without having to modify a system image, entirely on AVD emulator? I already have a device at my disposal but developing on emulator is eventually so much easier because I wouldn't have to flash images so often. Thank you very much in advance.

In Java:

mCar = Car.createCar(ctx);
mCarAudioManager = (CarAudioManager) mCar.getCarManager(Car.AUDIO_SERVICE);

In AndroidManifest.xml

<uses-permission android:name="android.car.permission.CAR_CONTROL_AUDIO_VOLUME"/>

When I try to do this I am getting following exception:

java.lang.RuntimeException: Unable to start activity ComponentInfo
...
Caused by: android.view.InflateException: Binary XML file line #18 in xxx:layout/sound_activity_layout: Binary XML file line #18 in xxx:layout/sound_activity_layout: Error inflating class androidx.fragment.app.FragmentContainerView
Caused by: android.view.InflateException: Binary XML file line #18 in xxx:layout/sound_activity_layout: Error inflating class androidx.fragment.app.FragmentContainerView              
Caused by: java.lang.SecurityException: requires permission android.car.permission.CAR_CONTROL_AUDIO_VOLUME
...

Solution

  • I think it's better to build your own emulator to develop system application.

    PTAL https://source.android.com/docs/automotive/start/avd/android_virtual_device