Open OttomanDeveloper opened 1 year ago
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:
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.
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.
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.
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.
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:
Error Logs:
Any help in resolving this issue would be greatly appreciated.
Expected Behavior
No response
How to Reproduce
To reproduce the issue:
Ensure you have the latest versions of the
video_player
andapplovin_max
packages in your Flutter app.Create a screen in your app where you have both the video player and the ad.
Play a video using the
video_player
package.Attempt to load an ad using the AppLovin SDK after the video starts playing.
Observe that the app crashes with the following error:
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