Skip to content

[FSSDK-11888] fix: update ProGuard rules for AGP 8+ and R8 compatibility #281

[FSSDK-11888] fix: update ProGuard rules for AGP 8+ and R8 compatibility

[FSSDK-11888] fix: update ProGuard rules for AGP 8+ and R8 compatibility #281

Workflow file for this run

name: flutter sdk
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
# workflow_dispatch:
# inputs:
# sdk_branch:
# description: "Specify the SDK branch"
# required: false
# default: "master"
# testapp_branch:
# description: "Specify the test app branch"
# required: false
# default: "master"
jobs:
unit_test_coverage:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
architecture: x64
- name: Install app dependencies
run: flutter pub get
- name: Test app
run: flutter test --coverage
- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
integration_android_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# You should create a personal access token and store it in your repository
token: ${{ secrets.CI_USER_TOKEN }}
repository: 'optimizely/travisci-tools'
path: 'home/runner/travisci-tools'
ref: 'master'
# Set SDK Branch based on input or PR/Push
# - name: Set SDK Branch and Test App Branch
# run: |
# # If manually triggered
# if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
# echo "SDK_BRANCH=${{ github.event.inputs.sdk_branch || 'master' }}" >> $GITHUB_ENV
# echo "TESTAPP_BRANCH=${{ github.event.inputs.testapp_branch || 'master' }}" >> $GITHUB_ENV
# # If triggered by PR
# elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
# echo "SDK_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
# # If triggered by push
# else
# echo "SDK_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
# echo "TRAVIS_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
# fi
- name: set SDK Branch if PR
env:
HEAD_REF: ${{ github.head_ref }}
if: ${{ github.event_name == 'pull_request' }}
run: |
echo "SDK_BRANCH=$HEAD_REF" >> $GITHUB_ENV
- name: set SDK Branch if not pull request
env:
REF_NAME: ${{ github.ref_name }}
if: ${{ github.event_name != 'pull_request' }}
run: |
echo "SDK_BRANCH=$REF_NAME" >> $GITHUB_ENV
echo "TRAVIS_BRANCH=$REF_NAME" >> $GITHUB_ENV
- name: Trigger build
env:
SDK: android
BUILD_NUMBER: ${{ github.run_id }}
TESTAPP_BRANCH: master
GITHUB_TOKEN: ${{ secrets.CI_USER_TOKEN }}
EVENT_TYPE: ${{ github.event_name }}
REPO_SLUG: 'optimizely/optimizely-flutter-testapp'
PULL_REQUEST_SLUG: ${{ github.repository }}
UPSTREAM_REPO: ${{ github.repository }}
PULL_REQUEST_SHA: ${{ github.event.pull_request.head.sha }}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
UPSTREAM_SHA: ${{ github.sha }}
TOKEN: ${{ secrets.CI_USER_TOKEN }}
EVENT_MESSAGE: ${{ github.event.message }}
HOME: 'home/runner'
run: |
home/runner/travisci-tools/trigger-script-with-status-update.sh
integration_ios_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# You should create a personal access token and store it in your repository
token: ${{ secrets.CI_USER_TOKEN }}
repository: 'optimizely/travisci-tools'
path: 'home/runner/travisci-tools'
ref: 'master'
- name: set SDK Branch if PR
env:
HEAD_REF: ${{ github.head_ref }}
if: ${{ github.event_name == 'pull_request' }}
run: |
echo "SDK_BRANCH=$HEAD_REF" >> $GITHUB_ENV
- name: set SDK Branch if not pull request
env:
REF_NAME: ${{ github.ref_name }}
if: ${{ github.event_name != 'pull_request' }}
run: |
echo "SDK_BRANCH=$REF_NAME" >> $GITHUB_ENV
echo "TRAVIS_BRANCH=$REF_NAME" >> $GITHUB_ENV
- name: Trigger build
env:
SDK: ios
BUILD_NUMBER: ${{ github.run_id }}
TESTAPP_BRANCH: master
GITHUB_TOKEN: ${{ secrets.CI_USER_TOKEN }}
EVENT_TYPE: ${{ github.event_name }}
REPO_SLUG: 'optimizely/optimizely-flutter-testapp'
PULL_REQUEST_SLUG: ${{ github.repository }}
UPSTREAM_REPO: ${{ github.repository }}
PULL_REQUEST_SHA: ${{ github.event.pull_request.head.sha }}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
UPSTREAM_SHA: ${{ github.sha }}
TOKEN: ${{ secrets.CI_USER_TOKEN }}
EVENT_MESSAGE: ${{ github.event.message }}
HOME: 'home/runner'
run: |
home/runner/travisci-tools/trigger-script-with-status-update.sh
build_test_android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: 'stable' # or: 'beta' or 'master'
cache: true
cache-key: 'flutter-:os:-:arch:-:channel:-:version:-:hash:' # optional, change this to force refresh cache
cache-path: ${{ runner.tool_cache }}/flutter # optional, change this to specify the cache path
architecture: x64 # optional, x64 or arm64
- run: flutter --version
- name: Setup java
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.0.5'
- run: flutter pub get
- run: flutter test
build_test_ios:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
architecture: x64
- run: flutter pub get
- run: flutter test
# Minification Compatibility Test
minification_compatibility_test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
architecture: x64
cache: true
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: Install dependencies
run: |
flutter pub get
cd example && flutter pub get
- name: Create ProGuard rules for example app
run: |
cat > example/android/app/proguard-rules.pro << 'EOF'
# Example app ProGuard rules for minification testing
# Keep example app classes
-keep class com.optimizely.optimizely_flutter_sdk_example.** { *; }
# Keep Flutter classes
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugins.GeneratedPluginRegistrant { *; }
# Google Play Core (for Flutter engine)
-keep class com.google.android.play.core.** { *; }
-dontwarn com.google.android.play.core.**
# Additional safety for Optimizely (redundant but safe)
-keep class com.optimizely.** { *; }
-dontwarn com.optimizely.**
# Jackson JSON
-keep class com.fasterxml.jackson.** { *; }
-dontwarn com.fasterxml.jackson.**
# Ignore missing classes
-dontwarn javax.mail.**
-dontwarn javax.activation.**
EOF
- name: Test with minification ENABLED
run: |
echo "🧪 Testing with minifyEnabled = true"
# Backup original build.gradle
cp example/android/app/build.gradle example/android/app/build.gradle.backup
# Enable minification and ensure ProGuard rules are referenced
sed -i 's/minifyEnabled false/minifyEnabled true/' example/android/app/build.gradle
sed -i 's/shrinkResources false/shrinkResources true/' example/android/app/build.gradle
# Ensure ProGuard rules are applied
if ! grep -q "proguardFiles.*proguard-rules.pro" example/android/app/build.gradle; then
sed -i '/minifyEnabled true/a\ proguardFiles getDefaultProguardFile('\''proguard-android-optimize.txt'\''), '\''proguard-rules.pro'\''' example/android/app/build.gradle
fi
echo "📄 Build configuration with minification:"
grep -A 5 "buildTypes" example/android/app/build.gradle
# Build release APK
cd example
flutter build apk --release --verbose
echo "✅ Build successful with minification ENABLED"
- name: Test with minification DISABLED
run: |
echo "🧪 Testing with minifyEnabled = false"
# Restore original and disable minification
cp example/android/app/build.gradle.backup example/android/app/build.gradle
sed -i 's/minifyEnabled true/minifyEnabled false/' example/android/app/build.gradle
sed -i 's/shrinkResources true/shrinkResources false/' example/android/app/build.gradle
echo "📄 Build configuration without minification:"
grep -A 5 "buildTypes" example/android/app/build.gradle
# Clean and build again
cd example
flutter clean
flutter build apk --release --verbose
echo "✅ Build successful with minification DISABLED"
- name: Run unit tests
run: |
echo "🧪 Running unit tests to verify SDK functionality"
flutter test
- name: Verify APK artifacts
run: |
echo "📱 Checking APK files were created:"
ls -la example/build/app/outputs/apk/release/
# Check APK size
if [ -f "example/build/app/outputs/apk/release/app-release.apk" ]; then
APK_SIZE=$(stat -c%s example/build/app/outputs/apk/release/app-release.apk 2>/dev/null || stat -f%z example/build/app/outputs/apk/release/app-release.apk)
echo "📊 Final APK Size: $(($APK_SIZE / 1024 / 1024)) MB"
fi
- name: Check for ProGuard artifacts
run: |
echo "🔍 Checking for ProGuard/R8 artifacts:"
# Look for mapping files
if [ -f "example/build/app/outputs/mapping/release/mapping.txt" ]; then
echo "✅ ProGuard mapping file found"
echo "📄 Mapping file size: $(wc -l < example/build/app/outputs/mapping/release/mapping.txt) lines"
else
echo "ℹ️ No mapping file found (expected if minification was disabled)"
fi
- name: Upload APK artifacts
uses: actions/upload-artifact@v4
with:
name: minification-test-apk
path: |
example/build/app/outputs/apk/release/app-release.apk
example/build/app/outputs/mapping/release/mapping.txt
retention-days: 7
- name: Report test results
run: |
echo "🎉 Minification compatibility test completed successfully!"
echo "✅ minifyEnabled = true: PASSED"
echo "✅ minifyEnabled = false: PASSED"
echo "✅ Your Optimizely Flutter SDK is minification-compatible!"
echo ""
echo "This confirms that:"
echo " • Library ProGuard rules are working correctly"
echo " • Plugin registration survives minification"
echo " • No critical classes are being stripped"
echo " • Customer's issue should be resolved"
- name: Cleanup
if: always()
run: |
# Restore original build.gradle if backup exists
if [ -f "example/android/app/build.gradle.backup" ]; then
mv example/android/app/build.gradle.backup example/android/app/build.gradle
echo "✅ Restored original build.gradle"
fi