发布模式下视频播放和插页广告的问题

huangapple go评论69阅读模式
英文:

Issue with video playback and interstitial ad in release mode

问题

MAX插件版本

2.5.0

Flutter版本

3.10.2

设备/平台信息

Poco X3 Pro Android 13和其他设备。

当前行为

我遇到了一个问题,当尝试在使用video_player包播放视频时加载广告时,我的应用程序会崩溃。广告在其他屏幕上成功加载,但只有在尝试播放视频并显示插页广告时才会出现此问题。

有趣的是,我只在发行模式下遇到这个问题,而在调试模式下却没有。

我的应用程序中使用的包:

  • video_player:^2.6.1
  • applovin_max:^2.5.0
  • flutter_local_notifications:^14.1.0
  • onesignal_flutter:^3.5.1

错误日志:

E/AndroidRuntime(30065): FATAL EXCEPTION: pool-16-thread-1
...

...

E/AndroidRuntime(30065): Caused by: java.lang.IllegalStateException: Failed to create VMBridge instance
...

...

对于解决此问题的任何帮助,将不胜感激。

期望的行为

没有回应

如何重现

要重现此问题:

  1. 确保在Flutter应用程序中安装了video_playerapplovin_max包的最新版本。

    • video_player: ^2.6.1
    • applovin_max: ^2.5.0
  2. 在应用程序中创建一个屏幕,其中包含视频播放器和广告。

  3. 使用video_player包播放视频。

  4. 尝试在视频开始播放后使用AppLovin SDK加载广告。

  5. 观察到应用程序崩溃,并显示以下错误:

E/AndroidRuntime(30065): FATAL EXCEPTION: pool-16-thread-1
...

...

E/AndroidRuntime(30065): java.lang.NoClassDefFoundError: k9.w3
...

请注意,此问题特定发生在Android上,而且只在发行模式下,而不是调试模式下。

重要的是要提到,这个问题发生在尝试在使用video_player包播放视频后加载广告时。在其他屏幕上广告成功加载,这表明问题特定于视频播放和广告加载的组合。

通过按照上述步骤,开发人员应能够理解和重现此问题,以便有效地进行调查和解决。

其他信息

没有回应

英文:

MAX Plugin Version

2.5.0

Flutter Version

3.10.2

Device/Platform Info

Poco X3 Pro Android 13 and Also other devices.

Current Behavior

I encountered an issue where my app crashes when trying to load an ad while playing a video using the video_player package. The ads load successfully on other screens, but this issue occurs specifically when attempting to play a video and show the interstitial ad.

Interestingly, I don't encounter this issue in debug mode, only in release mode.

Packages used in my app:

  • video_player: ^2.6.1
  • applovin_max: ^2.5.0
  • flutter_local_notifications: ^14.1.0
  • onesignal_flutter: ^3.5.1

Error Logs:

E/AndroidRuntime(30065): FATAL EXCEPTION: pool-16-thread-1
E/AndroidRuntime(30065): Process: com.videodownloader.udownload, PID: 30065
E/AndroidRuntime(30065): java.lang.NoClassDefFoundError: k9.w3
E/AndroidRuntime(30065):        at k9.n.o(Unknown Source:0)
E/AndroidRuntime(30065):        at ua.a.b(Unknown Source:40)
E/AndroidRuntime(30065):        at pa.y.c(Unknown Source:21)
E/AndroidRuntime(30065):        at pa.y.a(Unknown Source:35)
E/AndroidRuntime(30065):        at qa.e1.T0(Unknown Source:0)
E/AndroidRuntime(30065):        at qa.e1.c0(Unknown Source:106)
E/AndroidRuntime(30065):        at qa.e1.M0(Unknown Source:18)
E/AndroidRuntime(30065):        at qa.e1.Q(Unknown Source:0)
E/AndroidRuntime(30065):        at qa.u0.apply(Unknown Source:10)
E/AndroidRuntime(30065):        at j$.util.stream.d2.accept(SourceFile:0)
E/AndroidRuntime(30065):        at j$.util.stream.d2.accept(SourceFile:0)
E/AndroidRuntime(30065):        at j$.util.stream.d2.accept(SourceFile:0)
E/AndroidRuntime(30065):        at j$.util.a.forEachRemaining(SourceFile:0)
E/AndroidRuntime(30065):        at j$.util.stream.c.f0(SourceFile:0)
E/AndroidRuntime(30065):        at j$.util.stream.c.I0(Unknown Source:10)
E/AndroidRuntime(30065):        at j$.util.stream.U.y(SourceFile:0)
E/AndroidRuntime(30065):        at j$.util.stream.c.L0(SourceFile:0)
E/AndroidRuntime(30065):        at j$.util.stream.k2.forEach(SourceFile:0)
E/AndroidRuntime(30065):        at j$.util.stream.g2.accept(Unknown Source:24)
E/AndroidRuntime(30065):        at j$.util.Y.forEachRemaining(Unknown Source:20)
E/AndroidRuntime(30065):        at j$.util.stream.c.f0(SourceFile:0)
E/AndroidRuntime(30065):        at j$.util.stream.c.I0(Unknown Source:10)
E/AndroidRuntime(30065):        at j$.util.stream.U.y(SourceFile:0)
E/AndroidRuntime(30065):        at j$.util.stream.c.L0(SourceFile:0)
E/AndroidRuntime(30065):        at j$.util.stream.k2.forEachOrdered(SourceFile:0)
E/AndroidRuntime(30065):        at qa.e1.m0(Unknown Source:70)
E/AndroidRuntime(30065):        at qa.e1.r(Unknown Source:13)
E/AndroidRuntime(30065):        at k1.a.g(Unknown Source:26)
E/AndroidRuntime(30065):        at i1.b$a.run(Unknown Source:210)
E/AndroidRuntime(30065):        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
E/AndroidRuntime(30065):        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
E/AndroidRuntime(30065):        at java.lang.Thread.run(Thread.java:1012)
E/AndroidRuntime(30065): Caused by: java.lang.ExceptionInInitializerError
E/AndroidRuntime(30065):        at k9.n.m(Unknown Source:0)
E/AndroidRuntime(30065):        at k9.n.l(Unknown Source:5)
E/AndroidRuntime(30065):        at ua.a.b(Unknown Source:0)
E/AndroidRuntime(30065):        ... 30 more
E/AndroidRuntime(30065): Caused by: java.lang.IllegalStateException: Failed to create VMBridge instance
E/AndroidRuntime(30065):        at k9.w3.d(Unknown Source:36)
E/AndroidRuntime(30065):        at k9.w3.<clinit>(Unknown Source:0)
E/AndroidRuntime(30065):        ... 33 more

Any help in resolving this issue would be greatly appreciated.

Expected Behavior

No response

How to Reproduce

To reproduce the issue:

  1. Ensure you have the latest versions of the video_player and applovin_max packages in your Flutter app.

    • video_player: ^2.6.1
    • applovin_max: ^2.5.0
  2. Create a screen in your app where you have both the video player and the ad.

  3. Play a video using the video_player package.

  4. Attempt to load an ad using the AppLovin SDK after the video starts playing.

  5. Observe that the app crashes with the following error:

E/AndroidRuntime(30065): FATAL EXCEPTION: pool-16-thread-1
E/AndroidRuntime(30065): Process: com.videodownloader.udownload, PID: 30065
E/AndroidRuntime(30065): java.lang.NoClassDefFoundError: k9.w3
...

Please note that this issue occurs specifically on Android and is not reproducible in debug mode but only in release mode.

It's important to mention that this issue is observed when trying to load the ad after playing a video using the video_player package. Ads load successfully on other screens, indicating that the issue is specific to the combination of video playback and ad loading.

By following the steps above, developers should be able to understand and reproduce the issue in order to investigate and resolve it effectively.

Additional Info

No response

答案1

得分: 0

解决方案

经过广泛的研究和故障排除,我成功解决了该问题,方法是添加ProGuard规则并修改构建配置。以下是我遵循的步骤:

1. 创建ProGuard规则文件

android/app目录下创建一个名为proguard-rules.pro的文件。此文件将包含必要的ProGuard规则,以保留特定类并防止混淆。

2. 添加ProGuard规则

proguard-rules.pro文件中,添加以下ProGuard规则:

-keep class org.schabi.newpipe.extractor.** { *; }
-keep class org.ocpsoft.prettytime.i18n.** { *; }
-keep class org.mozilla.javascript.** { *; }
-keep class org.mozilla.classfile.ClassFileWriter
-keep class com.google.android.exoplayer2.** { *; }
-dontwarn org.mozilla.javascript.tools.**
-dontwarn android.arch.util.paging.CountedDataSource
-dontwarn android.arch.persistence.room.paging.LimitOffsetDataSource
-keep class com.artxdev.** { *; }
-keep class androidx.lifecycle.** { *; }
-keep class org.jaudiotagger.** { *; }
-keep class com.example.audio_tagger.** { *; }
-dontobfuscate

## Flutter wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }

# -keep class com.google.firebase.** { *; } // 如果在项目中使用firebase,请取消注释此行

-keep class com.arthenica.mobileffmpeg.Config {
    native <methods>;
    void log(long, int, byte[]);
    void statistics(long, int, float, float, long , int, double, double);
}

-keep class com.arthenica.mobileffmpeg.AbiDetect {
    native <methods>;
}

# OkHttp的规则。从https://github.com/square/okhttp复制粘贴
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn javax.annotation.**
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    !static !transient <fields>;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
}

这些规则将保留必要的类并防止与混淆相关的任何问题。

3. 修改构建配置

android/app/build.gradle文件中,找到buildTypes部分,并在release构建类型下添加proguardFiles指令。将配置更新如下:

buildTypes {
    release {
        // TODO: 为发布版本构建添加自己的签名配置。
        // 现在使用调试密钥进行签名,以便“flutter run --release”正常工作。


        signingConfig signingConfigs.release
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

此修改确保在构建应用的发布版本时应用ProGuard规则。

4. 添加所需的仓库

如果您在播放在线视频时使用newpipeextractor库,请确保在android/app/build.gradle文件的顶部添加以下仓库:

repositories {
    maven { url "https://jitpack.io" }
    mavenCentral()
}

这些仓库是获取newpipeextractor库所需依赖项的必要部分。

通过按照这些步骤,我成功解决了问题,并防止了应用在视频播放期间加载广告时崩溃。这些更改确保了必需的类得以保留,并防止与混淆相关的任何冲突。

希望这个解决方案对其他遇到类似问题的人有所帮助。

英文:

Solution

After extensive research and troubleshooting, I was able to resolve the issue by adding ProGuard rules and modifying the build configuration. Here are the steps I followed:

1. Create a ProGuard Rule File

Under the android/app directory, create a file named proguard-rules.pro. This file will contain the necessary ProGuard rules to retain specific classes and prevent obfuscation.

2. Add ProGuard Rules

Inside the proguard-rules.pro file, add the following ProGuard rules:

-keep class org.schabi.newpipe.extractor.** { *; }
-keep class org.ocpsoft.prettytime.i18n.** { *; }
-keep class org.mozilla.javascript.** { *; }
-keep class org.mozilla.classfile.ClassFileWriter
-keep class com.google.android.exoplayer2.** { *; }
-dontwarn org.mozilla.javascript.tools.**
-dontwarn android.arch.util.paging.CountedDataSource
-dontwarn android.arch.persistence.room.paging.LimitOffsetDataSource
-keep class com.artxdev.** { *; }
-keep class androidx.lifecycle.** { *; }
-keep class org.jaudiotagger.** { *; }
-keep class com.example.audio_tagger.** { *; }
-dontobfuscate

## Flutter wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }

# -keep class com.google.firebase.** { *; } // uncomment this if you are using firebase in the project

-keep class com.arthenica.mobileffmpeg.Config {
    native <methods>;
    void log(long, int, byte[]);
    void statistics(long, int, float, float, long , int, double, double);
}

-keep class com.arthenica.mobileffmpeg.AbiDetect {
    native <methods>;
}

# Rules for OkHttp. Copy-paste from https://github.com/square/okhttp
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn javax.annotation.**
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    !static !transient <fields>;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
}

These rules will preserve the necessary classes and prevent any issues related to obfuscation.

3. Modify the Build Configuration

Inside the android/app/build.gradle file, locate the buildTypes section and add the proguardFiles directive under the release build type. Update the configuration as follows:

buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so `flutter run --release` works.


        signingConfig signingConfigs.release
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

This modification ensures that the ProGuard rules are applied when building the release version of the app.

4. Add Required Repositories

If you're using the newpipeextractor library for playing online videos, make sure to add the following repositories at the top of the android/app/build.gradle file:

repositories {
    maven { url "https://jitpack.io" }
    mavenCentral()
}

These repositories are required to fetch the necessary dependencies for the newpipeextractor library.

By following these steps, I was able to resolve the issue and prevent the app from crashing when loading ads during video playback. These changes ensure that the required classes are retained and prevent any conflicts related to obfuscation.

I hope this solution helps others facing a similar issue.

huangapple
  • 本文由 发表于 2023年5月28日 13:19:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76350051.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定