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

Migrate to the Android Gradle Plugin's new variant APIs #269

Open
jschear opened this issue Sep 3, 2021 · 4 comments
Open

Migrate to the Android Gradle Plugin's new variant APIs #269

jschear opened this issue Sep 3, 2021 · 4 comments

Comments

@jschear
Copy link
Contributor

jschear commented Sep 3, 2021

AGP 4+ contains new APIs for accessing build variants (and the APKs produced for each of them), and the existing APIs have been deprecated.

The main differences appear to be:

  • com.android.build.gradle.api.TestVariant has been replaced by com.android.build.api.variant.AndroidTest.
  • Instead of using com.android.build.gradle.AppExtension and com.android.build.gradle.TestedExtension to access build variants, one needs to use com.android.build.api.variant.ApplicationAndroidComponentsExtension to access com.android.build.api.variant.ApplicationVariant, which has a androidTest: AndroidTest? property for the corresponding instrumentation test variant. (And com.android.build.api.variant.LibraryAndroidComponentsExtension to access com.android.build.api.variant.LibraryVariant.)
  • ApplicationVariant, LibraryVariant, and AndroidTest expose their outputs as com.android.build.api.variant.VariantOutputs, but there's no longer a way to get the path to each APK output via that API. Instead, one has to use the com.android.build.api.artifact.Artifacts API to access a DirectoryProperty for the folder the APKs are placed in, and use BuiltArtifactsLoader to access the outputs within a task action.

I've taken a stab at the update here, but the BuiltArtifactsLoader change is a bit tricky: master...jschear:js/agp_7

@runningcode
Copy link
Owner

Thanks for filing. This is a good idea. 👍
I'll try to take a look at your solution soon.

@jstewart5000
Copy link

👋🏾 @runningcode Curious if there is an ETA on this migration? If you are super swamped @jschear and I might look into making this one happen. Let us know whenever you get a chance 😃

@runningcode
Copy link
Owner

Hey, sorry there's no ETA on this. Sorry I haven't got a chance to look at it. October is a busy month for me but perhaps later I will be able to take a look at it. Feel free to contribute or pick up the PR.

@jschear
Copy link
Contributor Author

jschear commented Oct 14, 2021

Sounds good -- thanks for the update. We've been looking at making some other changes (in short: our app uses ABI splits, which fladle/fulladle doesn't handle right now), and were having trouble deciding between implementing them using the old AGP APIs, or upgrading to the new APIs first.

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