gpt4 book ai didi

java - Unity 插件在使用通知 Compat Builder 时出现错误

转载 作者:行者123 更新时间:2023-12-02 15:51:41 27 4
gpt4 key购买 nike

所以,

我为 Unity 创建了一个通知插件,当我使用时它工作正常(Notification = New Notification.Builer)

但我想使用NotificationCompatBuilder来访问旧设备,这样它就可以在所有API级别中使用。

当我使用它并尝试运行它时,它给了我这个错误

12-24 18:59:31.774: E/AndroidRuntime(10086): FATAL EXCEPTION: main
12-24 18:59:31.774: E/AndroidRuntime(10086): Process: com.blah.blahblah, PID: 10086
12-24 18:59:31.774: E/AndroidRuntime(10086): java.lang.Error: FATAL EXCEPTION [main]
12-24 18:59:31.774: E/AndroidRuntime(10086): Unity version : 5.4.2f2
12-24 18:59:31.774: E/AndroidRuntime(10086): Device model : LGE Nexus 5
12-24 18:59:31.774: E/AndroidRuntime(10086): Device fingerprint: google/hammerhead/hammerhead:6.0.1/M4B30X/3237893:user/release-keys
12-24 18:59:31.774: E/AndroidRuntime(10086): Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/app/NotificationCompat$Builder;
12-24 18:59:31.774: E/AndroidRuntime(10086): at com.blah.soundlibrary.MusicService.showNotification(MusicService.java:383)
12-24 18:59:31.774: E/AndroidRuntime(10086): at com.blah.soundlibrary.MusicService.onStartCommand(MusicService.java:302)
12-24 18:59:31.774: E/AndroidRuntime(10086): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3010)
12-24 18:59:31.774: E/AndroidRuntime(10086): at android.app.ActivityThread.-wrap17(ActivityThread.java)
12-24 18:59:31.774: E/AndroidRuntime(10086): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1442)
12-24 18:59:31.774: E/AndroidRuntime(10086): at android.os.Handler.dispatchMessage(Handler.java:102)
12-24 18:59:31.774: E/AndroidRuntime(10086): at android.os.Looper.loop(Looper.java:148)
12-24 18:59:31.774: E/AndroidRuntime(10086): at android.app.ActivityThread.main(ActivityThread.java:5417)
12-24 18:59:31.774: E/AndroidRuntime(10086): at java.lang.reflect.Method.invoke(Native Method)
12-24 18:59:31.774: E/AndroidRuntime(10086): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
12-24 18:59:31.774: E/AndroidRuntime(10086): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-24 18:59:31.774: E/AndroidRuntime(10086): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.app.NotificationCompat$Builder" on path: DexPathList[[zip file "/data/app/com.blah.blahblah-2/base.apk"],nativeLibraryDirectories=[/data/app/com.blah.blahblah-2/lib/arm, /data/app/com.blah.blahblah-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
12-24 18:59:31.774: E/AndroidRuntime(10086): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
12-24 18:59:31.774: E/AndroidRuntime(10086): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
12-24 18:59:31.774: E/AndroidRuntime(10086): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
12-24 18:59:31.774: E/AndroidRuntime(10086): ... 11 more
12-24 18:59:31.774: E/AndroidRuntime(10086): Suppressed: java.lang.ClassNotFoundException: android.support.v4.app.NotificationCompat$Builder
12-24 18:59:31.774: E/AndroidRuntime(10086): at java.lang.Class.classForName(Native Method)
12-24 18:59:31.774: E/AndroidRuntime(10086): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
12-24 18:59:31.774: E/AndroidRuntime(10086): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
12-24 18:59:31.774: E/AndroidRuntime(10086): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
12-24 18:59:31.774: E/AndroidRuntime(10086): ... 12 more
12-24 18:59:31.774: E/AndroidRuntime(10086): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

是的,我已经使用了

import android.support.v4.app.NotificationCompat;

我正在使用 Android Studio 和 Library .aar 文件来统一构建插件

花了半天时间才解决这个问题,哈哈

编辑:将“com.android.support:support-v4:25.1.0”添加到 gradle 也没有解决问题。

Edit-2:我认为可以通过将“support-v4-25.1.0”(我从 SDK 文件夹中获取)添加到“Assets/Plugins/Android”来抑制该问题,但它仍然给我同样的错误我认为它仍然看不到 .aar 文件:我很困惑

最佳答案

更新和回答:好的,当我看到此日志错误时

android.support.v4.app.NotificationCompat$Builder

我虽然问题出在 support.v4.25.1.0.aar 文件上,但是当我添加 support-compat-25.1.0.aar 时,错误是消失了,现在它正在工作。并且不再需要support.v4.25.1.0.aar...

关于java - Unity 插件在使用通知 Compat Builder 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41315012/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com