gpt4 book ai didi

android - VideoView.setOnPreparedListener() 的 NoSuchMethodError

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:46:53 28 4
gpt4 key购买 nike

我在使用 Proguard 和我的应用的自定义 VideoView 时遇到问题。似乎混淆我的代码会导致我的 VideoView 出现问题。每当我尝试为视频设置 OnPreparedListener 时,我的应用程序都会崩溃。见:

11-13 15:54:45.881  19428-19428/com.<REDACTED> E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.<REDACTED>, PID: 19428
java.lang.NoSuchMethodError: No virtual method setOnPreparedListener(Landroid/media/MediaPlayer$e;)V in class Landroid/widget/VideoView; or its super classes (declaration of 'android.widget.VideoView' appears in /system/framework/framework.jar:classes2.dex)
at com.<REDACTED>.ui.module.MHVideoPlayerModule.initializeVideoPlayer(MHVideoPlayerModule.java:174)
at com.<REDACTED>.ui.module.MHVideoPlayerModule.initializeViewData(MHVideoPlayerModule.java:154)
at com.<REDACTED>.ui.activity.MHVideoDetailActivity.a(MHVideoDetailActivity.java:198)
at com.<REDACTED>.ui.activity.MHVideoDetailActivity.b(MHVideoDetailActivity.java:171)
at com.<REDACTED>.ui.activity.MHVideoDetailActivity.a_(MHVideoDetailActivity.java:255)
at com.<REDACTED>.service.f.al.b(MHVideoUrlTaskManager.java:131)
at com.<REDACTED>.service.a.e.onPostExecute(MHAsyncServiceTask.java:194)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
...

我已经尝试将以下行添加到 Proguard 文件中,但它们没有帮助。

-keep class com.<REDACTED>.ui.module.MHVideoPlayerModule { *; }
-keep class android.widget.VideoView { *; }

编辑:这是 proguard-project.txt 文件:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
-keepclassmembers class com.<REDACTED>.common.JavaScriptInterface {
public *;
}

# Google Play Services start
# https://developer.android.com/google/play-services/setup.html
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
# Google Play Services end

-dontwarn javax.jdo.**
-dontwarn javax.naming.**
-dontwarn com.google.api.client.googleapis.extensions.android.gms.**
-dontwarn com.google.android.gms.**
-dontwarn com.squareup.okhttp.**

-keep public class android.net.http.SslError
-keep public class android.webkit.WebViewClient
-keep public class android.widget.VideoView

-dontwarn android.webkit.WebView
-dontwarn android.net.http.SslError
-dontwarn android.webkit.WebViewClient
-dontwarn android.media.MediaPlayer
-dontwarn android.widget.VideoView

-dontwarn org.bouncycastle.**
-dontwarn org.apache.commons.codec.binary.Base64

-keepattributes SourceFile,LineNumberTable
-printusage build/outputs/proguard/unused.txt
-printconfiguration build/outputs/proguard/configuration.txt

-libraryjars libs

-keep class com.crashlytics.** { *; }
-keep class io.fabric.** { *; }
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.facebook.** { *; }

# New Relic start
# https://docs.newrelic.com/docs/mobile-monitoring/mobile-monitoring-installation/android/installing-android-apps-gradle-android-studio#proguard
-keep class com.newrelic.** { *; }
-dontwarn com.newrelic.**
-keepattributes Exceptions, Signature, InnerClasses
# New Relic end

-dontshrink

最佳答案

看来您还提供了自定义 android.media.MediaPlayer 和/或 android.media.MediaPlayer.OnPreparedListener 实现:

java.lang.NoSuchMethodError: No virtual method setOnPreparedListener(Landroid/media/MediaPlayer$e;)V in class Landroid/widget/VideoView; or its super classes (declaration of 'android.widget.VideoView' appears in /system/framework/framework.jar:classes2.dex)

setOnPreparedListener -- 您正在调用的方法

(L -- 对象的 smali 前缀

android/media/MediaPlayer$e -- 您尝试传递给方法的实际类型名称。 这就是问题所在。 内部类类型 OnPreparedListener 被混淆了。它应该是 android/media/MediaPlayer$OnPreparedListener

android/widget/VideoView 尝试托管此方法签名的类。


您是否有使用原始包名称的自定义 MediaPlayerMediaPlayer.OnPreparedListener?如果是这样,您还需要将它们从 Proguard 中排除。像这样的东西:

-keep class android.media.** { *; }

关于android - VideoView.setOnPreparedListener() 的 NoSuchMethodError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26919327/

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