Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Build fails #104

Closed
mimi89999 opened this issue Jul 21, 2017 · 19 comments
Closed

Build fails #104

mimi89999 opened this issue Jul 21, 2017 · 19 comments

Comments

@mimi89999
Copy link

Building on commit c70a58d

michel@debian:~/git/fdroiddata$ fdroid build -vl subreddit.android.appstore
Clonage dans 'build/subreddit.android.appstore'...
INFO: Building version 0.7.0 (7000) of subreddit.android.appstore
INFO: Getting source for revision c70a58d24af5ddb3a430376bf483f314b08a6590
INFO: Creating local.properties file at build/subreddit.android.appstore/local.properties
INFO: Creating local.properties file at build/subreddit.android.appstore/app/local.properties
INFO: Cleaned build.gradle of keysigning configs at build/subreddit.android.appstore/app/build.gradle
INFO: Cleaning Gradle project...
Starting a Gradle Daemon, 1 busy Daemon could not be reused, use --status for details
Download https://jcenter.bintray.com/io/realm/realm-gradle-plugin/1.2.0/realm-gradle-plugin-1.2.0.pom
Download https://jcenter.bintray.com/me/tatarka/gradle-retrolambda/3.3.0/gradle-retrolambda-3.3.0.pom
Download https://jcenter.bintray.com/io/realm/realm-transformer/1.2.0/realm-transformer-1.2.0.pom
Download https://jcenter.bintray.com/io/realm/realm-annotations/1.2.0/realm-annotations-1.2.0.pom
Download https://jcenter.bintray.com/io/realm/realm-gradle-plugin/1.2.0/realm-gradle-plugin-1.2.0.jar
Download https://jcenter.bintray.com/me/tatarka/gradle-retrolambda/3.3.0/gradle-retrolambda-3.3.0.jar
Download https://jcenter.bintray.com/io/realm/realm-transformer/1.2.0/realm-transformer-1.2.0.jar
Download https://jcenter.bintray.com/io/realm/realm-annotations/1.2.0/realm-annotations-1.2.0.jar
Download https://jcenter.bintray.com/io/realm/realm-android-library/1.2.0/realm-android-library-1.2.0.pom
Download https://jcenter.bintray.com/com/futuremind/recyclerfastscroll/fastscroll/0.2.4/fastscroll-0.2.4.pom
Download https://jcenter.bintray.com/com/squareup/okhttp3/logging-interceptor/3.5.0/logging-interceptor-3.5.0.pom
Download https://jcenter.bintray.com/com/squareup/okhttp3/parent/3.5.0/parent-3.5.0.pom
Download https://jcenter.bintray.com/com/squareup/retrofit2/retrofit/2.1.0/retrofit-2.1.0.pom
Download https://jcenter.bintray.com/com/squareup/retrofit2/parent/2.1.0/parent-2.1.0.pom
Download https://jcenter.bintray.com/com/squareup/retrofit2/converter-gson/2.1.0/converter-gson-2.1.0.pom
Download https://jcenter.bintray.com/com/squareup/retrofit2/retrofit-converters/2.1.0/retrofit-converters-2.1.0.pom
Download https://jcenter.bintray.com/com/jakewharton/retrofit/retrofit2-rxjava2-adapter/1.0.0-RC2/retrofit2-rxjava2-adapter-1.0.0-RC2.pom
Download https://oss.sonatype.org/content/repositories/snapshots/com/github/bumptech/glide/glide/4.0.0-SNAPSHOT/glide-4.0.0-20170721.190157-255.pom
Download https://jcenter.bintray.com/com/wefika/flowlayout/0.4.0/flowlayout-0.4.0.pom
Download https://jcenter.bintray.com/io/reactivex/rxjava2/rxandroid/2.0.0-RC1/rxandroid-2.0.0-RC1.pom
Download https://jcenter.bintray.com/io/reactivex/rxjava2/rxjava/2.0.0-RC2/rxjava-2.0.0-RC2.pom
Download https://jcenter.bintray.com/com/google/dagger/dagger/2.2/dagger-2.2.pom
Download https://jcenter.bintray.com/com/google/dagger/dagger-parent/2.2/dagger-parent-2.2.pom
Download https://jcenter.bintray.com/com/jakewharton/butterknife/8.0.1/butterknife-8.0.1.pom
Download https://jcenter.bintray.com/de/psdev/licensesdialog/licensesdialog/1.8.1/licensesdialog-1.8.1.pom
Download https://jcenter.bintray.com/de/psdev/licensesdialog/parent/1.8.1/parent-1.8.1.pom
Download https://jcenter.bintray.com/com/squareup/leakcanary/leakcanary-android/1.4-beta2/leakcanary-android-1.4-beta2.pom
Download https://oss.sonatype.org/content/repositories/snapshots/com/github/bumptech/glide/gifdecoder/4.0.0-SNAPSHOT/gifdecoder-4.0.0-20170721.190235-26.pom
Download https://oss.sonatype.org/content/repositories/snapshots/com/github/bumptech/glide/disklrucache/4.0.0-SNAPSHOT/disklrucache-4.0.0-20170721.190233-26.pom
Download https://oss.sonatype.org/content/repositories/snapshots/com/github/bumptech/glide/annotations/4.0.0-SNAPSHOT/annotations-4.0.0-20170721.190122-23.pom
Download https://jcenter.bintray.com/com/jakewharton/butterknife-annotations/8.0.1/butterknife-annotations-8.0.1.pom
Download https://jcenter.bintray.com/com/squareup/leakcanary/leakcanary-analyzer/1.4-beta2/leakcanary-analyzer-1.4-beta2.pom
Download https://jcenter.bintray.com/com/squareup/leakcanary/leakcanary-watcher/1.4-beta2/leakcanary-watcher-1.4-beta2.pom
Download https://jcenter.bintray.com/com/squareup/haha/haha/2.0.2/haha-2.0.2.pom
Download https://jcenter.bintray.com/com/squareup/okhttp3/okhttp/3.5.0/okhttp-3.5.0.pom
Download https://jcenter.bintray.com/io/realm/realm-android-library/1.2.0/realm-android-library-1.2.0.aar
Download https://jcenter.bintray.com/com/futuremind/recyclerfastscroll/fastscroll/0.2.4/fastscroll-0.2.4.aar
Download https://jcenter.bintray.com/com/squareup/okhttp3/okhttp/3.5.0/okhttp-3.5.0.jar
Download https://jcenter.bintray.com/com/squareup/okhttp3/logging-interceptor/3.5.0/logging-interceptor-3.5.0.jar
Download https://jcenter.bintray.com/com/squareup/retrofit2/retrofit/2.1.0/retrofit-2.1.0.jar
Download https://jcenter.bintray.com/com/squareup/retrofit2/converter-gson/2.1.0/converter-gson-2.1.0.jar
Download https://jcenter.bintray.com/io/reactivex/rxjava2/rxjava/2.0.0-RC2/rxjava-2.0.0-RC2.jar
Download https://jcenter.bintray.com/com/jakewharton/retrofit/retrofit2-rxjava2-adapter/1.0.0-RC2/retrofit2-rxjava2-adapter-1.0.0-RC2.jar
Download https://oss.sonatype.org/content/repositories/snapshots/com/github/bumptech/glide/gifdecoder/4.0.0-SNAPSHOT/gifdecoder-4.0.0-20170721.190235-26.jar
Download https://oss.sonatype.org/content/repositories/snapshots/com/github/bumptech/glide/disklrucache/4.0.0-SNAPSHOT/disklrucache-4.0.0-20170721.190233-26.jar
Download https://oss.sonatype.org/content/repositories/snapshots/com/github/bumptech/glide/annotations/4.0.0-SNAPSHOT/annotations-4.0.0-20170721.190122-23.jar
Download https://oss.sonatype.org/content/repositories/snapshots/com/github/bumptech/glide/glide/4.0.0-SNAPSHOT/glide-4.0.0-20170721.190157-255.jar
Download https://jcenter.bintray.com/com/wefika/flowlayout/0.4.0/flowlayout-0.4.0.aar
Download https://jcenter.bintray.com/io/reactivex/rxjava2/rxandroid/2.0.0-RC1/rxandroid-2.0.0-RC1.aar
Download https://jcenter.bintray.com/com/google/dagger/dagger/2.2/dagger-2.2.jar
Download https://jcenter.bintray.com/com/jakewharton/butterknife-annotations/8.0.1/butterknife-annotations-8.0.1.jar
Download https://jcenter.bintray.com/com/jakewharton/butterknife/8.0.1/butterknife-8.0.1.aar
Download https://jcenter.bintray.com/de/psdev/licensesdialog/licensesdialog/1.8.1/licensesdialog-1.8.1.aar
Download https://jcenter.bintray.com/com/squareup/leakcanary/leakcanary-watcher/1.4-beta2/leakcanary-watcher-1.4-beta2.jar
Download https://jcenter.bintray.com/com/squareup/haha/haha/2.0.2/haha-2.0.2.jar
Download https://jcenter.bintray.com/com/squareup/leakcanary/leakcanary-analyzer/1.4-beta2/leakcanary-analyzer-1.4-beta2.jar
Download https://jcenter.bintray.com/com/squareup/leakcanary/leakcanary-android/1.4-beta2/leakcanary-android-1.4-beta2.aar
Download https://jcenter.bintray.com/com/squareup/leakcanary/leakcanary-android-no-op/1.4-beta2/leakcanary-android-no-op-1.4-beta2.pom
Download https://jcenter.bintray.com/com/squareup/leakcanary/leakcanary-android-no-op/1.4-beta2/leakcanary-android-no-op-1.4-beta2.aar
Jack is disabled, but one of the plugins you are using supports Java 8 language features.
Jack is disabled, but one of the plugins you are using supports Java 8 language features.
Jack is disabled, but one of the plugins you are using supports Java 8 language features.
Download https://jcenter.bintray.com/io/realm/realm-annotations-processor/1.2.0/realm-annotations-processor-1.2.0.pom
Download https://jcenter.bintray.com/com/google/dagger/dagger-compiler/2.2/dagger-compiler-2.2.pom
Download https://jcenter.bintray.com/com/jakewharton/butterknife-compiler/8.0.1/butterknife-compiler-8.0.1.pom
Download https://jcenter.bintray.com/com/google/dagger/dagger-producers/2.2/dagger-producers-2.2.pom
Download https://jcenter.bintray.com/io/reactivex/rxjava/1.1.3/rxjava-1.1.3.pom
Download https://jcenter.bintray.com/com/squareup/javapoet/1.6.1/javapoet-1.6.1.pom
Download https://jcenter.bintray.com/io/realm/realm-annotations-processor/1.2.0/realm-annotations-processor-1.2.0.jar
Download https://jcenter.bintray.com/com/google/dagger/dagger-compiler/2.2/dagger-compiler-2.2.jar
Download https://jcenter.bintray.com/com/jakewharton/butterknife-compiler/8.0.1/butterknife-compiler-8.0.1.jar
Download https://jcenter.bintray.com/com/google/dagger/dagger-producers/2.2/dagger-producers-2.2.jar
Download https://jcenter.bintray.com/io/reactivex/rxjava/1.1.3/rxjava-1.1.3.jar
Download https://jcenter.bintray.com/com/squareup/javapoet/1.6.1/javapoet-1.6.1.jar
:app:clean

BUILD SUCCESSFUL

Total time: 1 mins 25.373 secs
INFO: Scanning source for common problems...
WARNING: Found JAR file at gradle/wrapper/gradle-wrapper.jar
INFO: Creating source tarball...
INFO: Building Gradle project...
Jack is disabled, but one of the plugins you are using supports Java 8 language features.
Jack is disabled, but one of the plugins you are using supports Java 8 language features.
Jack is disabled, but one of the plugins you are using supports Java 8 language features.
:app:preBuild UP-TO-DATE
:app:preProdReleaseBuild UP-TO-DATE
:app:checkProdReleaseManifest
:app:preMockDebugAndroidTestBuild UP-TO-DATE
:app:preMockDebugBuild UP-TO-DATE
:app:preProdDebugAndroidTestBuild UP-TO-DATE
:app:preProdDebugBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2510Library
:app:prepareComAndroidSupportAppcompatV72510Library
:app:prepareComAndroidSupportCardviewV72510Library
:app:prepareComAndroidSupportCustomtabs2510Library
:app:prepareComAndroidSupportDesign2510Library
:app:prepareComAndroidSupportPreferenceV142510Library
:app:prepareComAndroidSupportPreferenceV72510Library
:app:prepareComAndroidSupportRecyclerviewV72510Library
:app:prepareComAndroidSupportSupportCompat2510Library
:app:prepareComAndroidSupportSupportCoreUi2510Library
:app:prepareComAndroidSupportSupportCoreUtils2510Library
:app:prepareComAndroidSupportSupportFragment2510Library
:app:prepareComAndroidSupportSupportMediaCompat2510Library
:app:prepareComAndroidSupportSupportV42510Library
:app:prepareComAndroidSupportSupportVectorDrawable2510Library
:app:prepareComAndroidSupportTransition2510Library
:app:prepareComFuturemindRecyclerfastscrollFastscroll024Library
:app:prepareComGetkeepsafeRelinkerRelinker121Library
:app:prepareComJakewhartonButterknife801Library
:app:prepareComJakewhartonTimberTimber412Library
:app:preMockDebugUnitTestBuild UP-TO-DATE
:app:preProdDebugUnitTestBuild UP-TO-DATE
:app:preProdReleaseUnitTestBuild UP-TO-DATE
:app:prepareComSquareupLeakcanaryLeakcanaryAndroidNoOp14Beta2Library
:app:prepareComWefikaFlowlayout040Library
:app:prepareDePsdevLicensesdialogLicensesdialog181Library
:app:prepareIoReactivexRxjava2Rxandroid200RC1Library
:app:prepareIoRealmRealmAndroidLibrary120Library
:app:prepareProdReleaseDependencies
:app:compileProdReleaseAidl
:app:compileProdReleaseRenderscript
:app:generateProdReleaseBuildConfig
:app:generateProdReleaseResValues
:app:generateProdReleaseResources
:app:mergeProdReleaseResources
:app:processProdReleaseManifest
:app:processProdReleaseResources
:app:generateProdReleaseSources
:app:incrementalProdReleaseJavaCompilationSafeguard
:app:javaPreCompileProdRelease
:app:compileProdReleaseJavaWithJavacNote: Version 3.5.0 of Realm is now available: http://static.realm.io/downloads/java/latest
Note: Processing class RealmString
Note: Processing class CachedScrape
Note: Processing class CachedAppInfo
Note: Creating DefaultRealmModule
/home/michel/git/fdroiddata/build/subreddit.android.appstore/app/src/main/java/subreddit/android/appstore/util/ui/glide/GlideConfigModule.java:14: error: GlideConfigModule is not abstract and does not override abstract method registerComponents(Context,Glide,Registry) in RegistersComponents
public class GlideConfigModule implements GlideModule {
       ^
/home/michel/git/fdroiddata/build/subreddit.android.appstore/app/src/main/java/subreddit/android/appstore/util/ui/glide/GlideConfigModule.java:21: error: method does not override or implement a method from a supertype
    @Override
    ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileProdReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 16.493 secs
ERROR: Could not build app subreddit.android.appstore: Build failed for subreddit.android.appstore:0.7.0
==== detail begin ====
Jack is disabled, but one of the plugins you are using supports Java 8 language features.
Jack is disabled, but one of the plugins you are using supports Java 8 language features.
Jack is disabled, but one of the plugins you are using supports Java 8 language features.
:app:preBuild UP-TO-DATE
:app:preProdReleaseBuild UP-TO-DATE
:app:checkProdReleaseManifest
:app:preMockDebugAndroidTestBuild UP-TO-DATE
:app:preMockDebugBuild UP-TO-DATE
:app:preProdDebugAndroidTestBuild UP-TO-DATE
:app:preProdDebugBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2510Library
:app:prepareComAndroidSupportAppcompatV72510Library
:app:prepareComAndroidSupportCardviewV72510Library
:app:prepareComAndroidSupportCustomtabs2510Library
:app:prepareComAndroidSupportDesign2510Library
:app:prepareComAndroidSupportPreferenceV142510Library
:app:prepareComAndroidSupportPreferenceV72510Library
:app:prepareComAndroidSupportRecyclerviewV72510Library
:app:prepareComAndroidSupportSupportCompat2510Library
:app:prepareComAndroidSupportSupportCoreUi2510Library
:app:prepareComAndroidSupportSupportCoreUtils2510Library
:app:prepareComAndroidSupportSupportFragment2510Library
:app:prepareComAndroidSupportSupportMediaCompat2510Library
:app:prepareComAndroidSupportSupportV42510Library
:app:prepareComAndroidSupportSupportVectorDrawable2510Library
:app:prepareComAndroidSupportTransition2510Library
:app:prepareComFuturemindRecyclerfastscrollFastscroll024Library
:app:prepareComGetkeepsafeRelinkerRelinker121Library
:app:prepareComJakewhartonButterknife801Library
:app:prepareComJakewhartonTimberTimber412Library
:app:preMockDebugUnitTestBuild UP-TO-DATE
:app:preProdDebugUnitTestBuild UP-TO-DATE
:app:preProdReleaseUnitTestBuild UP-TO-DATE
:app:prepareComSquareupLeakcanaryLeakcanaryAndroidNoOp14Beta2Library
:app:prepareComWefikaFlowlayout040Library
:app:prepareDePsdevLicensesdialogLicensesdialog181Library
:app:prepareIoReactivexRxjava2Rxandroid200RC1Library
:app:prepareIoRealmRealmAndroidLibrary120Library
:app:prepareProdReleaseDependencies
:app:compileProdReleaseAidl
:app:compileProdReleaseRenderscript
:app:generateProdReleaseBuildConfig
:app:generateProdReleaseResValues
:app:generateProdReleaseResources
:app:mergeProdReleaseResources
:app:processProdReleaseManifest
:app:processProdReleaseResources
:app:generateProdReleaseSources
:app:incrementalProdReleaseJavaCompilationSafeguard
:app:javaPreCompileProdRelease
:app:compileProdReleaseJavaWithJavacNote: Version 3.5.0 of Realm is now available: http://static.realm.io/downloads/java/latest
Note: Processing class RealmString
Note: Processing class CachedScrape
Note: Processing class CachedAppInfo
Note: Creating DefaultRealmModule
/home/michel/git/fdroiddata/build/subreddit.android.appstore/app/src/main/java/subreddit/android/appstore/util/ui/glide/GlideConfigModule.java:14: error: GlideConfigModule is not abstract and does not override abstract method registerComponents(Context,Glide,Registry) in RegistersComponents
public class GlideConfigModule implements GlideModule {
       ^
/home/michel/git/fdroiddata/build/subreddit.android.appstore/app/src/main/java/subreddit/android/appstore/util/ui/glide/GlideConfigModule.java:21: error: method does not override or implement a method from a supertype
    @Override
    ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileProdReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 16.493 secs
==== detail end ====
INFO: Finished.
@bobheadxi
Copy link
Collaborator

Why build on that commit? It is several commits behind, have you tried building 6996d5e?

@mimi89999
Copy link
Author

It is what is tagged as v0.7.0 and for F-Droid we are building on tags...

@bobheadxi
Copy link
Collaborator

Oh my bad, I misunderstood - might have to wait for a comment from @d4rken

@d4rken
Copy link
Member

d4rken commented Jul 22, 2017

We are building against glide:4.0.0-SNAPSHOT, something likely changed in the library.

Someone either has to to hardcode an older snapshot in the gradle file, or fix the issue.

@mimi89999
Copy link
Author

@bobheadxi Can you make a new release and add a new tag or move the existing one to that commit?

@bobheadxi
Copy link
Collaborator

bobheadxi commented Jul 24, 2017

Best if @d4rken does it when he has time, not sure what the process is, might be better if release as v0.7.1?

@d4rken
Copy link
Member

d4rken commented Jul 24, 2017

  • Raise the app version appropriately
  • (Merge master into dev if necessary)
  • Tag the release
  • Merge dev into master
  • Build a release APK

Only the last step is something I need to do because I have the signing key used for the previous github versions, for F-Droid that's not necessary though.

@bobheadxi
Copy link
Collaborator

@d4rken
Copy link
Member

d4rken commented Jul 24, 2017

Thinking about it, it might have been better to first merge then tag as the appstore app uses the tags to determine whether an update is available. That way we don't signal a new update before noticing an issue with the final build (i.e. travis is still testing the PR atm).

Hm actually we can do the tag, just not create a release for it on github, because that's what the app checks, right? Not sure what the app does when there is a new release, but no .apk attached yet...

Anyways, for F-Droid it should suffice.

@bobheadxi
Copy link
Collaborator

I believe the app waits for a release, and since v0.7.0 is still the "Latest Release" the tag in its current state shouldn't do anything

Without an apk attached, the app might just attempt to download the source code - should probably add a check to the app to check for that before indicating a release

I've put up a draft with an apk build attached, will that do or does it have to be done by you? Also unsure if I'm the only one who can see my drafts

@d4rken
Copy link
Member

d4rken commented Jul 24, 2017

I believe the app waits for a release, and since v0.7.0 is still the "Latest Release" the tag in its current state shouldn't do anything

Yeah I think that's the way it's implemented, at least I hope so 😁 .

Without an apk attached, the app might just attempt to download the source code - should probably add a check to the app to check for that before indicating a release.

Yeah though the draft approach seems sufficient.

I've put up a draft with an apk build attached, will that do or does it have to be done by you? Also unsure if I'm the only one who can see my drafts.

Everyone can see the drafts, but the attached APK won't work because it's not signed with the same signature key as the version everyone has installed, so they can't update it. They will get an error. To install it the previous version has to be uninstalled. That's Androids security mechanism so to prevent malicious updates. It guarantees that the APK someone installs is generated from a trusted source, i.e. the same source that build the previous version (or at least had access to the same key). Unless you created your own signing key the current apk is signed with a debug key, but in either case users won't be able to update with it.

I'll build an APK later and attach it to your draft.

@d4rken
Copy link
Member

d4rken commented Jul 24, 2017

F-Droid has it's own signing key which is why our APKs are not compatible with APKs build by F-Droid. Compatible meaning they can't update over each other.

@bobheadxi
Copy link
Collaborator

Ah I see

I'll build an APK later and attach it to your draft.

Thanks!

F-Droid has it's own signing key which is why our APKs are not compatible with APKs build by F-Droid. Compatible meaning they can't update over each other.

Does this mean when people using the FDroid build attempt to download an update via the "Update Available" dialogue built into the app they will run into problems?

@d4rken
Copy link
Member

d4rken commented Jul 24, 2017

Does this mean when people using the FDroid build attempt to download an update via the "Update Available" dialogue built into the app they will run into problems?

Yes, the Android installer will throw an error during the update attempt. If someone wants to do a PR 😉 : This can be solved by comparing the signature of the apk that is installed (which can be accessed through the packagemanager) and comparing it with the signature of the github build apks (which doesn't change and could be hardcoded). If it doesn't match, don't show an update dialog or show some other kind of information.

@bobheadxi
Copy link
Collaborator

bobheadxi commented Jul 24, 2017

Seems fairly important usability wise, opened up an issue (#109) for it and will get around to it :) thanks!

@d4rken
Copy link
Member

d4rken commented Jul 24, 2017

Yeah could be quite annoying, though I would guess that regular F-Droid users are fairly familiar with the issue as it also affects apps that are available from GPlay+FDroid.

@bobheadxi
Copy link
Collaborator

@d4rken How exactly does this work?

the signature of the github build apks (which doesn't change and could be hardcoded)

@d4rken
Copy link
Member

d4rken commented Aug 29, 2017

By using something like

getPackageManager().getPackageInfo(pkgname, PackageManager.GET_SIGNATURES).signatures

You could detect whether the apk is from github or froid by checking it for a specific signature.

The apk from github will have my signature (from the certificate file on my hdd), while the apk from fdroid will have their signature.

@d4rken
Copy link
Member

d4rken commented Aug 29, 2017

@bobheadxi

keytool -list -v -keystore keystore_rAndroidAppStore.jks

Returns

Creation date: 03.09.2016
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: OU=App Store, O=/r/Android
Issuer: OU=App Store, O=/r/Android
Serial number: 7e74e0e6
Valid from: Sat Sep 03 23:10:18 CEST 2016 until: Thu Jan 05 22:10:18 CET 3015
Certificate fingerprints:
         MD5:  36:54:AD:AB:ED:1F:24:58:9E:9D:27:23:D3:1A:B4:AC
         SHA1: FC:4E:25:23:E3:50:9B:A5:6E:6A:FD:C3:60:04:95:8E:2E:94:EA:B2
         SHA256: 6F:95:6E:1A:9E:89:EA:8F:9B:E4:44:B3:EB:31:DA:9C:7B:4C:C6:34:A1:E1:18:90:15:A7:16:A0:90:A9:77:4C
         Signature algorithm name: SHA256withRSA
         Version: 3

So our SHA1 certificate fingerprint is
FC4E2523E3509BA56E6AFDC36004958E2E94EAB2

This code reads the fingerprint for an any installed package and also returns the SHA finger print:

    public static List<String> getSignatures(Context context, String packageName) {
        List<String> foundSignatures = new ArrayList<>();
        try {
            final Signature[] signatures = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES).signatures;
            for (final Signature sig : signatures) {
                final byte[] rawCert = sig.toByteArray();
                InputStream certStream = new ByteArrayInputStream(rawCert);
                CertificateFactory certFactory = CertificateFactory.getInstance("X509");
                X509Certificate x509Cert = (X509Certificate) certFactory.generateCertificate(certStream);

                MessageDigest md = MessageDigest.getInstance("SHA1");
                byte[] publicKey = md.digest(x509Cert.getEncoded());
                foundSignatures.add(bytesToHex(publicKey).toUpperCase());
            }
        } catch (Exception e) { e.printStackTrace(); }
        return foundSignatures;
    }

    public static String bytesToHex(byte[] in) {
        final StringBuilder out = new StringBuilder();
        for (byte b : in) out.append(String.format("%02x", b));
        return out.toString();
    }

For the release apk of this app it would return a list with a single entry, namely the above SHA1 fingerprint.

For the F-Droid APK it would be a different fingerprint.

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

No branches or pull requests

3 participants