Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Require users to use AGP 8 if using the latest Flutter SDK #18

Closed
joshuadeguzman opened this issue Jul 29, 2024 · 5 comments
Closed

Comments

@joshuadeguzman
Copy link

Description

We're currently using Android Gradle Plugin (AGP) 7.6.3. When we try to run flutter build apk, it throws a build error for having a nullable R8 issue, related to the AGP v8 migration in the Android SDK.

Attachments

Here's the error logs that we get:

ERROR:/Users/joshua/.gradle/caches/transforms-3/737b2f8aceb183fbf88a8d49781f16d3/transformed/jetified-appcompat-re
sources-1.7.0-runtime.jar: R8: java.lang.NullPointerException
[  +1 ms] FAILURE: Build failed with an exception.
[    ] * What went wrong:
[    ] Execution failed for task ':app:minifyDevReleaseWithR8'.
[    ] > A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
[    ]  > Compilation failed to complete, origin:
/Users/joshua/.gradle/caches/transforms-3/737b2f8aceb183fbf88a8d49781f16d3/transformed/jetified-appcompat-resource
s-1.7.0-runtime.jar:androidx/appcompat/graphics/drawable/DrawableContainerCompat$1.class
[    ] * Try:
[    ] > Run with --debug option to get more log output.
[    ] > Run with --scan to get full insights.
[    ] * Exception is:
[    ] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:minifyDevReleaseWithR8'.
[    ] at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecu
ter.java:142)
[    ] at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)

It throws an unrelated R8 error but somehow it didn't expose the actual issue. So we went ahead and check the SDK changelog, and crossmatch it with the native SDKs.

NOTE: However, we were unable to use the latest Flutter 1.2.0 just yet because there are at least two plugins that needs to support AGP 8 like image_gallery_saver and facebook_app_events.

Proposal

I propose we update the docs and remind the users to use the latest AGP version in the Installing SDK step:

distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip

I went through the Android SDK PR changes, and saw that the AGP was using the 8.5 version. Good thing is that the Flutter SDK Changelog does match the changes happening on the native plugins so I was able to see the changes.

Thanks!

@joshuadeguzman joshuadeguzman changed the title [docs] Require users to use AGP 8 if using the latest Flutter SDk [docs] Require users to use AGP 8 if using the latest Flutter SDK Jul 29, 2024
@joshuadeguzman
Copy link
Author

We are able to build using superwall_flutter: 1.1.8:

[+1232 ms] ✓  Built build/app/outputs/flutter-apk/app-dev-release.apk (135.5MB).
[        ] "flutter apk" took 141,327ms.
[ +162 ms] ensureAnalyticsSent: 114ms
[        ] Running 0 shutdown hooks
[        ] Shutdown hooks complete
[   +1 ms] exiting with code 0

@ianrumac
Copy link
Contributor

Hey @joshuadeguzman !
Thanks for the suggestion, added it to docs and will be live soon!

Regarding not being able to update due to image_gallery_saver and facebook_app_events, you can try something similar to the following in your build.gradle:

subprojects {

   ...
    afterEvaluate { project ->
            if (project.hasProperty("android")) {
                android {
                    compileSdk = 34
                    compileOptions {
                        sourceCompatibility JavaVersion.VERSION_17
                        targetCompatibility JavaVersion.VERSION_17
                    }
                    if (project.plugins.hasPlugin("kotlin-android"))
                        tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
                            kotlinOptions.jvmTarget = "17"
                        }
                }
          }
    }
}

While not a perfect solution, it could help until the library owners update their respective targets.

@ianrumac
Copy link
Contributor

Resolving the issue as new docs are live!

@joshuadeguzman
Copy link
Author

Thank you @ianrumac !! I saw the doc changes, it's pretty neat! I hope this will help more developers who will integrate Superwall!

https://superwall.com/docs/installation-via-pubspec#android-configuration

@colbymaloy
Copy link

@ianrumac maybe you guys should update your god forsaken docs as well. one of your quick start guides put me on superwall kit 0.0.27....not the latest version. i just lost 6 hours because of this. ffs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants