9

I'm new to android and Lucene. can I use Lucene for search in android list view. I have tried importing the package 2.3.2 and also used the jar files in library. However, there is an error in SearchFiles.java error is :
The type java.rmi.Remote cannot be resolved. It is indirectly referenced from .class files.

There is a possibility that this file doesnt exist for android. Is this the problem?

Sandeep Kumar P K
  • 7,412
  • 6
  • 36
  • 40
ketki
  • 91
  • 1
  • 2
  • 5

6 Answers6

10

You may want to use the native Full Text Search feature called FTS3 in SQLite instead, which is available in Android and it is faster (since it is running natively) and uses less memory than a Java Lucene implementation under Dalvik VM.

Hendy Irawan
  • 20,498
  • 11
  • 103
  • 114
  • 4
    Running natively does not always mean faster, especially if using filesystem-backed SQLite database. Did you run any tests to confirm this? – Display Name Sep 28 '15 at 07:17
5
  1. Delete "extends java.rmi.Remote" from the Class "org.apache.lucene.search.Searchable"
  2. Delete class "org.apache.lucene.search.RemoteSearchable"
Darko Vasilev
  • 51
  • 1
  • 1
  • how do i delete. cause i have all class files. also tried to decompile and recompile but not working – dhpratik Oct 07 '14 at 05:53
5

I've successfully used Lucene 3.3 for really simple search dute and it works. However, I have no idea what the memory usage impact is. In the 3.3 there is no dependency from RMI. If you need 2.3.2 and you have the source code you can free Lucene from the RMI dependency (I've read about a guy who succeeded in doing this).

Ryan Berger
  • 9,644
  • 6
  • 44
  • 56
Blackbelt
  • 156,034
  • 29
  • 297
  • 305
  • 1
    Can you please share your code. I am new to lucene and dont know how to import lucene in android project. – codemaniac Oct 06 '14 at 10:49
  • Can you share your code related to lucene in android ,i want to get started with lucene in android.It will helpful for guys like me – Prabha1 Feb 20 '15 at 06:25
3

I think this demo app will work for you.

https://github.com/weiweiwang/quickdialer

It has:

  • fast T9 search
  • support 5000 contacts
  • 500 calllogs
JaydeepW
  • 3,237
  • 1
  • 25
  • 27
3

Android is not java - it does not provide all standart java apis ( just look into android reference, java.rmi is not there ). However, it is possible to import almost everrything that is pure java ( if you have enough memory ). You may try to remove unnecessary classes which cause classloading problems from jars - bu it is a lot of work.

Konstantin Pribluda
  • 12,329
  • 1
  • 30
  • 35
0

This repository modify Lucene 7.3.0 for using in Android 8.0: https://github.com/texophen/lucene-android

If it does not work, you can modify org.apache.lucene.util.AttributeFactory and add your type to bellow method:

  static final MethodHandle findAttributeImplCtor(Class<? extends AttributeImpl> clazz) {
    try {
      //org.apache.lucene.LucenePackage.writeLog("AttributeFactory.findAttributeImplCtor() - 1: " + lookup.findConstructor(clazz, NO_ARG_CTOR).toString());
      MethodHandle mh = null;
      if (lookup.findConstructor(clazz, NO_ARG_CTOR).toString().endsWith("PackedTokenAttributeImpl")) {
        mh = lookup.findConstructor(clazz, NO_ARG_CTOR).asType(MethodType.methodType(org.apache.lucene.analysis.tokenattributes.PackedTokenAttributeImpl.class));
      } else {
        mh = lookup.findConstructor(clazz, NO_ARG_CTOR).asType(NO_ARG_RETURNING_ATTRIBUTEIMPL);
      }
      //org.apache.lucene.LucenePackage.writeLog("AttributeFactory.findAttributeImplCtor() - 2: " + mh.toString());
      return mh;
    } catch (NoSuchMethodException | IllegalAccessException e) {
      throw new IllegalArgumentException("Cannot lookup accessible no-arg constructor for: " + clazz.getName(), e);
    }
  }
texopher
  • 1
  • 3