Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - AppIndex URI

I recently updated my Android Studio to version 2.1 and the project I was working on to Gradle version 2.1.0 as well. I commented a line in my code which had nothing to do with the App Indexing code that is auto-generated, and now, whenever I try to run my app it crashes and gives me the following error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{lux.unisabana.sabanaviveenti/sabanaviveenti.unisabana.lux.unisabana.appsabana.MainActivity}: java.lang.IllegalArgumentException: AppIndex: The android-app URI host must match the package name and follow the format android-app://<package_name>/<scheme>/[host_path]. Provided URI: android-app://sabanaviveenti.unisabana.lux.unisabana.appsabana/http/host/path

I have looked everywhere and tried many things, updating the target versions, the libraries required for it and nothing has worked so far, can anyone please help me?

The SDK I'm using for compiling is the version 23 and the Google Services dependency I'm using is the 8.4.0

like image 520
Jpfcan Avatar asked Oct 19 '22 10:10

Jpfcan


1 Answers

I had also been fighting with this problem for nearly two days. In short: search through your Java files for "sabanaviveenti.unisabana.lux.unisabana.appsabana/http/host/path". You will probably find them in the OnStart() method of your initial activity. You need to replace sabanaviveenti.unisabana.lux.unisabana.appsabana with the package name which contains your main app code. E.g. something like this:

    Action viewAction=Action.newAction(
            Action.TYPE_VIEW, // TODO: choose an action type.
            "LogTasks Page", // TODO: Define a title for the content shown.
            // TODO: If you have web page content that matches this app activity's content,
            // make sure this auto-generated web page URL is correct.
            // Otherwise, set the URL to null
            Uri.parse("http://host/path"),
            // TODO: Make sure this auto-generated app URL is correct.
            // was: Uri.parse("android-app://sabanaviveenti.unisabana.lux.unisabana.appsabana/path"),
            Uri.parse("android-app://com.myserver.mypackage/http/host/path")
    );
    AppIndex.AppIndexApi.start(client, viewAction);

The reason I had the problem was because I was restructuring the app's code and simultaneously updating the Android Studio and the SDK. Somehow this code got created automatically. In my case, the activity is in a library package, but the main activity in the application is derived from this activity, so I did not see the original activity code directly.

like image 149
Einar H. Avatar answered Oct 29 '22 19:10

Einar H.