【发布时间】:2018-05-08 03:51:23
【问题描述】:
我无法让 proguard 在我的应用中工作。当我将 minify 启用为 true 时,布局屏幕中的 textinputlayout 工作正常,但我有一个包含一个膨胀 XML 的警报对话框,该 XML 没有膨胀(该 XML 包含一个 textinputlayout。请帮助大家。这是代码 sn-p。
PS:我正在使用移动应用发布,请不要因为对齐不正确而抨击。我真的需要帮助。
Build.gradle 条目-->
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguardandroid.txt'), 'proguard-rules.pro' signingConfig
signingConfigs.release
}
}
dependencies { compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.android.support:cardview-v7:25.1.0'
compile project(':volley-1.0.0')
compile project(':photoview-1.2.4')
compile project(':calligraphy-2.2.0') }
XML 屏幕中的TextInputLayout -->
<android.support.design.widget.TextInputLayout
android:id="@+id/pin_login_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:hint="Please enter PIN"
android:inputType="numberPassword"
android:maxLength="4"
android:textSize="24sp"/>
</android.support.design.widget.TextInputLayout>
警报对话框代码-->
AlertDialog.Builder builder = new AlertDialog.Builder(getContext(), R.style.AlertDialogStyle);
final TextInputLayout otpWrapper = (TextInputLayout) (LayoutInflater.from(getContext())).inflate(R.layout.single_edit_text_material, null);
otpWrapper.setHint("Please enter OTP");
otpWrapper.getEditText().setSingleLine(true);
otpWrapper.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
setEditTextMaxLength(otpWrapper.getEditText(), 6);
builder.setView(otpWrapper); builder.setNegativeButton("Cancel", null);
builder.setPositiveButton("Submit", new DialogInterface.OnClickListener(){
@Override public void onClick(DialogInterface dialog, int which) {
}
});
builder.setCancelable(false); final AlertDialog d = builder.create();
d.setCanceledOnTouchOutside(false); d.show();
single_edit_text_material.xml -->
<android.support.design.widget.TextInputLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/wrapper" android:layout_width="match_parent"
android:layout_height="wrap_content" android:paddingEnd="8dp"
android:paddingStart="8dp" android:paddingTop="8dp">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.TextInputLayout>
编辑:当 proguard 未启用时,对话框会在工作状态下弹出 textinputlayout,但当我启用 proguard 时,会弹出对话框但 textinputlayout 不存在,只有确定按钮存在。 android监视器没有错误
【问题讨论】:
-
您无法将 TextInputLayout 设置为视图,甚至无法对其进行充气。看我的回答你就明白了。
-
你能发布错误消息/堆栈跟踪吗?
-
@AesSedai101 Android 显示器没有错误。
标签: android android-layout android-proguard