2017-06-20 49 views
1

我添加了Gradle依賴項,compile 'org.elasticsearch.client:transport:5.2.1'nodeBuilder()/ NodeBuilder - 無法解析符號 - 彈性搜索Java API(在Android上)

當Gradle構建同步時,我得到了一個警告列表。

Warning:WARNING: Dependency commons-logging:commons-logging:1.1.3 is ignored for release as it may be conflicting with the internal version provided by Android. 
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.2 is ignored for release as it may be conflicting with the internal version provided by Android. 
Warning:WARNING: Dependency commons-logging:commons-logging:1.1.3 is ignored for release as it may be conflicting with the internal version provided by Android. 
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.2 is ignored for release as it may be conflicting with the internal version provided by Android. 
Warning:WARNING: Dependency commons-logging:commons-logging:1.1.3 is ignored for debug as it may be conflicting with the internal version provided by Android. 
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.2 is ignored for debug as it may be conflicting with the internal version provided by Android. 
Warning:WARNING: Dependency commons-logging:commons-logging:1.1.3 is ignored for debug as it may be conflicting with the internal version provided by Android. 
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.2 is ignored for debug as it may be conflicting with the internal version provided by Android. 

但是Gradle構建成功。現在我在nodeBuilder()NodeBuilder處得到一個錯誤。錯誤是:Cannot resolve symbol。我該如何解決?

回答

1

ElasticSearch託管在Maven中心。在你的Maven項目,你可以定義你想要的ElasticSearch版本如下圖所示在你的pom.xml文件中使用:

<dependency> 
    <groupId>org.elasticsearch</groupId> 
    <artifactId>elasticsearch</artifactId> 
    <version>0.90.3</version> 
</dependency> 

Android Studio中不使用Maven作爲它的建造者;它使用Gradle代替。因此請嘗試添加這種依賴關係:

dependencies { 
    ... 
    compile 'org.elasticsearch:elasticsearch:0.90.3' 
}