java.lang.NoSuchFieldError: No instance field name of type Ljava/lang/String; in class Lh/e/c/a; or its superclasses (declaration of 'h.e.c.a' appears in /data/app/com.epub.epubreader-1/base.apk)
at h.e.c.a.<init>(:89)
at h.e.c.b.a(:52)
at h.e.c.a(:358)
at h.f.a.c.<clinit>(:70)
at org.readium.r2.streamer.a.d.d(:62)
at org.readium.r2.streamer.c.b.a(:101)
at com.folioreader.ui.activity.FolioActivity.B(:477)
at com.folioreader.ui.activity.FolioActivity.A(:447)
at com.folioreader.ui.activity.FolioActivity.onCreate(:296)
at android.app.Activity.performCreate(Activity.java:5979)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2262)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.access$800(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5258)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
我创建了一个平台通道来从flutter访问android folioreader库。读者在调试中工作正常,但在APK版本中,当我尝试打开库时应用崩溃。以下是主要活动。
class MainActivity : FlutterActivity() {
private val channelName = "epubchannel"
var config = Config()
.setAllowedDirection(Config.AllowedDirection.ONLY_HORIZONTAL)
.setDirection(Config.Direction.HORIZONTAL)
var folioReader = FolioReader.get()
.setConfig(config, true)
@SuppressLint("SdCardPath")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
GeneratedPluginRegistrant.registerWith(this)
MethodChannel(flutterView, channelName).setMethodCallHandler { call, result ->
try {
if (call.method == "resume") {
Log.i(LOG_TAG, "-> saveReadLocator -> " + call.arguments.toString())
val readLocator = ReadLocator.fromJson(call.argument<String>("lastReadPosition"))
folioReader.setReadLocator(readLocator)
folioReader.openBook(call.argument<String>("path"))
folioReader.setReadLocatorListener { readLocator ->
Log.i(LOG_TAG, "-> saveReadLocator -> " + readLocator.toJson()!!)
result.success(readLocator.toJson().toString())
FolioReader.clear()
}
} else if (call.method == "start") {
folioReader.openBook(call.argument<String>("path"))
folioReader.setReadLocatorListener { readLocator ->
result.success(readLocator.toJson().toString())
FolioReader.clear()
}
}
} catch (e: Exception) {
result.error("failed", "${e.toString()}", "")
}
}
}
}
导致该问题的错误是什么?如果您需要更多的资源来理解问题,请发表评论。谢谢。
更新: 我在发布方法中添加了以下属性,该应用程序运行正常。添加此属性有什么问题吗?
minifyEnabled false
shrinkResources false