Search code examples
androidxmlgoogle-glass

Unable to load voice trigger for activity


Android manifest:

<uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT" />
....
<activity
            android:name=".MainActivity"
            android:label="@string/app_name" 
            android:icon="@drawable/ic_launcher" >                      

            <intent-filter>                                
                <action android:name="com.google.android.glass.action.VOICE_TRIGGER" />               
            </intent-filter>
            <meta-data 
                android:name="com.google.angroid.glass.VoiceTrigger"
                android:resource="@xml/voice_trigger" />

            <intent-filter>
                <action android:name="android.speech.action.RECOGNIZE_SPEECH" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>                            
        </activity>

voice_trigger.xml (...\res\xml)

<?xml version="1.0" encoding="utf-8"?>
<trigger keyword="@string/glass_voice_trigger" />

strings.xml

<string name="glass_voice_trigger">control</string>

Whenever I run my code, VoiceTriggers logs that it was unable to build the voice trigger for my main activity (throws VoiceTriggerBuildingException) because the config file for the voice trigger was not found.

Did anyone else run across this problem?


Solution

  • If you've AndroidManifest.xml you shared is the same that you are using, then you have a typo for the voice trigger meta-data:

    <meta-data 
        android:name="com.google.android.glass.VoiceTrigger"
        android:resource="@xml/voice_trigger" />
    

    You had com.google.angroid... instead of com.google.android....