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

Failed to build #34

Open
IzzySoft opened this issue Nov 14, 2024 · 13 comments
Open

Failed to build #34

IzzySoft opened this issue Nov 14, 2024 · 13 comments

Comments

@IzzySoft
Copy link

I tried building the app from source, going by the steps in the workflow:

build:
  - sed -r '/signingConfigs.release/d' -i android/app/build.gradle
  - git clone -b 3.24.5 https://github.com/flutter/flutter
  - export PUB_CACHE=${PWD}/.pub-cache
  - flutter/bin/flutter config --no-analytics
  - flutter/bin/flutter pub get
  - flutter/bin/flutter build apk --release --split-per-abi --target-platform=android-arm64
build_home_dir: /home/runner
build_repo_dir: /home/runner/work/flut-renamer/flut-renamer
provisioning:
  android_home: /opt/sdk
  cmdline_tools:
    version: '12.0'
    url: https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
    sha256: 2d2d50857e4eb553af5a6dc3ad507a17adf43d115264b1afc116f95c92e5e258
  extra_packages:
    - curl
    - clang
    - cmake
    - ninja-build
    - pkg-config
    - libgtk-3-0
    - libgtk-3-dev
    - libblkid1
    - liblzma5
  image: debian:bookworm-slim
  jdk: openjdk-17-jdk-headless

But the build fails when it invokes gradle:

Downloading android-x64-release/linux-x64 tools...                 105ms

Running Gradle task 'assembleRelease'...                        

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/home/runner/work/flut-renamer/flut-renamer/android/app/build.gradle' line: 31

* What went wrong:
A problem occurred evaluating project ':app'.
> path may not be null or empty string. path='null'

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
==============================================================================

2: Task failed with an exception.
-----------
* Where:
Build file '/home/runner/work/flut-renamer/flut-renamer/android/app/build.gradle' line: 31

* What went wrong:
A problem occurred evaluating project ':app'.
> path may not be null or empty string. path='null'

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
==============================================================================

BUILD FAILED in 1m 39s
Running Gradle task 'assembleRelease'...                          100.1s
Gradle task assembleRelease failed with exit code 1

As you can see, I even reflected the Github environment with the home and repo directories. Any hints what I might have missed?

Btw, instead of specifying a "moving target" like stable, could you maybe add the flutter version you use as git submodule here, or at least specify it in pubspec.yaml?

environment:
  sdk: '>=3.0.0 <4.0.0'
  flutter: 3.24.5

That would help reproducing a build even months later (and yes, the reason I try to build your app is Reproducible Builds – see Reproducible Builds, special client support and more at IzzyOnDroid).

Thanks in advance for your help!

@sun-jiao
Copy link
Owner

Thanks, I'll take a look.

@IzzySoft
Copy link
Author

IzzySoft commented Dec 6, 2024

Found something, @sun-jiao?

@sun-jiao
Copy link
Owner

sun-jiao commented Dec 6, 2024

I'll fix the build on the newest flutter and use a fixed version in the script in the next week.

@sun-jiao
Copy link
Owner

sun-jiao commented Dec 9, 2024

@IzzySoft I've updated the android gradle version and flutter dependencies. And I've added a fixed number (same as my local version) in the GitHub actions script. Could you have a try and tell me the result?

@IzzySoft
Copy link
Author

IzzySoft commented Dec 9, 2024

Thanks! That builds fine! Now, as the background is "reproducible builds" (see initial post): could you provide me an APK you've build from that commit (d2e5b8e) so I can have them compared by our builder?

@sun-jiao
Copy link
Owner

HI, which version do you want? universal? or split per abi?

@IzzySoft
Copy link
Author

app-arm64-v8a-release.apk would be perfect (that's the one available with the IzzyOnDroid repo – btw, feel free to pick a badge and link there e.g. from your Readme, folks can use their favorite F-Droid client to install from there and keep the app updated automatically), thanks!

@sun-jiao
Copy link
Owner

I am not familiar with reproducable build. So I don't know if different signatures affect the comparison of files.

app-arm64-v8a-release.zip

@IzzySoft
Copy link
Author

I don't know where you built this APK, but obviously not from inside the git repo, as META-INF/version-control-info.textproto only contains:

generate_error_reason: NO_SUPPORTED_VCS_FOUND

So I cannot check this as I have no clue which commit I should build, sorry. And as our builders build from inside the git tree, they'd have the correct info there…

OK, assuming you've built from the latest commit (d2e5b8e) and I suggested above, and simply removing .git as the first build step… But thanks to this line it fails when no keystore is defined (it should rather skip signing entirely in such a case).

https://github.com/sun-jiao/flut-renamer/blob/main/android/app/build.gradle#L27-L34

if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

def _storeFile = file(System.getenv("KEYSTORE") ?: keystoreProperties["storeFile"])
def _storePassword = System.getenv("KEYSTORE_PASSWORD") ?: keystoreProperties["storePassword"]
def _keyAlias = System.getenv("KEY_ALIAS") ?: keystoreProperties["keyAlias"]
def _keyPassword = System.getenv("KEY_PASSWORD") ?: keystoreProperties["keyPassword"]

If the file does not exist, you cannot read from it. And if those environment variables are not set, it fails. So maybe the last for lines should go into an "elseif" branch checking if the `KEYSTORE' variable is set, or something alike?

So I created a dummy key.properties:

echo -e "storeFile=/dev/null\nstorePassword=storePass\nkeyAlias=alias\nkeyPassword=keyPass" >> key.properties

Still crashes at line 31: "path may not be null or empty string. path='null'" (maybe Flutter considers android/ being the rootProject?). So I explicitly export them as ENV in addition:

export KEYSTORE=/dev/null KEYSTORE_PASSWORD=storePass KEY_ALIAS=keyAlias KEY_PASSWORD=keyPass

(it's all dummies, the process won't sign anyway).

That builds now, but the resulting APK is much different from yours, already bigger even before signing. It contains a lot of files your APK does not have. And while the APK from my build e.g. clearly states 1.8.0 in androidx.browser_browser.version, yours has task ':browser:browser:writeVersionFile' property 'version' there – so something is very wrong here.

I don't know if different signatures affect the comparison of files.

No, that's taken care for. We build an unsigned APK, then use apksigcopier to copy the signature from your APK over – which only works if, apart from signing, the builds were identical (and thus reproducible).

@sun-jiao
Copy link
Owner

sun-jiao commented Dec 19, 2024

I don't understand.

It would be understandable if it was missing some files that my apk has, which could be attributed to gitignore.

Can you share your apk with me? I will check when possible.

@IzzySoft
Copy link
Author

Sure. Let me share the recipe as well, so you know how I've built:

build:
  - rm -rf .git
  - sed -r '/signingConfigs.release/d' -i android/app/build.gradle
  - export KEYSTORE=/dev/null KEYSTORE_PASSWORD=storePass KEY_ALIAS=keyAlias KEY_PASSWORD=keyPass
  - FLUTTER_VERSION="$(sed -rn 's/\s*flutter-version:\s*([0-9.])/\1/p' .github/workflows/main.yml | head -n 1)"
  - git clone -b $FLUTTER_VERSION https://github.com/flutter/flutter
  - export PUB_CACHE=${PWD}/.pub-cache
  - flutter/bin/flutter config --no-analytics
  - flutter/bin/flutter pub get
  - flutter/bin/flutter build apk --release --split-per-abi --target-platform=android-arm64
  - mv build/app/outputs/flutter-apk/app-arm64-v8a-release.apk /outputs/unsigned.apk

a632e63e1e0e200bcd038680cccc6ba228ce94900954572ae730172b3ce3da30-net.sunjiao.renamer-d2e5b8e20d0f0445b09a9af3e568e6368ed6a822-unsigned.apk.zip

(just remove the .zip extension I had to add for Github to allow me to attach it)

To check for RB, ideally you build from a (freshly checked out) git tree (of course without the rm -rf .git), so META-INF/version-control-info.textproto has the commit hash. You might also want to see our other hints on reproducible builds.

@sun-jiao
Copy link
Owner

sun-jiao commented Jan 2, 2025

I did not find a reason. May be due to the different android sdk and ndk?

@IzzySoft
Copy link
Author

IzzySoft commented Jan 2, 2025

I went by your workflow and use OpenJDK-17 (zulu is not possible here; but if that's the culprit, you could try switching to "temurin" – or "oracle", which is supposed to be OpenJDK but I could not yet confirm it). Your workflow does not specify any NDK; the build.gradle however says 27.0.12077973. I could specify that explicitly. But that cannot be the reason for

the resulting APK is much different from yours, already bigger even before signing. It contains a lot of files your APK does not have. And while the APK from my build e.g. clearly states 1.8.0 in androidx.browser_browser.version, yours has task ':browser:browser:writeVersionFile' property 'version' there – so something is very wrong here.

I have no idea how you build the APK. But as your META-INF/version-control-info.textproto says generate_error_reason: NO_SUPPORTED_VCS_FOUND, it was certainly not built from within the repo tree. So it's some other "local tree" on your machine – which most likely is not fully "in sync" with the repo.

Hence the "first basic rule" of our hints on reproducible builds: always build from a clean tree at the commit the tag points to. "clean" means neither local modifications, nor any artifacts remaining from previous builds. And "commit" implies a git tree 😉 So maybe you can perform a git clone of your repo, and build from within that? Then provide me the resulting APK, and I can test again.

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

2 participants