Unfortunately Android does not have java.lang.management.ManagementFactory<div><br></div><div>The old version of Lucene never required it but the new version of Lucene does.</div><div><br></div><div><div>12-04 21:34:41.629: WARN/System.err(23160): java.lang.NoClassDefFoundError: java.lang.management.ManagementFactory</div>
<div>12-04 21:34:41.639: WARN/System.err(23160): at org.apache.lucene.store.NativeFSLockFactory.acquireTestLock(NativeFSLockFactory.java:87)</div><div>12-04 21:34:41.639: WARN/System.err(23160): at org.apache.lucene.store.NativeFSLockFactory.makeLock(NativeFSLockFactory.java:142)</div>
<div>12-04 21:34:41.649: WARN/System.err(23160): at org.apache.lucene.store.Directory.makeLock(Directory.java:106)</div><div>12-04 21:34:41.649: WARN/System.err(23160): at org.apache.lucene.index.IndexWriter.init(IndexWriter.java:1058)</div>
</div><div><br></div><div>I can't really see a reason to use ManagementFactory but here is how it is used:</div><div><br></div><div><span class="Apple-style-span" style="font-family: verdana; font-size: 12px; "><pre style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; ">
<span class="javaKeyword" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(143, 17, 81); ">private</span> <span class="javaKeyword" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(143, 17, 81); ">synchronized</span> <span class="javaKeyword" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(143, 17, 81); ">void</span> acquireTestLock() {
<span class="javaKeyword" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(143, 17, 81); ">if</span> (tested) <span class="javaKeyword" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(143, 17, 81); ">return</span>;
tested = true;
<span class="javaSComment" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; color: rgb(17, 143, 70); ">// Ensure that lockDir exists and is a directory.</span>
<span class="javaKeyword" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(143, 17, 81); ">if</span> (!lockDir.exists()) {
<span class="javaKeyword" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(143, 17, 81); ">if</span> (!lockDir.mkdirs())
<span class="javaKeyword" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(143, 17, 81); ">throw</span> <span class="javaKeyword" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(143, 17, 81); ">new</span> RuntimeException(<span class="javaString" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(76, 47, 191); ">"Cannot create directory: "</span> +
lockDir.getAbsolutePath());
} <span class="javaKeyword" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(143, 17, 81); ">else</span> <span class="javaKeyword" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(143, 17, 81); ">if</span> (!lockDir.isDirectory()) {
<span class="javaKeyword" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(143, 17, 81); ">throw</span> <span class="javaKeyword" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(143, 17, 81); ">new</span> RuntimeException(<span class="javaString" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(76, 47, 191); ">"Found regular file where directory expected: "</span> +
lockDir.getAbsolutePath());
}
<span class="javaSComment" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; color: rgb(17, 143, 70); ">// add the RuntimeMXBean's name to the lock file, to reduce the chance for</span>
<span class="javaSComment" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; color: rgb(17, 143, 70); ">// name collisions when this code is invoked by multiple JVMs (such as in</span>
<span class="javaSComment" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; color: rgb(17, 143, 70); ">// our tests). On most systems, the name includes the process Id.</span>
<span class="javaSComment" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; color: rgb(17, 143, 70); ">// Also, remove any non-alphanumeric characters, so that the lock file will</span>
<span class="javaSComment" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; color: rgb(17, 143, 70); ">// be created for sure on all systems.</span>
String randomLockName = <span class="javaString" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(76, 47, 191); ">"lucene-"</span>
+ ManagementFactory.getRuntimeMXBean().getName().replaceAll(<span class="javaString" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(76, 47, 191); ">"[^a..zA..Z0..9]+"</span>,<span class="javaString" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(76, 47, 191); ">""</span>) + <span class="javaString" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(76, 47, 191); ">"-"</span>
+ Long.toString(<span class="javaKeyword" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(143, 17, 81); ">new</span> Random().nextInt(), Character.MAX_RADIX)
+ <span class="javaString" style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; font-weight: bold; color: rgb(76, 47, 191); ">"-test.lock"</span>;</pre>
<pre style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; "><br></pre><pre style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; ">
I suppose I could edit the code and build a modified Lucene jar but I don't really want to do that. Another solution might be to go back to earlier jars but again that would lead to differences with JSword. I suppose I could disable index creation on Android because the above is only required during index creation. At the moment all I can think of is to modify the Lucene jars.</pre>
<pre style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; "><br></pre><pre style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; ">
Any ideas?</pre><pre style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; "><br></pre><pre style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; ">
Thanks</pre><pre style="margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-top: 0em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; ">Martin</pre></span></div>