首次声明后Android程序崩溃

时间:2017-02-13 16:35:38

标签: android

我有一个Android应用。我使用Android Studio。在添加与崩溃位置无关的代码之前,此应用程序正在运行。我在前几行放置了断点。当我启动调试器时,前两行正确停止,但在进入下一个语句之前崩溃。由于这部分代码没有改变,我不知道它为什么会崩溃。有人可以建议寻找一些东西吗?

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    // Set up the login form.
    mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
    populateAutoComplete();

这是XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:gravity="center_horizontal"
              android:orientation="vertical"
              android:paddingBottom="@dimen/activity_vertical_margin"
              android:paddingLeft="@dimen/activity_horizontal_margin"
              android:paddingRight="@dimen/activity_horizontal_margin"
              android:paddingTop="@dimen/activity_vertical_margin"
              tools:context="com.mynt.mynt.LoginActivity">

    <!-- Login progress -->
    <ProgressBar
        android:id="@+id/login_progress"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:visibility="gone"/>

    <ScrollView
        android:id="@+id/login_form"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:id="@+id/email_login_form"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <AutoCompleteTextView
                    android:id="@+id/email"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/prompt_email"
                    android:inputType="textEmailAddress"
                    android:maxLines="1"
                    android:singleLine="true"/>

            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <EditText
                    android:id = "@+id/EDITTEXT"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:background="@null"
                    android:editable="false"
                    android:ellipsize = "end"
                    android:cursorVisible="false"
                    android:scrollbars = 'vertical'
                    android:text = ""/>

                <EditText
                    android:id="@+id/password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/prompt_password"
                    android:imeActionId="@+id/login"
                    android:imeActionLabel="@string/action_sign_in_short"
                    android:imeOptions="actionUnspecified"
                    android:inputType="textPassword"
                    android:maxLines="1"
                    android:singleLine="true"/>

            </android.support.design.widget.TextInputLayout>

            <Button
                android:id="@+id/email_sign_in_button"
                style="?android:textAppearanceSmall"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:text="@string/action_sign_in"
                android:textStyle="bold"/>

        </LinearLayout>
    </ScrollView>
</LinearLayout>

以下是Android Monitor的输出:

02-13 11:53:31.150 17373-17373/? E/Zygote: v2
02-13 11:53:31.150 17373-17373/? I/libpersona: KNOX_SDCARD checking this for 10380
02-13 11:53:31.150 17373-17373/? I/libpersona: KNOX_SDCARD not a persona
02-13 11:53:31.160 17373-17373/? I/SELinux: Function: selinux_compare_spd_ram, index[1], SPD-policy is existed. and_ver=SEPF_SECMOBILE_6.0.1 ver=11
02-13 11:53:31.160 17373-17373/? W/SELinux: Function: selinux_compare_spd_ram, index[1], priority [2], priority version is VE=SEPF_SECMOBILE_6.0.1_0030
02-13 11:53:31.160 17373-17373/? E/Zygote: accessInfo : 0
02-13 11:53:31.160 17373-17373/? W/SELinux: SELinux: seapp_context_lookup: seinfo=default, level=s0:c512,c768, pkgname=com.mynt.mynt 
02-13 11:53:31.160 17373-17373/? I/art: Late-enabling -Xcheck:jni
02-13 11:53:31.180 17373-17373/? D/TimaKeyStoreProvider: TimaSignature is unavailable
02-13 11:53:31.180 17373-17373/? D/ActivityThread: Added TimaKeyStore provider
02-13 11:53:31.210 17373-17373/com.mynt.mynt W/ResourcesManager: getTopLevelResources: /data/app/com.mynt.mynt-1/base.apk / 1.0 running in com.mynt.mynt rsrc of package com.mynt.mynt
02-13 11:53:31.210 17373-17373/com.mynt.mynt I/InjectionManager: Inside getClassLibPath + mLibMap{0=, 1=}
02-13 11:53:31.210 17373-17373/com.mynt.mynt D/ResourcesManager: For user 0 new overlays fetched Null
02-13 11:53:31.220 17373-17373/com.mynt.mynt W/ActivityThread: Application com.mynt.mynt is waiting for the debugger on port 8100...
02-13 11:53:31.220 17373-17373/com.mynt.mynt I/System.out: Sending WAIT chunk
02-13 11:53:31.390 17373-17379/com.mynt.mynt I/art: Debugger is active
02-13 11:53:31.420 17373-17373/com.mynt.mynt I/System.out: Debugger has connected
02-13 11:53:31.420 17373-17373/com.mynt.mynt I/System.out: waiting for debugger to settle...
02-13 11:53:31.620 17373-17373/com.mynt.mynt I/System.out: waiting for debugger to settle...
02-13 11:53:31.820 17373-17373/com.mynt.mynt I/System.out: waiting for debugger to settle...
02-13 11:53:32.020 17373-17373/com.mynt.mynt I/System.out: waiting for debugger to settle...
02-13 11:53:32.220 17373-17373/com.mynt.mynt I/System.out: waiting for debugger to settle...
02-13 11:53:32.420 17373-17373/com.mynt.mynt I/System.out: waiting for debugger to settle...
02-13 11:53:32.620 17373-17373/com.mynt.mynt I/System.out: waiting for debugger to settle...
02-13 11:53:32.820 17373-17373/com.mynt.mynt I/System.out: waiting for debugger to settle...
02-13 11:53:33.020 17373-17373/com.mynt.mynt I/System.out: debugger has settled (1467)
02-13 11:53:33.020 17373-17373/com.mynt.mynt I/InjectionManager: Inside getClassLibPath caller 
02-13 11:53:33.020 17373-17373/com.mynt.mynt W/System: ClassLoader referenced unknown path: /data/app/com.mynt.mynt-1/lib/arm64
02-13 11:53:33.030 17373-17373/com.mynt.mynt I/InstantRun: Instant Run Runtime started. Android package is com.mynt.mynt, real application class is null.
02-13 11:53:33.420 17373-17373/com.mynt.mynt W/System: ClassLoader referenced unknown path: /data/app/com.mynt.mynt-1/lib/arm64
02-13 11:53:33.420 17373-17373/com.mynt.mynt D/InjectionManager: InjectionManager
02-13 11:53:33.420 17373-17373/com.mynt.mynt D/InjectionManager: fillFeatureStoreMap com.mynt.mynt
02-13 11:53:33.420 17373-17373/com.mynt.mynt I/InjectionManager: Constructor com.mynt.mynt, Feature store :{}
02-13 11:53:33.420 17373-17373/com.mynt.mynt I/InjectionManager: featureStore :{}
02-13 11:53:33.790 17373-17373/com.mynt.mynt W/ResourcesManager: getTopLevelResources: /data/app/com.mynt.mynt-1/base.apk / 1.0 running in com.mynt.mynt rsrc of package com.mynt.mynt
02-13 11:53:33.820 17373-17373/com.mynt.mynt W/ResourcesManager: getTopLevelResources: /data/app/com.mynt.mynt-1/base.apk / 1.0 running in com.mynt.mynt rsrc of package com.mynt.mynt
02-13 11:53:41.640 17373-17373/com.mynt.mynt W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
02-13 11:53:46.280 17373-17373/com.mynt.mynt I/TextInputLayout: EditText added is not a TextInputEditText. Please switch to using that class instead.
02-13 11:53:46.520 17373-17373/com.mynt.mynt I/TextInputLayout: EditText added is not a TextInputEditText. Please switch to using that class instead.
02-13 11:53:46.560 17373-17373/com.mynt.mynt D/AndroidRuntime: Shutting down VM
02-13 11:53:46.600 17373-17373/com.mynt.mynt E/AndroidRuntime: FATAL EXCEPTION: main
                                                               Process: com.mynt.mynt, PID: 17373
                                                               java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mynt.mynt/com.mynt.mynt.LoginActivity}: android.view.InflateException: Binary XML file line #73: We already have an EditText, can only have one
                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3254)
                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)
                                                                   at android.app.ActivityThread.access$1100(ActivityThread.java:222)
                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                   at android.os.Looper.loop(Looper.java:158)
                                                                   at android.app.ActivityThread.main(ActivityThread.java:7237)
                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
                                                                Caused by: android.view.InflateException: Binary XML file line #73: We already have an EditText, can only have one
                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
                                                                   at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288)
                                                                   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                   at com.mynt.mynt.LoginActivity.onCreate(LoginActivity.java:78)
                                                                   at android.app.Activity.performCreate(Activity.java:6876)
                                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207)
                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350) 
                                                                   at android.app.ActivityThread.access$1100(ActivityThread.java:222) 
                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795) 
                                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                   at android.os.Looper.loop(Looper.java:158) 
                                                                   at android.app.ActivityThread.main(ActivityThread.java:7237) 
                                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
                                                                Caused by: java.lang.IllegalArgumentException: We already have an EditText, can only have one
                                                                   at android.support.design.widget.TextInputLayout.setEditText(TextInputLayout.java:320)
                                                                   at android.support.design.widget.TextInputLayout.addView(TextInputLayout.java:283)
                                                                   at android.view.ViewGroup.addView(ViewGroup.java:4462)
                                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:856)
                                                                   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
                                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
                                                                   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
                                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
                                                                   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
                                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
                                                                   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
                                                                   at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288) 
                                                                   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                   at com.mynt.mynt.LoginActivity.onCreate(LoginActivity.java:78) 
                                                                   at android.app.Activity.performCreate(Activity.java:6876) 
                                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207) 
                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350) 
                                                                   at android.app.ActivityThread.access$1100(ActivityThread.java:222) 
                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795) 
                                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                   at android.os.Looper.loop(Looper.java:158) 
                                                                   at android.app.ActivityThread.main(ActivityThread.java:7237) 
                                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 

1 个答案:

答案 0 :(得分:0)

我会尝试使用以下代码更改代码,将EditText的任何实例封装到单个TextInputLayout中,因为您获得了以下stacktrace行:

  

android.view.InflateException:二进制XML文件行#73:我们已经有一个EditText,只能有一个                                                                      在android.view.LayoutInflater.inflate(LayoutInflater.java:551)

    <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <EditText
                    android:id = "@+id/EDITTEXT"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:background="@null"
                    android:editable="false"
                    android:ellipsize = "end"
                    android:cursorVisible="false"
                    android:scrollbars = 'vertical'
                    android:text = ""/>
</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
                <EditText
                    android:id="@+id/password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/prompt_password"
                    android:imeActionId="@+id/login"
                    android:imeActionLabel="@string/action_sign_in_short"
                    android:imeOptions="actionUnspecified"
                    android:inputType="textPassword"
                    android:maxLines="1"
                    android:singleLine="true"/>
                  </android.support.design.widget.TextInputLayout>