0

I have just created my first Android Automotive project:

image

when I run AndroidAutoDemo.mobile module it works fine:

working

Unfortunately when I switch to AndroidAutoDemo.automotive module I get:

Could not identify launch activity: Default Activity not found Error while Launching activity Failed to launch an application on all devices

This is the Android Manifest file in AndroidAutoDemo.automotive module (left as default):

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

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

    <application
        android:allowBackup="true"
        android:appCategory="audio"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.AndroidAutoDemo" />

</manifest>

This is my mobile emulator:

emulator

  • How can I fix?
tail
  • 355
  • 2
  • 11

2 Answers2

1

To run automotive app you need Automotive emulator and Automotive flavor with Manifest like below. Also there is no Automotive emulator provided by Google yet but you can get other open source emulator from like Polestar https://developer.polestar.com/sdk/polestar2-sys-img.xml and Volvo https://developer.volvocars.com/sdk/volvo-sys-img.xml You don't have to add new activity

if want to understand you can go through example source code https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:car/app/app-samples/helloworld/

`

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="androidx.car.app.sample.helloworld"
    android:versionCode="1"
    android:versionName="1.0">

    <!-- Various required feature settings for an automotive app. -->
    <uses-feature
        android:name="android.hardware.type.automotive"
        android:required="true" />
    <uses-feature
        android:name="android.software.car.templates_host"
        android:required="true" />
    <uses-feature
        android:name="android.hardware.wifi"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.screen.portrait"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.screen.landscape"
        android:required="false" />

    <application
      android:label="@string/app_name"
      android:icon="@drawable/ic_launcher"
      android:extractNativeLibs="false">

        <meta-data
            android:name="com.android.automotive"
            android:resource="@xml/automotive_app_desc"
            tools:ignore="MetadataTagInsideApplicationTag" />

        <meta-data android:name="androidx.car.app.minCarApiLevel"
            android:value="1"
            tools:ignore="MetadataTagInsideApplicationTag" />

        <service
            android:name="androidx.car.app.sample.helloworld.common.HelloWorldService"
            android:exported="true">
          <intent-filter>
            <action android:name="androidx.car.app.CarAppService" />
          </intent-filter>
        </service>

        <activity
            android:name="androidx.car.app.activity.CarAppActivity"
            android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
            android:exported="true"
            android:launchMode="singleTask"
            android:label="@string/app_name">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="distractionOptimized" android:value="true"/>
        </activity>
    </application>
</manifest>

`

alokHarman
  • 289
  • 1
  • 8
0

Each Manifest file should include information about available activities and launcher activity. Launcher activity needs to be defined with some additional Intent filters, for example:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.car">

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

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.DeviceDefault.NoActionBar">
    <activity android:name="com.example.car.MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
bongo
  • 733
  • 4
  • 12