当我使用不同的API测试时,我的Android自定义键盘工作正常,使用模拟器但我在发布应用程序后看到崩溃错误。受影响的用户只有一个人。以下是一些更多细节:
三星Galaxy J3 Pro(j3xproltechn),2048MB RAM,Android 5.1
在gradle中禁用了proguard缩小。我在布局中使用的图像不超过200kb,并且一次只使用一个图像,因此不存在内存中断的可能性。
以下是错误行的代码:
@Override
public View onCreateInputView() {
// Set custom theme to input view.
int themeLayout = sharedPreferences.getInt(THEME_KEY, R.layout.input_1);
mInputView = (LatinKeyboardView) getLayoutInflater().inflate(
themeLayout, null);
mInputView.setOnKeyboardActionListener(this);
// Apply the selected keyboard to the input view.
setLatinKeyboard(getSelectedSubtype());
return mInputView;
}
R.layout.input_1的代码:
<com.domain.keyboard.android.LatinKeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/kb_bg_1"
android:keyBackground="@drawable/key_bg_fill_grey"
android:keyPreviewLayout="@layout/key_preview_layout"
android:keyPreviewOffset="@dimen/keyPreviewOffset"
android:keyTextColor="@color/white"
android:popupLayout="@layout/keyboard_popup_layout" />
错误日志:
android.view.InflateException:at android.view.LayoutInflater.createView(LayoutInflater.java:640)at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:750)在android.view.LayoutInflater.inflate (LayoutInflater.java:483)在android.view.LayoutInflater.inflate (LayoutInflater.java:415)在android.view.LayoutInflater.inflate (LayoutInflater.java:366)at com.domain.keyboard.android.SoftKeyboard.onCreateInputView (SoftKeyboard.java:159)at com.domain.keyboard.android.SoftKeyboard.onStartInput (SoftKeyboard.java:232)引起: java.lang.reflect.InvocationTargetException:at java.lang.reflect.Constructor.newInstance(Native Method)at java.lang.reflect.Constructor.newInstance(Constructor.java:288)at android.view.LayoutInflater.createView(LayoutInflater.java:614)