与Google地图集成时,我遇到了非常令人沮丧的错误。有人可以解释我做错了什么导致以下错误:
这是错误
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>.
提供的URI:android-app://app.facebook.android.com.googlemaps/http/host/path
答案 0 :(得分:0)
找到答案,我从不同的来源复制了代码。这就是抛出异常的onStart方法的样子:
@Override
protected void onStart() {
googleApiClient.connect();
super.onStart();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
Action viewAction = Action.newAction(
Action.TYPE_VIEW, // TODO: choose an action type.
"Map 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.
Uri.parse("android-app://app.facebook.android.com.googlemaps/http/host/path")
);
AppIndex.AppIndexApi.start(googleApiClient, viewAction);
}
我只需要更改app.facebook.android.com.googlemaps以匹配我的主要活动包名称。