binwiederhier / ntfy-android

Android app for ntfy.sh
Apache License 2.0
465 stars 92 forks source link

Disable tasks for processing google services for variants which do not use them #42

Closed markosopcic closed 1 year ago

markosopcic commented 1 year ago

Application currently cannot be built if you do not have a google-services.json file, even the fdroid flavor which doesnt use google services. This PR disables the process GoogleServices gradle tasks which fail for all variants which aren't a part of the play flavor, e.g. the fdroid flavor.

binwiederhier commented 1 year ago

My gradle knowledge is pretty bad, so I appreciate this PR a lot. Thank you.

For F-Droid, I'm currently telling people to run this sed (https://ntfy.sh/docs/develop/#build-f-droid-flavor-no-fcm):

# Remove Google dependencies (FCM)
sed -i -e '/google-services/d' build.gradle
sed -i -e '/google-services/d' app/build.gradle

# To build an unsigned .apk (app/build/outputs/apk/fdroid/*.apk)
./gradlew assembleFdroidRelease

# To build a bundle .aab (app/fdroid/release/*.aab)
./gradlew bundleFdroidRelease

Would this PR make that obsolete? This sed is also used in the F-Droid build process (https://gitlab.com/fdroid/fdroiddata/-/blob/master/metadata/io.heckel.ntfy.yml#L191), which is very common there.

markosopcic commented 1 year ago

No problem, glad I can help!

So just to confirm what you said, I did the following:

  1. On your original source code, I ran `sed -i -e '/google-services/d' build.gradle sed -i -e '/google-services/d' app/build.gradle

./gradlew clean assembleFdroidRelease` to get the first APK.

  1. On my PR version, without running the sed commands, I also ran ./gradlew clean assembleFdroidRelease to get the second APK.

  2. I then diff-ed them using the diff tool, and also using the Android Studio built in APK analyzer which can compare two APKs - and found no difference's at all.

image

So I think it's safe to say that yes, my PR would make the process of running those sed commands obsolete for someone who wants to build the fdroid version - since both versions/processes generate the same APK down to every last bit. And the play version should stay the same since the task to process google services will stay enabled for the variants with the play flavor.

markosopcic commented 1 year ago

@binwiederhier can we merge this then? 😄

binwiederhier commented 1 year ago

Oops yes. I had the tab open for a while. I'll do it this week. I want to try it out myself first. I just did some Android build and dep-upgrade work, so this is a welcome addition.

binwiederhier commented 1 year ago

I do have to make sure that the FDroid build doesn't break, or clean that up too.

markosopcic commented 1 year ago

Of course, I just wanted to follow up on this to see if you need anything else from me. As much as i've tested the f droid variant works as intended.

binwiederhier commented 1 year ago

Thanks!