2014-06-26 408 views
1

我創建了一個科爾多瓦插件這樣的樹插件添加庫:科爾多瓦:在

LucenePlugin 
    src 
     android 
      libs 
        lucene-analyzers-2.4.1.jar 
        lucene-core-2.4.1.jar 
        lucene-snowball-2.4.1.jar 
      LucenePlugin.java 
    www 
     lucene.js 
    plugin.xml 

在plugin.xml中,我加入的.jar這樣

<platform name="android"> 
    <config-file target="res/xml/config.xml" parent="/*"> 
     <feature name="org.apache.cordova.LuceneLibs"> 
      <param name="android-package" value="org.apache.cordova.LuceneLibs"/> 
     </feature> 
    </config-file> 
    <source-file src="src/android/lucene-analyzers-2.4.1.jar" target-dir="libs" framework="true"/> 
    <source-file src="src/android/lucene-core-2.4.1.jar" target-dir="libs" framework="true"/> 
    <source-file src="src/android/lucene-snowball-2.4.1.jar" target-dir="libs" framework="true"/>  
</platform> 

當我添加插件到科爾多瓦項目中,庫似乎是在好地方:

平臺\機器人\庫\的Lucene分析器-2.4.1.jar等等

不幸的是,當我運行該項目,我有這樣的錯誤

W/System.err(12492): java.lang.NoClassDefFoundError: 
org.apache.lucene.search.IndexSearcher 
W/System.err(12492): at 
org.apache.cordova.Lucene.LucenePlugin.execute(LucenePlugin.java:27) 
W/System.err(12492): at 
org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:65) 
W/System.err(12492): at 
org.apache.cordova.PluginManager.execHelper(PluginManager.java:242) 

你知道什麼我忘了?

謝謝

+0

確保它採用的是Android構建路徑 –

+0

一套文件包含android請建立路徑嗎? – Gabriel

+1

事實上,一切都很好,唯一的問題是IndexSearcher實現了java.rmi,Android沒有這個包。 要解決此問題,我們必須做兩件事: 1.從類「org.apache.lucene.search.Searchable」中刪除「extends java.rmi.Remote」2.刪除類「org.apache。 lucene.search.RemoteSearchable「 http://stackoverflow.com/questions/7821103/lucene-in-android – Gabriel

回答

1

我有同樣的問題。 jar文件在正確的地方着陸。但是,由於這個新添加的jar文件沒有被添加到構建路徑中,所以很明顯,您將在您的jar文件中找不到所有這些類的類的錯誤。如果您在本地項目中安裝此插件,只需將此jar文件添加到您的構建路徑。它會解決你的問題。但是如果你想在雲平臺上使用這個插件,比如phonegap build,可能會遇到麻煩。我正在尋找解決方法。

+0

您是否找到了解決方案?我遇到了同樣的問題。 – dbaq

0

對於同一個問題,請看this answer。只需將您的庫放在單個插件的頂級目錄中即可。這個對我有用。

0

如果您需要引用存在於特定的命名空間的設備,您可以使用上一庫「框架」標籤

<!-- Depend on latest version of GCM from play services --> 
<framework src="com.google.android.gms:play-services-gcm:+" /> 
<!-- Depend on v21 of appcompat-v7 support library --> 
<framework src="com.android.support:appcompat-v7:21+" /> 
<!-- Depend on library project included in plugin --> 
<framework src="relative/path/FeedbackLib" custom="true" /> 

https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#framework