Add Android.mk
AOSP build system uses Android.mk files to determine how to build components. Having an Android.mk is necessary for inclusion into ROMs.
-
Developer
Marked this MR as WIP because it makes no sense without !1 (merged).
-
Looks like @eighthave redid this work in !4 (merged).
-
Owner
this does work without !1 (merged), so I would merge it before !1 (merged) while waiting for tests there. Do we definitely need to set the versionName in AndroidManifest.xml?
-
Owner
I removed Android.mk from !4 (merged) to prefer this
-
Owner
@relan do you know how the Android.mk build process works here? Is it calling ant or gradle?
-
Developer
how the Android.mk build process works here? Is it calling ant or gradle?
Neither. AOSP uses own, make-based build system. Android.mk is actually a Makefile containing all instructions needed to build a package.
Do we definitely need to set the versionName in AndroidManifest.xml?
Yes, because AOSP build system can take version code/name (and also min/target SDK) only from AndroidManifest.xml. In fact it just leaves it as is, while Gradle would process it and add appropriate tags/params.
It's indeed possible to run arbitrary shell commands and call ant or gradle manually. But this is non-standard and very fragile way.
Is version code/name in AndroidManifest.xml a problem?
-
Owner
I figured that Android.mk called gradle or ant, but I looked into the source code some, and it seems that you're right: they made a third APK build system in
make.No problem about moving version code/name to AndroidManifest.xml, that just means ditching the gradle
getVersionName()hack that I'm fond of. -
Added 6 commits:
-
bf48afb8...e4de1f1e - 4 commits from branch
fdroid:master - 178d5441 - Add Android.mk
- 7d90c524 - Move SDK and version attributes into the manifest
Toggle commit list -
bf48afb8...e4de1f1e - 4 commits from branch
-
Developer
Now I'm going to rebuild my ROM from scratch. I'll remove "WIP" after I make sure the Privileged Extension is integrated properly.
-
OwnerEdited by Hans-Christoph Steiner
You should rebase this on the latest master since I just merged !1 (merged). Without that, you'll have to sign the F-Droid.apk using your ROM key to make it work with the Privileged Extension the way it was working before.
Also, I've never written an Android.mk for building an APK before, but I did just look into how the standard system apps are built. It looks like your changes might need a few more things. Here's what I came up with:
LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := $(call all-java-files-under, app/src/main/java) LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/app/src/main/res LOCAL_MANIFEST_FILE := $(LOCAL_PATH)/app/src/main/AndroidManifest.xml LOCAL_PACKAGE_NAME := FDroidPrivilegedExtension LOCAL_CERTIFICATE := platform LOCAL_PRIVILEGED_MODULE := true include $(BUILD_PACKAGE) -
Owner
Also, I'm OK with moving
versionCodeandversionNameto AndroidManifest.xml if it must be that way, but I'd like to keepversionName getVersionName()in build.gradle since it generates nice version names based on git tags and commit IDs.Perhaps there is good a way to set
versionNamethis way in Android.mk? If there is a standard make variable name forversionName, it can just be set usinggit describe --tags --alwayslike in gradle. Or maybe we could just use asedreplace regexp. Based on looking at https://android.googlesource.com/platform/build/+/master/core/android_manifest.mk, it seems possible since its doing manifest merging. Automatically including the verisonName is going to be important as more ROMs integrate this since it will mean that the binary will have a built-in record of the exact version from git it is built from, making figuring out problems easier. -
Added 7 commits:
-
7d90c524...00166eb2 - 5 commits from branch
fdroid:master - 6b7cc911 - Add Android.mk
- a3c2195e - Move SDK and version attributes into the manifest
Toggle commit list -
7d90c524...00166eb2 - 5 commits from branch
-
Developer
It looks like your changes might need a few more things.
AOSP build system is clever enough to find manifest and resources without explicit paths definitions. I've checked this making an AOSP 6.0.1 build.
Perhaps there is good a way to set versionName this way in Android.mk?
I don't know such a way. I would be surprised if it exists because AOSP is a solid thing, everything in it has the same version. It just doesn't need separate versioning of components.
I'm not a big fan of
git describe --tags --alwaystrick because it won't work when building code from a tarball (F-Droid provides source tarballs for each app and this is the right thing). IMO build process should not depend on VCS.Currently I've got Privileged Extension built and integrated into the ROM and F-Droid 0.101-alpha4 is able to find and call it but then I get an uncaught remote exception:
08-11 09:59:31.369 589 1089 I ActivityManager: Start proc 1673:org.fdroid.fdroid.privileged:fdroid_privileged/u0a6 for service org.fdroid.fdroid.privileged/.PrivilegedService 08-11 09:59:31.490 1673 1673 W System : ClassLoader referenced unknown path: /system/priv-app/FDroidPrivileged/lib/arm 08-11 09:59:31.546 1673 1685 D PrivilegedExtension: Checking if package is allowed to access privileged extension: org.fdroid.fdroid 08-11 09:59:31.552 1673 1685 D PrivilegedExtension: Allowed cert hash: 43238d512c1e5eb2d6569f4a3afbf5523418b82e0a3ed1552770abb9a9c9ccab 08-11 09:59:31.552 1673 1685 D PrivilegedExtension: Package cert hash: 43238d512c1e5eb2d6569f4a3afbf5523418b82e0a3ed1552770abb9a9c9ccab 08-11 09:59:31.553 1673 1685 D PrivilegedExtension: Package is allowed to access the privileged extension! 08-11 09:59:31.555 1673 1686 D PrivilegedExtension: Checking if package is allowed to access privileged extension: org.fdroid.fdroid 08-11 09:59:31.555 1673 1686 D PrivilegedExtension: Allowed cert hash: 43238d512c1e5eb2d6569f4a3afbf5523418b82e0a3ed1552770abb9a9c9ccab 08-11 09:59:31.556 1673 1686 D PrivilegedExtension: Package cert hash: 43238d512c1e5eb2d6569f4a3afbf5523418b82e0a3ed1552770abb9a9c9ccab 08-11 09:59:31.556 1673 1686 D PrivilegedExtension: Package is allowed to access the privileged extension! 08-11 09:59:31.572 589 614 I ActivityManager: Start proc 1697:com.android.defcontainer/u0a3 for service com.android.defcontainer/.DefaultContainerService 08-11 09:59:31.622 1697 1708 D DefContainer: Copying /data/user/0/org.fdroid.fdroid/files/install-1759028076.apk to base.apk 08-11 09:59:31.678 198 198 I SELinux : SELinux: Loaded file_contexts contexts from /file_contexts. 08-11 09:59:31.680 589 614 I PackageManager.DexOptimizer: Running dexopt (dex2oat) on: /data/app/vmdl690655031.tmp/base.apk pkg=org.ligi.fast isa=arm vmSafeMode=false debuggable=false oatDir = /data/app/vmdl690655031.tmp/oat bootComplete=true 08-11 09:59:31.762 1711 1711 I dex2oat : Starting dex2oat. 08-11 09:59:31.991 1711 1711 I dex2oat : dex2oat took 231.842ms (threads: 4) arena alloc=1242KB java alloc=210KB native alloc=2MB free=2MB 08-11 09:59:32.134 589 614 V BackupManagerService: restoreAtInstall pkg=org.ligi.fast token=1 restoreSet=0 08-11 09:59:32.134 589 614 W BackupManagerService: Requested unavailable transport: android/com.android.internal.backup.LocalTransport 08-11 09:59:32.134 589 614 W BackupManagerService: No transport 08-11 09:59:32.134 589 614 V BackupManagerService: Finishing install immediately 08-11 09:59:32.135 589 614 W Settings: Setting install_non_market_apps has moved from android.provider.Settings.Global to android.provider.Settings.Secure, returning read-only value. 08-11 09:59:32.135 589 614 I art : Starting a blocking GC Explicit 08-11 09:59:32.175 589 614 I art : Explicit concurrent mark sweep GC freed 50580(3MB) AllocSpace objects, 18(348KB) LOS objects, 33% free, 12MB/18MB, paused 885us total 40.008ms 08-11 09:59:32.176 1673 1685 E JavaBinder: *** Uncaught remote exception! (Exceptions are not yet supported across processes.) 08-11 09:59:32.176 1673 1685 E JavaBinder: java.lang.AbstractMethodError: abstract method "void android.content.pm.IPackageInstallObserver.packageInstalled(java.lang.String, int)" 08-11 09:59:32.176 1673 1685 E JavaBinder: at android.content.pm.PackageManager$LegacyPackageInstallObserver.onPackageInstalled(PackageManager.java:4689) 08-11 09:59:32.176 1673 1685 E JavaBinder: at android.app.PackageInstallObserver$1.onPackageInstalled(PackageInstallObserver.java:34) 08-11 09:59:32.176 1673 1685 E JavaBinder: at android.content.pm.IPackageInstallObserver2$Stub.onTransact(IPackageInstallObserver2.java:79) 08-11 09:59:32.176 1673 1685 E JavaBinder: at android.os.Binder.execTransact(Binder.java:453) 08-11 09:59:32.177 1673 1685 W System.err: java.lang.AbstractMethodError: abstract method "void android.content.pm.IPackageInstallObserver.packageInstalled(java.lang.String, int)" 08-11 09:59:32.177 1673 1685 W System.err: at android.content.pm.PackageManager$LegacyPackageInstallObserver.onPackageInstalled(PackageManager.java:4689) 08-11 09:59:32.177 1673 1685 W System.err: at android.app.PackageInstallObserver$1.onPackageInstalled(PackageInstallObserver.java:34) 08-11 09:59:32.177 1673 1685 W System.err: at android.content.pm.IPackageInstallObserver2$Stub.onTransact(IPackageInstallObserver2.java:79) 08-11 09:59:32.177 1673 1685 W System.err: at android.os.Binder.execTransact(Binder.java:453) 08-11 09:59:32.177 1673 1685 E JavaBinder: Forcefully exiting 08-11 09:59:32.182 1061 1061 D CarrierServiceBindHelper: Receive action: android.intent.action.PACKAGE_ADDED 08-11 09:59:32.184 1061 1061 D CarrierServiceBindHelper: mHandler: 3 08-11 09:59:32.184 1061 1061 D CarrierConfigLoader: mHandler: 9 phoneId: 0 08-11 09:59:32.205 589 647 I InputReader: Reconfiguring input devices. changes=0x00000010 08-11 09:59:32.237 589 602 W Searchables: No global search activity found 08-11 09:59:32.258 207 207 I Zygote : Process 1673 exited cleanly (1) 08-11 09:59:32.297 589 600 I ActivityManager: Process org.fdroid.fdroid.privileged:fdroid_privileged (pid 1673) has died 08-11 09:59:32.298 589 600 W ActivityManager: Scheduling restart of crashed service org.fdroid.fdroid.privileged/.PrivilegedService in 1000msAOSP code:
4685 public void onPackageInstalled(String basePackageName, int returnCode, String msg, 4686 Bundle extras) { 4687 if (mLegacy == null) return; 4688 try { 4689 mLegacy.packageInstalled(basePackageName, returnCode); 4690 } catch (RemoteException ignored) { 4691 } 4692 } -
Developer
@relan Good point about the automated version tags, then I would also advise against using this method, especially for the privileged extension as it will be build inside a rom, potentially not from the git directly.
Regarding the problem: Sounds like the AIDL files have not been packaged correctly or something along these lines. Are you sure that proguard is disabled? I will check later in detail.
-
Developer
@relan A better idea: Can you try removing the file in https://gitlab.com/fdroid/privileged-extension/tree/master/app/src/main/java/android/content/pm please and then rebuild the rom. They are just abstract and stubs to satisfy the compiler when the extension is build outside of a rom.
-
Developer
Without AIDL files Privileged Extension wouldn't work at all. But it does install an app and then crashes. I'll check you idea about ProGuard (not sure whether build system calls it on its own).
Can you try removing the file in https://gitlab.com/fdroid/privileged-extension/tree/master/app/src/main/java/android/content/pm please and then rebuild the rom.
Still no luck (looks like the issue is the same):
08-11 12:08:21.636 1959 1975 D PrivilegedExtension: Checking if package is allowed to access privileged extension: org.fdroid.fdroid 08-11 12:08:21.643 1959 1975 D PrivilegedExtension: Allowed cert hash: 43238d512c1e5eb2d6569f4a3afbf5523418b82e0a3ed1552770abb9a9c9ccab 08-11 12:08:21.643 1959 1975 D PrivilegedExtension: Package cert hash: 43238d512c1e5eb2d6569f4a3afbf5523418b82e0a3ed1552770abb9a9c9ccab 08-11 12:08:21.643 1959 1975 D PrivilegedExtension: Package is allowed to access the privileged extension! 08-11 12:08:21.646 1959 1974 D PrivilegedExtension: Checking if package is allowed to access privileged extension: org.fdroid.fdroid 08-11 12:08:21.647 1959 1974 D PrivilegedExtension: Allowed cert hash: 43238d512c1e5eb2d6569f4a3afbf5523418b82e0a3ed1552770abb9a9c9ccab 08-11 12:08:21.647 1959 1974 D PrivilegedExtension: Package cert hash: 43238d512c1e5eb2d6569f4a3afbf5523418b82e0a3ed1552770abb9a9c9ccab 08-11 12:08:21.647 1959 1974 D PrivilegedExtension: Package is allowed to access the privileged extension! 08-11 12:08:21.672 1678 1690 D DefContainer: Copying /data/user/0/org.fdroid.fdroid/files/install-1697840141.apk to base.apk 08-11 12:08:22.244 195 195 I SELinux : SELinux: Loaded file_contexts contexts from /file_contexts. 08-11 12:08:22.246 591 617 I PackageManager.DexOptimizer: Running dexopt (dex2oat) on: /data/app/vmdl1871454346.tmp/base.apk pkg=nl.mpcjanssen.simpletask isa=arm vmSafeMode=false debuggable=false oatDir = /data/app/vmdl1871454346.tmp/oat bootComplete=true 08-11 12:08:22.340 2141 2141 I dex2oat : Starting dex2oat. 08-11 12:08:22.878 2141 2141 W dex2oat : Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 08-11 12:08:23.038 2141 2145 W dex2oat : Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView 08-11 12:08:26.398 2141 2145 W dex2oat : No verified method for method calling String.<init>: void org.json.JSONStringer.<init>(int) 08-11 12:08:26.927 2141 2144 W dex2oat : No verified method for method calling String.<init>: java.lang.String java.io.ByteArrayOutputStream.toString() 08-11 12:08:26.998 2141 2143 W dex2oat : No verified method for method calling String.<init>: java.lang.String java.io.ByteArrayOutputStream.toString() 08-11 12:08:27.992 2141 2141 I dex2oat : dex2oat took 5.655s (threads: 4) arena alloc=3MB java alloc=5MB native alloc=20MB free=4MB 08-11 12:08:28.018 591 617 W PackageManager: Package nl.mpcjanssen.simpletask desires unavailable shared library com.sec.android.app.multiwindow; ignoring! 08-11 12:08:28.167 591 617 V BackupManagerService: restoreAtInstall pkg=nl.mpcjanssen.simpletask token=1 restoreSet=0 08-11 12:08:28.167 591 617 W BackupManagerService: Requested unavailable transport: android/com.android.internal.backup.LocalTransport 08-11 12:08:28.168 591 617 W BackupManagerService: No transport 08-11 12:08:28.168 591 617 V BackupManagerService: Finishing install immediately 08-11 12:08:28.168 591 617 W Settings: Setting install_non_market_apps has moved from android.provider.Settings.Global to android.provider.Settings.Secure, returning read-only value. 08-11 12:08:28.168 591 617 I art : Starting a blocking GC Explicit 08-11 12:08:28.219 591 617 I art : Explicit concurrent mark sweep GC freed 78234(4MB) AllocSpace objects, 19(920KB) LOS objects, 33% free, 12MB/18MB, paused 1.007ms total 50.415ms 08-11 12:08:28.221 1959 1975 E JavaBinder: *** Uncaught remote exception! (Exceptions are not yet supported across processes.) 08-11 12:08:28.221 1959 1975 E JavaBinder: java.lang.AbstractMethodError: abstract method "void android.content.pm.IPackageInstallObserver.packageInstalled(java.lang.String, int)" 08-11 12:08:28.221 1959 1975 E JavaBinder: at android.content.pm.PackageManager$LegacyPackageInstallObserver.onPackageInstalled(PackageManager.java:4689) 08-11 12:08:28.221 1959 1975 E JavaBinder: at android.app.PackageInstallObserver$1.onPackageInstalled(PackageInstallObserver.java:34) 08-11 12:08:28.221 1959 1975 E JavaBinder: at android.content.pm.IPackageInstallObserver2$Stub.onTransact(IPackageInstallObserver2.java:79) 08-11 12:08:28.221 1959 1975 E JavaBinder: at android.os.Binder.execTransact(Binder.java:453) 08-11 12:08:28.221 1959 1975 W System.err: java.lang.AbstractMethodError: abstract method "void android.content.pm.IPackageInstallObserver.packageInstalled(java.lang.String, int)" 08-11 12:08:28.221 1959 1975 W System.err: at android.content.pm.PackageManager$LegacyPackageInstallObserver.onPackageInstalled(PackageManager.java:4689) 08-11 12:08:28.221 1959 1975 W System.err: at android.app.PackageInstallObserver$1.onPackageInstalled(PackageInstallObserver.java:34) 08-11 12:08:28.221 1959 1975 W System.err: at android.content.pm.IPackageInstallObserver2$Stub.onTransact(IPackageInstallObserver2.java:79) 08-11 12:08:28.221 1959 1975 W System.err: at android.os.Binder.execTransact(Binder.java:453) 08-11 12:08:28.221 1959 1975 E JavaBinder: Forcefully exiting 08-11 12:08:28.302 204 204 I Zygote : Process 1959 exited cleanly (1) 08-11 12:08:28.341 591 1114 I ActivityManager: Process org.fdroid.fdroid.privileged:fdroid_privileged (pid 1959) has died 08-11 12:08:28.341 591 1114 W ActivityManager: Scheduling restart of crashed service org.fdroid.fdroid.privileged/.PrivilegedService in 1000ms -
Developer
@relan I searched a little bit on the Internet, and indeed proguard could be the problem, as described in one of the comments on https://paulononaka.wordpress.com/2011/07/02/how-to-install-a-application-in-background-on-android/
-
Developer
-
Owner
Does anyone really ever build ROMs from anything but
repo, which is git? I've never heard of building a ROM without usingrepo.gitis really an integral part of the ROM building process.Also, I think
minifyEnableddoesn't always cover proguard. I think it needs to be something like this:android { buildTypes { all { minifyEnabled false useProguard false shrinkResources false } } } -
-
Developer
Yes, ProGuard was the problem. I've disabled it completely because it does not make much sense for such a small project. Now F-Droid 0.101-alpha4 installs and removes apps via the Privileged Extension just fine.
Also changed the APK name to FDroidPrivilegedExtension.
Does anyone really ever build ROMs from anything but
repo, which is git?I can imagine someone doing
repo syncon one machine, copying source code tree (just code, no.gitsubdirs) to another machine without Internet connection and building there.How do Copperhead guys build their Android?
-
Unmarked this merge request as a Work In Progress
Toggle commit list -
Developer
I can imagine someone doing repo sync on one machine, copying source code tree (just code, no .git subdirs) to another machine without Internet connection and building there.
Exactly. I don't see the problem of increasing versionName manually before creating a git tag. It avoids the usage of specialized gradle code.
I am okay with merging this. Thanks for the testing @relan
-
43 29 targetCompatibility JavaVersion.VERSION_1_7 44 30 } 45 31 32 buildTypes { 33 all { 34 minifyEnabled false -
Developer
Would be nice to have a comment here why proguard must be disabled.
-
Developer
Done. Thanks for your hints!
-
-
Developer
I think @eighthave's concern about versioning can be addressed in a different way. We can adopt something like Git flow model:
- ROMs developers use
masterbranch of the Privileged Extension repository. - Privileged Extension is developed in the
developbranch,masteralways contains the latest stable code. - When a new version is ready,
developis merged intomaster. So ROMs should never get a half-baked version of the Privileged Extension.
- ROMs developers use
-
Owner
No git workflow will address the issue I'm concerned about, I moved that discussion to a new issue: #8
As for "git flow", that model is vastly overcomplicated for a project of this size. This project only has linear, fast-forward progress in commits, we do not need bugfix versions of stable release. Even with fdroidclient, which is a lot more complicated than this, there is hardly any activity on the stable release branches, and we only support one stable branch at a time. And git flow is too complicated for fdroidclient too.
-
-
-
Status changed to merged
Toggle commit list -