[HOWTO] ✏ Compiling Fairphone Open OS / Rooting

Thanks @wvengen. I think I just figured out what was wrong. When copying the log from the phone to the forum, I noticed one strange line:

So I used fastboot flash userdata userdata.img to flash the userdata and the phone booted up fine. I guess the factory reset you did had the same effect (reseting the userdata partition).

So far, I can say that WiFi, sim card and camera seem to work, I have not yet tested anything else.

Sorry for the long thread that apparently was just one step away from a solution. Hopefully, it will help someone else.

EDIT: Maybe someone with wiki access rights can add some details to the top post (e.g., about flashing userdata).

1 Like

Hello, this is how my build failed today:

Config:

  • AMDx86_64
  • Kubuntu 15.10
  • gcc-version: 4.8.5
  • python: 2.7.10
  • OpenJDK 8
  • RAM: 8GB
  • ccache: 100GB
  • swap: 10GB

out/target/common/obj/PACKAGING/public_api.txt:20: error 5: Added public field android.Manifest.permission.BACKUP
out/target/common/obj/PACKAGING/public_api.txt:82: error 5: Added public field android.Manifest.permission.INVOKE_CARRIER_SETUP
out/target/common/obj/PACKAGING/public_api.txt:106: error 5: Added public field android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE
out/target/common/obj/PACKAGING/public_api.txt:116: error 5: Added public field android.Manifest.permission.RECEIVE_EMERGENCY_BROADCAST
Ignoring unused library classes…
Original number of library classes: 11515
Final number of library classes: 11515
Shrinking…

Checking API: checksystemapi-last


You have tried to change the API from what has been previously approved.

To make these errors go away, you have two choices:

  1. You can add “@hide” javadoc comments to the methods, etc. listed in the
    errors above.
  1. You can update current.txt by executing the following command:
    make update-api
  To submit the revised current.txt to the main Android repository,
  you will need approval.

build/core/tasks/apicheck.mk:62: recipe for target ‘out/target/common/obj/PACKAGING/checkpublicapi-current-timestamp’ failed
make: *** [out/target/common/obj/PACKAGING/checkpublicapi-current-timestamp] Error 38
make: *** Waiting for unfinished jobs…
Writing output…
Preparing output jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/ContactsProvider_intermediates/proguard.classes.jar]
Copying resources from program jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/ContactsProvider_intermediates/classes.jar]
Preparing output jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/TelephonyProvider_intermediates/proguard.classes.jar]
Copying resources from program jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/TelephonyProvider_intermediates/classes.jar]
Preparing output jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/Telecom_intermediates/proguard.classes.jar]
Copying resources from program jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/Telecom_intermediates/classes.jar]
Removing unused program classes and class elements…
Original number of program classes: 1767
Final number of program classes: 557
Preparing output jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/SystemUI_intermediates/proguard.classes.jar]
Copying resources from program jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/SystemUI_intermediates/classes.jar]
Writing output…
Preparing output jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/TeleService_intermediates/proguard.classes.jar]
Copying resources from program jar [/home/xaxa/fairphone_os/out/target/common/obj/APPS/TeleService_intermediates/classes.jar]

make failed to build some targets (03:17:35 (hh:mm:ss))

Anyone an idea what went wrong? I used -j8 and am trying with j8 right now. I will switch to -j4 in a third try maybe.

Edit: ccache-, ram-, and swap-size added

Only a first guess: As far as I remember, openjdk-7-jdk is recommended to build Android 5.

Maybe you are right. I have read it as just a recommendation rather than a strong necessity. After fail I was checking too, but I didn’t got this error-message. If my second build running right now fails too, I will change the Java-Version aswell and will report in the late evening.

Edit:
2nd build failed too, at the exact same position with the same error message. Now trying with -j2 and OpenJDK 7 as recommended (I have removed all JDK-versions I found with synaptic before)

3rd build with JDK7 and -j2 failed too. Does anybody else know this API error?

Finally the self compiled Fairphone Open Source Android works on my phone. :relieved:

The info I was missing was to not use “make -j8” when compiling, but “make” (it took 6hrs). This was already stated multiple times in this thread, however I assumed that everything went fine because the build process printed “compiled successfully”, which apparently has no meaning whether the output is usable.

I then flashed boot.img + system.img and for the first time the phone didn’t hang at the Fairphone splash with the black background but at the “loading” screen with a light background color. It was still not able to boot. This I could fix with the information of this thread by executing “fastboot -w flash system system.img”. This command cleared not only system but also the partitions userdata, cache, etc.

Afterwards the Fairphone booted directly into the OS in contrast to the stock Fairphone OS which boots into a welcome screen. :grin:

For all building with Docker on Linux: I needed to switch its storage backend to devicemapper to be able to finish building (to get around the zombies problem). More at docker/docker#18502 and SO.
This is documented in the fairphone2-build-env’s README now, but you may have missed it if you started building before the change.

congrats!

how can i send you a private message? i cant find an button for that (am i too stupid).

Click on the name of the user you want to send a PM.

thank you, but i dont get it. this is embarrassing but if i click on the username i just can see the users batches, activity… but i cant find a pm button. so sorry for my of topic postings.

What i need is an FP2 ROM. I formatted my FP2 and have no backup (yeah thats funny).

So if someone can help me out maybe you manage to send me a PM.

@tinkerweasel, could you get in contact with @dsfhoiud?

1 Like

Maybe this is the wrong thread?!

I noticed changes to the repository. Is there some kind of changelog available? Do we know if one or some of the known issues are already fixed in the Open Source sources? And how would one know if the sources available are stable for day to day usage?

Or is it to early to ask these questions and we expect something along these lines to come when Fairphone starts to publish pre-built OS versions later in Q1/2016?

To a certain extend I’m asking as I expect delivery of my FP2 and wanted to go Google-free right form the start…

Grazie mille for your thoughts… :wink:

There has been some bug squashing in the sources, but I’m not sure what has been fixed.

By extended use. If this is a concern, wait for the pre-built versions which will (hopefully) have some beta-testing done before general release.

1 Like

I finally managed to get a succesful build with OpenJDK 7. I wanted to try it out in the emulator first but the emulator doesn’t work at all. After some search I found one has to put

$ . build/envsetup.sh
$ set_stuff_for_environment
$ choosecombo 1 FP2 2
$ make -j8

in-between before compiling (isn’t mentioned in source.android.com aswell). However a build takes a couple of hours and I highly prefer to get the emulator working on the ready build afterwards. All solution I found refer to the whole android studio by google. If no other solution I will install it, but I am pretty sure we have people here who got the emulator running on their builds. If so, my first question is: where was actually the whole SDK-Stuff put into (by using the commands given by the thread-starter)?

Happy to hear it’s working for you. The emulator seems to be broken, I think some other people in this thread confirmed it.

What do you mean by “SDK-Stuff”? The problem is not the emulator itself but that the build script / process for building the emulator image (which is different from the production one) is broken, so using another emulator probably won’t help.

Thanks to whoever added a link to my post about the Gapps.
As far as i understand the issue, everyone who wants to build Fairphone OS by himself has to do these steps.
Otherwise, none of the binary blobs which need system access will work properly. Just have a look at the list of APKs to sign, and you’ll understand what i mean. :slight_smile:

2 Likes

My Docker-Build crashed at

target Package: FrameworkCoreTests_install_use_perm_good (out/target/product/FP2/obj/APPS/FrameworkCoreTests_install_use_perm_good_intermediates/package.apk)
warning: ignoring flag -c hdpi-v4. Use --preferred-density instead.
warning: ignoring flag -c mdpi-v4. Use --preferred-density instead.
warning: ignoring flag -c hdpi-v4. Use --preferred-density instead.
warning: ignoring flag -c mdpi-v4. Use --preferred-density instead.
adding: lib/ (stored 0%)
adding: lib/armeabi-v7a/ (stored 0%)
adding: lib/armeabi-v7a/libframeworks_coretests_jni.so (deflated 75%)
warning: ignoring flag -c hdpi-v4. Use --preferred-density instead.
warning: ignoring flag -c mdpi-v4. Use --preferred-density instead.
warning: ignoring flag -c hdpi-v4. Use --preferred-density instead.
warning: ignoring flag -c mdpi-v4. Use --preferred-density instead.
adding: lib/ (stored 0%)
adding: lib/armeabi-v7a/ (stored 0%)
adding: lib/armeabi-v7a/libframeworks_coretests_jni.so (deflated 75%)
target Package: FrameworkCoreTests_install_uses_feature (out/target/product/FP2/obj/APPS/FrameworkCoreTests_install_uses_feature_intermediates/package.apk)
warning: ignoring flag -c hdpi-v4. Use --preferred-density instead.
warning: ignoring flag -c mdpi-v4. Use --preferred-density instead.
warning: ignoring flag -c hdpi-v4. Use --preferred-density instead.
warning: ignoring flag -c mdpi-v4. Use --preferred-density instead.
adding: lib/ (stored 0%)
adding: lib/armeabi-v7a/ (stored 0%)
adding: lib/armeabi-v7a/libframeworks_coretests_jni.so (deflated 75%)

is there somebody with the same error?

Yes, i’m using AUFS. That could be the Problem.

You can change it yourself if you want to add more info. I think they need to fix the build. We can’t fix all those things after the fact, the list will get too long. Not sure if “choosecombo” will affect the signing, I think it’s mostly the make files in core, but I’m not sure.

Below the list you published as reference.

/system/app/TimeService/TimeService.apk
/system/app/PPPreference/PPPreference.apk
/system/app/QuickBoot/QuickBoot.apk
/system/app/SVIService/SVIService.apk
/system/app/btmultisim/btmultisim.apk
/system/app/GsmTuneAway/GsmTuneAway.apk
/system/app/SystemAgent/SystemAgent.apk
/system/app/qcrilmsgtunnel/qcrilmsgtunnel.apk
/system/app/WfdService/WfdService.apk
/system/app/com.qualcomm.qti.services.secureui/com.qualcomm.qti.services.secureui.apk
/system/app/fastdormancy/fastdormancy.apk
/system/app/CABLService/CABLService.apk
/system/app/SimContacts/SimContacts.apk
/system/app/NetworkSetting/NetworkSetting.apk
/system/app/xdivert/xdivert.apk
/system/app/RCSBootstraputil/RCSBootstraputil.apk
/system/app/QTIDiagServices/QTIDiagServices.apk
/system/app/QtiDdsSwitchService/QtiDdsSwitchService.apk
/system/app/atfwd/atfwd.apk
/system/vendor/app/ims/ims.apk
/system/priv-app/com.qualcomm.location/com.qualcomm.location.apk
/system/priv-app/com.qualcomm.msapm/com.qualcomm.msapm.apk
/system/priv-app/CNEService/CNEService.apk

I’ve experiences exactly the same error and changing to devicemapper has solved it.

This solution is now also indicated in the Readme of the image (thanks to a generous contributer).

Just wanted to share my experience here:
I followed the steps as described in the wiki post (on Ubuntu 14.04 LTS), except that I downloaded the whole repo (missed the --depth=1) and added the patches for unified NLP. I had to add -w when flashing system.img as otherwise the phone would hang during boot at the white “Loading” screen (It got quite warm too and battery was very low after 15 minutes or so).
So far it seems to work perfectly (even the LED issue is fixed), although I haven’t tested much yet. One thing I noticed was the “introduction” to the UI (a few screens showing basic usage of the UI) - I didn’t notice that on the stock Fairphone OS.

Thanks to all of you who worked on this guide - it feels incredible to run a self-compiled OS on my FP2 :smiley:

1 Like

Hello @kuleszdl, @tphysm, @fp1_wo_sw_updates

I tried as proposed and got stuck on a problem when trying to embed Superuser (by phhusson) into my build:

Compiler stops because of multiple Android.mk-Files defining su. /system/extras/su comes with FP-buildtree. Websearch (example) gives just to delete the whole folder or renaming the mk-file. However if I try, both run into several different “no rule defined”-errors a little bit later in compile-process.

Since I didn’t managed to find a workaround in accordance to the explanations of koush or phhusson I renamed all Android.mk-files in Superuser-Directory into Android_su.mk. My assumption is, that any mk-file in build-tree will be called, but I am not sure whether this will install Superuser as meant considering the same procedure with the mk-file in system/extras/su didn’t work out aswell in the first place.

If my currently running build fails - any idea how to get rid of this? Thank you in advance.