簡體   English   中英

在通知中使用ConstraintLayout時崩潰

[英]Crash when using ConstraintLayout in Notification

當我在自定義Notification使用ConstraintLayout時,我得到一個InflationException 我可以在我的應用程序的其他地方使用它們,而不是在Notification的自定義布局中。 我假設支持庫中包含的任何小部件根本無法在RemoteView ,但我找不到任何確認。 有人知道嗎?

E/StatusBar: couldn't inflate view for notification com.example.app/0x1
android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.constraint.ConstraintLayout" on path: DexPathList[[],nativeLibraryDirectories=[/system/priv-app/TeleService/lib/arm64, /system/fake-libs64, /system/priv-app/TeleService/TeleService.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /system/lib64, /vendor/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.view.LayoutInflater.createView(LayoutInflater.java:606)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
    at android.widget.RemoteViews.inflateView(RemoteViews.java:3278)
    at android.widget.RemoteViews.-wrap1(Unknown Source:0)
    at android.widget.RemoteViews$AsyncApplyTask.doInBackground(RemoteViews.java:3380)
    at android.widget.RemoteViews$AsyncApplyTask.doInBackground(RemoteViews.java:3376)
    at android.os.AsyncTask$2.call(AsyncTask.java:333)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
    at java.lang.Thread.run(Thread.java:764)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.app, PID: 9732
android.app.RemoteServiceException: Bad notification posted from package com.example.app: Couldn't inflate contentViewsandroid.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1775)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6541)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

RemoteViews對象(以及App Widget) 可以支持以下布局類

  • FrameLayout
  • LinearLayout
  • RelativeLayout
  • GridLayout

以下小部件類:

  • AnalogClock
  • Button
  • Chronometer
  • ImageButton
  • ImageView
  • ProgressBar
  • TextView
  • ViewFlipper
  • ListView
  • GridView
  • StackView
  • AdapterViewFlipper

不支持這些類的后代。

閱讀更多: https//developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout

RemoteView只能支持以下布局類:

FrameLayout

LinearLayout

RelativeLayout

GridLayout

如前所述這里

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM