moshi 和 android 2.3.3
moshi and android 2.3.3
我在 android 2.3.3 上使用 moshi 时遇到问题:
D/PassAndroid( 1649): java.lang.IllegalArgumentException: cannot construct instances of org.ligi.passandroid.model.pass.PassImpl
D/PassAndroid( 1649): at com.squareup.moshi.ClassFactory.get(ClassFactory.java:110)
D/PassAndroid( 1649): at com.squareup.moshi.ClassJsonAdapter.create(ClassJsonAdapter.java:61)
D/PassAndroid( 1649): at com.squareup.moshi.Moshi.adapter(Moshi.java:92)
D/PassAndroid( 1649): at com.squareup.moshi.Moshi.adapter(Moshi.java:61)
D/PassAndroid( 1649): at org.ligi.passandroid.model.AndroidFileSystemPassStore.save(AndroidFileSystemPassStore.kt:33)
D/PassAndroid( 1649): at org.ligi.passandroid.ui.PassListActivity.onFABClick(PassListActivity.java:82)
D/PassAndroid( 1649): at org.ligi.passandroid.ui.PassListActivity$$ViewBinder.doClick(PassListActivity$$ViewBinder.java:39)
D/PassAndroid( 1649): at butterknife.internal.DebouncingOnClickListener.onClick(DebouncingOnClickListener.java:22)
D/PassAndroid( 1649): at android.view.View.performClick(View.java:2485)
D/PassAndroid( 1649): at android.view.View$PerformClick.run(View.java:9080)
D/PassAndroid( 1649): at android.os.Handler.handleCallback(Handler.java:587)
D/PassAndroid( 1649): at android.os.Handler.dispatchMessage(Handler.java:92)
D/PassAndroid( 1649): at android.os.Looper.loop(Looper.java:130)
D/PassAndroid( 1649): at android.app.ActivityThread.main(ActivityThread.java:3683)
D/PassAndroid( 1649): at java.lang.reflect.Method.invokeNative(Native Method)
D/PassAndroid( 1649): at java.lang.reflect.Method.invoke(Method.java:507)
D/PassAndroid( 1649): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
D/PassAndroid( 1649): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
D/PassAndroid( 1649): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 1649): FATAL EXCEPTION: main
E/AndroidRuntime( 1649): java.lang.IllegalArgumentException: cannot construct instances of org.ligi.passandroid.model.pass.PassImpl
E/AndroidRuntime( 1649): at com.squareup.moshi.ClassFactory.get(ClassFactory.java:110)
E/AndroidRuntime( 1649): at com.squareup.moshi.ClassJsonAdapter.create(ClassJsonAdapter.java:61)
E/AndroidRuntime( 1649): at com.squareup.moshi.Moshi.adapter(Moshi.java:92)
E/AndroidRuntime( 1649): at com.squareup.moshi.Moshi.adapter(Moshi.java:61)
E/AndroidRuntime( 1649): at org.ligi.passandroid.model.AndroidFileSystemPassStore.save(AndroidFileSystemPassStore.kt:33)
E/AndroidRuntime( 1649): at org.ligi.passandroid.ui.PassListActivity.onFABClick(PassListActivity.java:82)
E/AndroidRuntime( 1649): at org.ligi.passandroid.ui.PassListActivity$$ViewBinder.doClick(PassListActivity$$ViewBinder.java:39)
E/AndroidRuntime( 1649): at butterknife.internal.DebouncingOnClickListener.onClick(DebouncingOnClickListener.java:22)
E/AndroidRuntime( 1649): at android.view.View.performClick(View.java:2485)
E/AndroidRuntime( 1649): at android.view.View$PerformClick.run(View.java:9080)
E/AndroidRuntime( 1649): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 1649): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 1649): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 1649): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 1649): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1649): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 1649): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 1649): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 1649): at dalvik.system.NativeStart.main(Native Method)
它适用于更高版本的 android。 PassImpl 是一个 kotlin class - 但 moshi 通常能够创建它们,因为它适用于更高版本。有人知道解决方法吗?
这是一个 moshi 错误,现已解决:https://github.com/square/moshi/issues/117
我在 android 2.3.3 上使用 moshi 时遇到问题:
D/PassAndroid( 1649): java.lang.IllegalArgumentException: cannot construct instances of org.ligi.passandroid.model.pass.PassImpl
D/PassAndroid( 1649): at com.squareup.moshi.ClassFactory.get(ClassFactory.java:110)
D/PassAndroid( 1649): at com.squareup.moshi.ClassJsonAdapter.create(ClassJsonAdapter.java:61)
D/PassAndroid( 1649): at com.squareup.moshi.Moshi.adapter(Moshi.java:92)
D/PassAndroid( 1649): at com.squareup.moshi.Moshi.adapter(Moshi.java:61)
D/PassAndroid( 1649): at org.ligi.passandroid.model.AndroidFileSystemPassStore.save(AndroidFileSystemPassStore.kt:33)
D/PassAndroid( 1649): at org.ligi.passandroid.ui.PassListActivity.onFABClick(PassListActivity.java:82)
D/PassAndroid( 1649): at org.ligi.passandroid.ui.PassListActivity$$ViewBinder.doClick(PassListActivity$$ViewBinder.java:39)
D/PassAndroid( 1649): at butterknife.internal.DebouncingOnClickListener.onClick(DebouncingOnClickListener.java:22)
D/PassAndroid( 1649): at android.view.View.performClick(View.java:2485)
D/PassAndroid( 1649): at android.view.View$PerformClick.run(View.java:9080)
D/PassAndroid( 1649): at android.os.Handler.handleCallback(Handler.java:587)
D/PassAndroid( 1649): at android.os.Handler.dispatchMessage(Handler.java:92)
D/PassAndroid( 1649): at android.os.Looper.loop(Looper.java:130)
D/PassAndroid( 1649): at android.app.ActivityThread.main(ActivityThread.java:3683)
D/PassAndroid( 1649): at java.lang.reflect.Method.invokeNative(Native Method)
D/PassAndroid( 1649): at java.lang.reflect.Method.invoke(Method.java:507)
D/PassAndroid( 1649): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
D/PassAndroid( 1649): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
D/PassAndroid( 1649): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 1649): FATAL EXCEPTION: main
E/AndroidRuntime( 1649): java.lang.IllegalArgumentException: cannot construct instances of org.ligi.passandroid.model.pass.PassImpl
E/AndroidRuntime( 1649): at com.squareup.moshi.ClassFactory.get(ClassFactory.java:110)
E/AndroidRuntime( 1649): at com.squareup.moshi.ClassJsonAdapter.create(ClassJsonAdapter.java:61)
E/AndroidRuntime( 1649): at com.squareup.moshi.Moshi.adapter(Moshi.java:92)
E/AndroidRuntime( 1649): at com.squareup.moshi.Moshi.adapter(Moshi.java:61)
E/AndroidRuntime( 1649): at org.ligi.passandroid.model.AndroidFileSystemPassStore.save(AndroidFileSystemPassStore.kt:33)
E/AndroidRuntime( 1649): at org.ligi.passandroid.ui.PassListActivity.onFABClick(PassListActivity.java:82)
E/AndroidRuntime( 1649): at org.ligi.passandroid.ui.PassListActivity$$ViewBinder.doClick(PassListActivity$$ViewBinder.java:39)
E/AndroidRuntime( 1649): at butterknife.internal.DebouncingOnClickListener.onClick(DebouncingOnClickListener.java:22)
E/AndroidRuntime( 1649): at android.view.View.performClick(View.java:2485)
E/AndroidRuntime( 1649): at android.view.View$PerformClick.run(View.java:9080)
E/AndroidRuntime( 1649): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 1649): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 1649): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 1649): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 1649): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1649): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 1649): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 1649): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 1649): at dalvik.system.NativeStart.main(Native Method)
它适用于更高版本的 android。 PassImpl 是一个 kotlin class - 但 moshi 通常能够创建它们,因为它适用于更高版本。有人知道解决方法吗?
这是一个 moshi 错误,现已解决:https://github.com/square/moshi/issues/117