This repository modify Lucene 7.3.0 for using in Android 8.0: https://github.com/texophen/lucene-android
如不工作,可修改org.apache.lucene.util.Attribute 2. 工厂和添加种类以替代方法:
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);
}
}