简单应用Android Studio上的主线程错误

时间:2015-10-15 13:16:12

标签: android

我正试图让Android网站上的入门应用在Android Studio中运行。我不知道为什么我会说“应用程序可能在其主线程上做了太多工作。”这样一个简单的应用程序出错。

  1. 除了教程
  2. 中的内容之外,没有任何内容添加到代码中
  3. 将堆大小更改为128
  4. 将Ram更改为768
  5. Nexus 4 API 23
  6. 文本框和按钮不显示。但我没有得到任何其他错误。
  7. 似乎缺少某些东西,但我不知道是什么。

    10-15 08:10:12.213 2304-2304/com.example.mike.nutrition I/art: Not late-enabling -Xcheck:jni (already on)
    10-15 08:10:12.213 2304-2304/com.example.mike.nutrition I/art: Late-enabling JIT
    10-15 08:10:12.216 2304-2304/com.example.mike.nutrition I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
    10-15 08:10:12.286 2304-2304/com.example.mike.nutrition W/System: ClassLoader referenced unknown path: /data/app/com.example.mike.nutrition-1/lib/x86
    10-15 08:10:12.595 2304-2322/com.example.mike.nutrition D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
    10-15 08:10:12.607 2304-2304/com.example.mike.nutrition D/: HostConnection::get() New Host Connection established 0xaba3db60, tid 2304
    10-15 08:10:13.012 2304-2322/com.example.mike.nutrition I/OpenGLRenderer: Initialized EGL, version 1.4
    10-15 08:10:13.092 2304-2322/com.example.mike.nutrition W/EGL_emulation: eglSurfaceAttrib not implemented
    10-15 08:10:13.092 2304-2322/com.example.mike.nutrition W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xab944fe0, error=EGL_SUCCESS
    10-15 08:10:13.140 2304-2304/com.example.mike.nutrition I/Choreographer: Skipped 30 frames!  The application may be doing too much work on its main thread.
    10-15 08:10:13.667 2304-2304/com.example.mike.nutrition I/Choreographer: Skipped 31 frames!  The application may be doing too much work on its main thread.
    10-15 08:12:06.378 2304-2311/com.example.mike.nutrition W/art: Suspending all threads took: 5.010ms
    10-15 08:12:10.380 2304-2311/com.example.mike.nutrition W/art: Suspending all threads took: 7.298ms
    
    
    
    <?xml version="1.0" encoding="utf-8"?>
            <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:orientation="horizontal">
                <EditText android:id="@+id/edit_message"
                    android:layout_weight="1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:hint="@string/edit_message" />
                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/button_send" />
            </LinearLayout>
    

    编辑: 我收到了这个错误:

    10-15 11:45:28.829 1563-1563/com.android.launcher3 E/AndroidRuntime:  Caused by: java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.appwidget.AppWidgetHostView$ParcelableSparseArray instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/0x4. Make sure other views do not use the same id.
    

1 个答案:

答案 0 :(得分:0)

似乎你没有为你的AVD指定足够的RAM。尝试将其升级到2056年。