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

feat(android): foss compliant build for F-Droid #87

Merged
merged 6 commits into from
Jul 3, 2024

Conversation

azarz
Copy link
Member

@azarz azarz commented Jun 28, 2024

Add a fdroid flavor for builds that does not depend on Google services.

@azarz azarz mentioned this pull request Jun 28, 2024
@licaon-kter
Copy link
Contributor

...but it should not depend at build time either

this recipe metadata/fr.ign.geoportail.yml

License: GPLv3
SourceCode: https://github.com/IGNF/cartes-ign-app
IssueTracker: https://github.com/IGNF/cartes-ign-app/issues

AutoName: geoportail-app
Description: Application Géoportail

RepoType: git
Repo: https://github.com/IGNF/cartes-ign-app

Builds:
  - versionName: 3.1.0
    versionCode: 30100
    commit: 5a3ebbf4bea3aa7e678a2917e241919d0042a3e4
    subdir: android/app
    sudo:
      - sysctl fs.inotify.max_user_watches=524288 || true
      - apt-get update
      - apt-get install -y make npm
    gradle:
      - fdroid
    rm:
      - android/app/build_google.gradle
    prebuild:
      - sed -i -e '/gms/d' ../build.gradle
      - cd ../..
      - npm install --build-from-source
      - npm run build
      - npx cap sync
      - sed -i -e '/gms/d' node_modules/@capacitor/geolocation/android/build.gradle
    scandelete:
      - node_modules

AutoUpdateMode: None
UpdateCheckMode: Tags

will fail... kinda as expected, right? As I'm removing all the proprietary bits before building...

> Task :capacitor-geolocation:compileReleaseJavaWithJavac FAILED
/home/vagrant/build/fr.ign.geoportail/node_modules/@capacitor/geolocation/android/src/main/java/com/capacitorjs/plugins/geolocation/Geolocation.java:8: error: package com.google.android.gms.common does not exist
import com.google.android.gms.common.ConnectionResult;
,,,

...yet @capacitor/geolocation still depends on them

@azarz
Copy link
Member Author

azarz commented Jul 2, 2024

Is it possible in the prebuild section of the recipe to remove the line

 "@capacitor/geolocation": "^6.0.0",

from the package.json file, before the npm install command? The app will still work, the only featur that will be lacking will be the user prompt to activate GPS when activating Geolocation in the App.

I would like to test the resulting app from such a recipe, how can I manage to do that? This way I could tweak it and propose a final result to you. As the app name and description are outdated, I could also change them.

@licaon-kter
Copy link
Contributor

@azarz that's like a hardcoded dep

import { Geolocation } from "@capacitor/geolocation";
so will fail to build

@azarz
Copy link
Member Author

azarz commented Jul 2, 2024

I have made the import conditional:

try {
Geolocation = (await import("@capacitor/geolocation")).Geolocation;
} catch (e) {
Geolocation = {
checkPermissions: async () => {
try {
await new Promise( (resolve, reject) => {
navigator.geolocation.getCurrentPosition(resolve, reject, {
maximumAge: 0,
timeout: 3000,
});
});
return {
location: "granted",
};
} catch {
return {
location: "denied",
};
}
},
requestPermissions: async () => {
NativeSettings.open({
optionAndroid: AndroidSettings.Location,
optionIOS: IOSSettings.LocationServices
});
},
}
}

Now if the dependency is not in the package.json, the build does not fail.

On another note, the app name has changed, here is a suggestion for the display name and description:

License: GPLv3
SourceCode: https://github.com/IGNF/cartes-ign-app
IssueTracker: https://github.com/IGNF/cartes-ign-app/issues

# if AutoName is a display name
AutoName: Cartes IGN
Description: Découvrez la France autrement et observez l’évolution du territoire

@azarz azarz force-pushed the feat-foss-android-build branch from 94e99eb to 8475805 Compare July 2, 2024 13:24
@licaon-kter
Copy link
Contributor

licaon-kter commented Jul 2, 2024

autoname comes from your code: https://github.com/IGNF/cartes-ign-app/blob/develop/android/app/src/main/res/values/strings.xml#L3

description/changelogs/icon/screenshots you'll add in a Fastlane folder structure: https://gitlab.com/-/snippets/1895688

here's a test APK: fr.ign.geoportail_30100.apk.ZIP (remove the .ZIP from name)

built from this recipe:

  - versionName: 3.1.0+foss
    versionCode: 30100
    commit: 847580597dcba31d50a17eecfbfe9c815d517a14
    subdir: android/app
    sudo:
      - sysctl fs.inotify.max_user_watches=524288 || true
      - apt-get update
      - apt-get install -y make npm
    gradle:
      - fdroid
    rm:
      - android/app/build_google.gradle
    prebuild:
      - sed -i -e '/gms/d' ../build.gradle
      - sed -i -e '/geolocation/d' ../../package.json
      - cd ../..
      - npm install --build-from-source
      - npm run build
      - npx cap sync
    scandelete:
      - node_modules

@azarz azarz force-pushed the feat-foss-android-build branch from 36690ef to 228d74b Compare July 2, 2024 16:32
@azarz
Copy link
Member Author

azarz commented Jul 2, 2024

I have added the fastlane directory, and tested the app you provided: it seems to work!

What is the next step?

@licaon-kter
Copy link
Contributor

I have added the fastlane directory

right, but why add the French texts and pics in the en-US folder?

Move them to fr-FR 😄

Is the app in French only? Even so, you should add at least summary and some info in full description .txt in English in en-US that explains this, so users that don't have French locale don't end up with a blank details screen.

@licaon-kter
Copy link
Contributor

What is the next step?

merge this PR, tag a new release

@azarz
Copy link
Member Author

azarz commented Jul 3, 2024

I have added the fastlane directory

right, but why add the French texts and pics in the en-US folder?

Move them to fr-FR 😄

Is the app in French only? Even so, you should add at least summary and some info in full description .txt in English in en-US that explains this, so users that don't have French locale don't end up with a blank details screen.

I did it because as you guessed, the app is french only, and apparently FDroid requires the en-US folder. I will do as you advised and merge the PR. I'll let you know when I have tagged a release.

@licaon-kter
Copy link
Contributor

Regarding the pics, keep en-US/images/icon.png but the rest can go away from en-US, as they live in fr-FR

@azarz azarz force-pushed the feat-foss-android-build branch from fc1bd15 to 0447d28 Compare July 3, 2024 08:57
@azarz azarz merged commit 6395d6b into develop Jul 3, 2024
2 checks passed
@azarz azarz deleted the feat-foss-android-build branch July 3, 2024 08:58
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

Successfully merging this pull request may close these issues.

2 participants