我在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
答案 0 :(得分:4)
您似乎还提供自定义android.media.MediaPlayer
和/或android.media.MediaPlayer.OnPreparedListener
实施:
java.lang.NoSuchMethodError:没有虚拟方法setOnPreparedListener(Landroid / media / MediaPlayer $ e;)V类Landroid / widget / VideoView;或其超级类(声明&#39; android.widget.VideoView&#39;出现在/system/framework/framework.jar:classes2.dex)
setOnPreparedListener
- 您正在调用的方法
(L
- 对象的 smali 前缀
android/media/MediaPlayer$e
- 您尝试传入方法的实际类型名称。 这是问题。内部类类型OnPreparedListener
正在被混淆。它应该是android/media/MediaPlayer$OnPreparedListener
android/widget/VideoView
尝试托管此方法签名的类。
您是否拥有使用原始包名称的自定义MediaPlayer
或MediaPlayer.OnPreparedListener
?如果是这样,您还需要从Proguard中排除那些。类似的东西:
-keep class android.media.** { *; }
答案 1 :(得分:1)
只需在&#34; proguard-project.txt#34中插入以下内容即可查看;文件
-keep class android.widget.** { *; }