为什么android studio app索引测试显示网络错误

时间:2016-09-01 07:03:26

标签: android

我在我的应用程序中进行应用程序索引我有一些疑问,我在下面描述,

  1. android studio - &gt;跑 - &gt;编辑配置 - &gt;常规标签 - &gt;启动选项下拉菜单 - &gt;选择了网址并复制粘贴我的网址http://<example.com>/ - &gt;在这里运行应用程序在获取日志的应用程序索引日志中没有得到任何错误
  2. 我已经宣布了我的清单文件,

     <activity android:name=".sample.activity.MainActivity">
            <intent-filter android:autoVerify="true">
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
    
                <data
                    android:host="www.example.com"
                    android:pathPrefix="/MYPREFIX"
                    android:scheme="http"
                    />
            </intent-filter>
        </activity>
    

    我用java文件中的onStart方法编写,在此之前我已经在onCreate()中声明并启动了GoogleApiClient类

    client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
    
     @Override
    protected void onStart() {
        super.onStart();
        client.connect();
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW,
                "MainPage",
                Uri.parse("`http://www.example.com/`"),
                Uri.parse("`android-app://package/http/www.example.com/prefix/`")
        );
        AppIndex.AppIndexApi.start(client, viewAction);
    }
    

    然后在onStop方法中,我确实喜欢这个

     @Override
    protected void onStop() {
        super.onStop();
    
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW,
                "MainPage",Uri.parse("`http://www.example.com/`"),
    
                Uri.parse("`android-app://package/http/www.example.com/prefix/`")
        );
        AppIndex.AppIndexApi.end(client, viewAction);
    
        client.disconnect();
    }
    

    上面的代码没有错误,但是当我使用app进行索引测试时,我在android stuio中遇到错误,我就这样测试了

    android studio - &gt;工具 - &gt; android - &gt; Google App索引测试 - &gt;新窗口打开 - &gt;在网址部分,我给http://www.example.com/ (or) http://www.example.com/prefix/这两个都没有工作,我得到这样的错误

    **网络错误,请稍后再试。     1. Google无法使用Google bot抓取功能对此页面编制索引。     2. Google无法使用App Indexing API为此页面编制索引。 **

    谷歌应用程序中的

    - &gt;设置 - &gt;手机搜索 - &gt;我可以看到我的应用程序默认选中。

    然后我在文件中cheked - &gt;其他设置 - &gt;默认设置 - &gt;检验代码 - &gt;缺少支持谷歌应用程序索引和缺少对谷歌应用程序索引API的支持,但截图将告诉你我得到了什么请看下面

    enter image description here

    enter image description here 但是因为我在Android设备中看不到Chrome中的应用程序索引,如果搜索与我的应用程序相关,我错过了什么或者我是否会发布测试版?我想做的事??请告诉我

    提前致谢

2 个答案:

答案 0 :(得分:0)

只是想在这里为Google AppIndexing澄清一些内容。明确的基础知识让我们把它分成两部分

支持HTTP网址 为此,您只需根据上面提到的URL在清单文件中声明applinks。

要对此进行测试,您需要转到Android工作室&gt;构建&gt;编辑配置&gt;启动选项&gt;选择网址&gt; 然后在此处输入您的网址&gt;申请并测试。

这与GoogleAppIdexing API不同。即使您不包含App indexing Api。这将有效。

App Indexing的第二部分是: - 添加AppIndexing API 我们必须在我们的活动onCreate()和onStop()方法中包含代码。

<强>更新: 1.选择文件&gt;其他设置&gt;默认设置&gt;编辑&gt;检查&gt; Android Lint。 2.取消选中Google App Indexing和Google App Indexing缺失支持的应用程序链接使用不正确。 enter image description here 3.通过选择Analyze&gt;手动运行语法检查。从应用程序或右键单击菜单中检查代码。

答案 1 :(得分:-1)

添加AppIndexing API为您的内容编制索引并在Google搜索栏中使用自动完成功能。让我们以每个页面的inShorts应用程序为例,有一个标题和小描述。阅读2或3个标题后,关闭应用程序并转移到Google搜索栏。 enter image description here 尝试输入您刚刚浏览的标题,您将获得应用页面建议,标题为标题。这与您在搜索App时获得的App建议不同。这是因为您为此特定页面编写了AppIndexing API代码并且标题相同正如你在onCreate中初始化的那样。 enter image description here