Android App Indexing - > FirebaseAppIndexingInvalidArgumentException

1.4k views Asked by At

Hej!

I'm trying to implement app indexing content and I've started with the app-indexing Google codelabs sample.

Running this code

 Indexable recipeToIndex = new Indexable.Builder()
           .setName(mRecipe.getTitle())
           .setUrl(mRecipe.getRecipeUrl())
           .setImage(mRecipe.getPhoto())
           .setDescription(mRecipe.getDescription())
           .build();

 FirebaseAppIndex.getInstance().update(recipeToIndex); 

always results in a FirebaseAppIndexingInvalidArgumentException thrown by the update() method.

com.google.firebase.appindexing.FirebaseAppIndexingInvalidArgumentException: Intent 'Intent { act=android.intent.action.VIEW dat=http://example.com pkg=com.example }' cannot be resolved. The invalid indexable is: Indexable { { id: 'http://example.com/123' } Properties { { key: 'name' value: [ 'test_name' ] } } Metadata { worksOffline: false, score: 0 } }
                          at com.google.firebase.appindexing.internal.zzn.zzb(Unknown Source)
                          at com.google.firebase.appindexing.internal.zzd$zzc$1.onComplete(Unknown Source)
                          at com.google.android.gms.tasks.zzc$1.run(Unknown Source)
                          at android.os.Handler.handleCallback(Handler.java:739)
                          at android.os.Handler.dispatchMessage(Handler.java:95)
                          at android.os.Looper.loop(Looper.java:145)
                          at android.app.ActivityThread.main(ActivityThread.java:5951)
                          at java.lang.reflect.Method.invoke(Native Method)
                          at java.lang.reflect.Method.invoke(Method.java:372)
                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)

Do you have an suggestions how to add an image to the Indexable?

4

There are 4 answers

0
x90 On

You should chose appropriate (or that one that fits better) Builder from Indexables class as in sample.

0
sbaar On

The reason I was getting this error was because there was no intent filter in the manifest for the app I was testing.

Make sure for the url you are setting on the indexable that there is a matching entry in the manifest

    <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

            <intent-filter android:label="@string/app_name" android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="http"
                    android:host="century.com"
                    android:pathPrefix="/recipe" />
            </intent-filter>
        </activity>

0
Marc On

Ensure setUrl() recieves a well formed URL, mine had http://app.com//path

the // before path caused the problem

  Indexable recipeToIndex = new Indexable.Builder()
           .setName(mRecipe.getTitle())
           .setUrl(Uri.parse(mRecipe.getRecipeUrl()).toString())
           .setImage(Uri.parse(mRecipe.getPhoto()).toString())
           .setDescription(mRecipe.getDescription())
           .build();

This is not so important for setImage

1
Akira Hiramoto On

Delete the image message or edit the code like this.

if (friendlyMessage.getText() != null) {
   FirebaseAppIndex.getInstance().update(getMessageIndexable(friendlyMessage));
}
FirebaseUserActions.getInstance().end(getMessageViewAction(friendlyMessage));

It seems the tutorial does not consider the message without message. All the messages should be text or text with image. To fix it you should check. https://github.com/firebase/friendlychat/issues/160