Java 在我的应用程序中实现Google索引

Java 在我的应用程序中实现Google索引,java,android,eclipse,google-index,Java,Android,Eclipse,Google Index,******这是我在Android manifest.xml中的活动实现****** <activity android:name="com.zameen.zameenapp.GizmosActivity" android:label="@string/title_gizmos" > <intent-filter android:label="@string/filter_title_viewgizmos"> <action

******这是我在Android manifest.xml中的活动实现******

<activity
    android:name="com.zameen.zameenapp.GizmosActivity"
    android:label="@string/title_gizmos" >
    <intent-filter android:label="@string/filter_title_viewgizmos">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
        <data android:scheme="http"
              android:host="www.example.com"
              android:pathPrefix="/gizmos" />

        <!-- note that the leading "/" is required for pathPrefix-->
        <!-- Accepts URIs that begin with "example://gizmos”
        <data android:scheme="example"
              android:host="gizmos" />
        -->
    </intent-filter>
</activity>
我正在我的应用程序中实现谷歌索引,我已经检查了一个特定的Url,即www.example.com/gizmos,我可以使用adb命令行轻松启动我的活动。 问题是我必须导入操作类库文件,该文件是import com.google.android.gms.appindexing.Action 但是每次我尝试添加它时都会出现错误,当按照Eclipse的建议导入指定的库文件时,我会在AppIndex.AppIndexApi.endnewAction(Action.TYPE_视图、标题、WEB_URL、APP_URI)收到错误我想为GizmosActivity中的Action类导入库文件以解决问题。还有人会告诉我GizmosActivity代码和清单定义得很好吗?我如何测试它是否工作良好
我非常感谢这个解决方案

我最终得到了这个解决方案,因为谷歌服务库没有更新,使用SDK更新google服务,然后将google服务项目从SDK文件夹extras导入Eclipse,之后别忘了在urs项目库中添加google服务库。

如果您使用的是Android Studio,您可以让Gradle帮您处理。只需将
compile'com.google.android.gms:play services appindexing:8.3.0'
(或您想要的任何版本)添加到应用程序的
build.gradle
(在“依赖项”下)中,您就可以导入所需的应用程序索引库

例如:

apply plugin: 'com.android.application'
    ...

    dependencies {
        compile 'com.google.android.gms:play-services-appindexing:8.3.0'
    }

但每次尝试添加时都会出现错误
什么错误?@Qix包含错误的导入库com.google.android.gms.appindexing.Action;但这是实现Action viewAction=Action.newAction(Action.TYPE\u VIEW、title、WEB\u URL、APP\u URI)的建议;使用它时,我可以通知谷歌,在我的应用程序特定页面上执行了多少次newAction。请将Java给你的实际错误粘贴到你的原始帖子中,这就是我所说的。@Qix我正在为我的应用程序谷歌索引学习本教程,你没有听我说。你说你收到了错误,但是你没有在你的帖子中发布你收到的实际错误。
apply plugin: 'com.android.application'
    ...

    dependencies {
        compile 'com.google.android.gms:play-services-appindexing:8.3.0'
    }