[HOWTO] opengapps integration script

3,309 views
Skip to first unread message

Dmitry Sutyagin

unread,
Nov 20, 2015, 11:12:26 AM11/20/15
to Android-x86
If you want to integrate google apps into the build but not sure how, you can use this guide+script.

This guide should allow you to integrate gapps provided by opengapps.org into your build:

Requirements:
bash
unzip
rsync

1. successfully build android without gapps
2. fetch the latest version of opengapps package from http://opengapps.org/ (currently only x86 available, but you can try to use it for x86_64 too, some of the apps will work, have not tested them all, Play Store works at least)
3. create a folder "gapps" in the root of your android repo
4. move the .zip archive which you downloaded to "gapps" folder
5. move the script ./integrate.sh to "gapps" folder also
6. run the script
7. rebuild android to let it repack the system folder with integrated gapps.

Questions welcome.
integrate.sh

Gabriele Miranda

unread,
Nov 22, 2015, 8:07:26 PM11/22/15
to Android-x86
Thanks, it seems very fast and helpful but I have a problem (I'm new to the development of Android x86, so it's probably due to my lack).
if i use the "micro" x86 package (also tried mini and nano) i am able to run the script and everything is unpacked and copied to right
out/target/product/x86_64/system subfolder (although the "popd > /dev/null" throws an error) but when i launch "make efi_img" the
image generated is exactly the same as that generated before the script.
I also tried to "touch" almost everything to force rebuild, i tried to delete all *.img files and to edit kernel config but nothing..

Now i do "make clean" and start from beginning, let's see.
When finish i'll post the error throw by the .sh


Dmitry Sutyagin

unread,
Nov 23, 2015, 1:02:01 AM11/23/15
to Android-x86
Gabriele,

The original script has a flaw - it does not remove system.img and system.sfs which is necessary, otherwise these files are not re-built. I have fixed this now, see attachment.
Let me know if this works for you. If you made "make clean" There's a chance that you will need to re-run the script after the make, not sure - I'd recommend to re-run to be sure, then make again, should be very fast - only image creation.
I wonder what kind of error you get from popd, let me know.
integrate.sh

Chiem Ma

unread,
Dec 10, 2015, 4:53:16 PM12/10/15
to Android-x86
Hi, Dimitri.

I tried to use your script, but when I rebuild (make efi_img -j4) the file doesn't change, just like the other poster.

This is using your new script.

The files are definitely being deleted and rebuilt, but for some reason, it always puts the same files into .img.  Any idea why?

Dmitry Sutyagin

unread,
Dec 11, 2015, 2:42:54 AM12/11/15
to Android-x86
Chiem,

1 - make sure you have put the zip archive from opengapps into gapps folder. There should be only one zip file in the folder.
2 - run the script one more time, see if there are any errors - if there are - post here.
3 - verify that the system folder in the out directory contains the new gapps files. For ex., priv-app folder should contain GoogleServicesFramework folder.
4 - check that system.sfs and the content of obj/PACKAGING/systemimage_intermediates is removed from out folder (full path you can find inside the script at the end)
5 - run 'm -j4 efi_img' to rebuid the image.
6 - mount the resulting image to see its contents, mount system image inside it too and check that gapps are there (for ex. priv-app/GoogleServicesFramework)

cwm9

unread,
Dec 16, 2015, 10:04:36 PM12/16/15
to Android-x86
Thanks.  It turns out it was working the whole time.  It looks like the image is fixed in size and contains free space, so the size doesn't change despite the files being added.

Metta Crawler

unread,
Jan 20, 2016, 11:37:09 AM1/20/16
to Android-x86
Oops, you can't have two installers:

android-x86/out/target/product/x86/system/priv-app/PackageInstaller/PackageInstaller.apk
android-x86/out/target/product/x86/system/priv-app/GooglePackageInstaller/GooglePackageInstaller.apk

http://www.magicbluesmoke.org/android-6-0-there-must-be-one-required-installer/

To work-around this I just booted the android and when it got stuck I logged into the console with Ctrl-Alt-F1 and used the shell to remove the non-google one.
cd /system/priv-app
rm -r PackageInstaller

then the boot up completed.

Metta Crawler

unread,
Jan 20, 2016, 9:06:13 PM1/20/16
to Android-x86
Patch for integrate.sh mostly to use ${ANDROID_PRODUCT_OUT} since rsync sort of missed the directory it was aiming for.


$ diff -u integrate.sh integrate-v3.sh
--- integrate.sh    2016-01-19 06:19:15.535497623 -0500
+++ integrate-v3.sh    2016-01-20 07:26:53.820269550 -0500
@@ -1,11 +1,18 @@
 #!/bin/bash
 
+prog=$(basename $0)
+
+if [ ! -f build/envsetup.sh ]; then
+    echo ${prog}: Please cd to the directory you ran \'repo init\' in.
+    exit 1
+fi
+
 product=`echo "$ANDROID_PRODUCT_OUT" | rev | cut -d/ -f1 | rev`
 
 if [ -z "$product" ]
 then
-    echo 'Please specify product by running "lunch [...]" to set $ANDROID_PRODUCT_OUT variable'
-    exit 0
+    echo '${prog}: Please specify product by running "lunch [...]" to set $ANDROID_PRODUCT_OUT variable'
+    exit 1
 fi
 
 pushd $(dirname $0) > /dev/null
@@ -34,15 +41,15 @@
 mkdir combined
 find unpacked/ -type f | xargs -n 1 -I@ sh -c 'cd `echo "@" | cut -d/ -f1-3`; file=`echo "@" | cut -d/ -f4-`; rsync -R $file ../../../combined; cd ../../../'
 
-echo "6. copying files into out/target/product/$product/system..."
+echo "6. copying files into ${ANDROID_PRODUCT_OUT}/system ..."
 
-rsync -r combined/ ../../out/target/product/$product/system
+rsync -r combined/ ${ANDROID_PRODUCT_OUT}/system
 
 echo "7. removing system.img and system.sfs to force their rebuild"
 
-
-rm -rf ../../out/target/product/$product/obj/PACKAGING/systemimage_intermediates/*
-rm ../../out/target/product/$product/system.sfs
+rm -rf ${ANDROID_PRODUCT_OUT}/obj/PACKAGING/systemimage_intermediates/*
+rm -f ${ANDROID_PRODUCT_OUT}/system.sfs
+rf -rf ${ANDROID_PRODUCT_OUT}/system/priv-app/PackageInstaller
 
 popd > /dev/null
 


On Friday, November 20, 2015 at 11:12:26 AM UTC-5, Dmitry Sutyagin wrote:

Metta Crawler

unread,
Jan 21, 2016, 6:56:02 AM1/21/16
to Android-x86
This is the exact bug that the patch fixes:

6. copying files into out/target/product/x86/system...
rsync: mkdir "/home/metta/src/android/tmp/../../out/target/product/x86/system" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(674) [Receiver=3.1.1]

Luke

unread,
Jan 21, 2016, 9:04:07 PM1/21/16
to Android-x86
Good work but you have a typo and it should remove the GooglePackageInstaller not the PackageInstaller

rm -rf ${ANDROID_PRODUCT_OUT}/system/priv-app/GooglePackageInstaller

Metta Crawler

unread,
Feb 16, 2016, 10:06:43 PM2/16/16
to Android-x86


On Thursday, January 21, 2016 at 9:04:07 PM UTC-5, Luke wrote:
Good work but you have a typo and it should remove the GooglePackageInstaller not the PackageInstaller

I meant what I wrote and I ran what I wrote and it worked. I removed PackageInstaller not GooglePackageInstaller.
Maybe it worked the other way for you but it is not a typo on my part.

Thanks and Regards,
MC
 

Luke

unread,
Feb 16, 2016, 10:23:54 PM2/16/16
to Android-x86
rf -rf ${ANDROID_PRODUCT_OUT}/system/priv-app/PackageInstaller
  ^ should be "rm" thats the typo.

PackageInstaller gets recompiled when using make, causing the 2 package error.

Removing GooglePackageInstaller is the better option.

Metta Crawler

unread,
Feb 17, 2016, 6:14:13 AM2/17/16
to Android-x86
Aah, ya got me! :D

Ok. next time I'll try removing the other one and see.

Jon West

unread,
Feb 22, 2016, 10:25:09 AM2/22/16
to Android-x86
How would one go about doing this with the new opengapps using tar.lz instead of tar.gz?

Hypo Turtle

unread,
Feb 22, 2016, 10:54:00 AM2/22/16
to Android-x86
Something like:

find -name '*.tar.lz' | xargs -n 1 tar --lzip -pxf -C unpacked                                           
at line 26

Jon West

unread,
Feb 22, 2016, 4:50:33 PM2/22/16
to Android-x86
yeah, I didn't have lzip registered correctly. It works now

Jon West

unread,
Feb 22, 2016, 4:52:41 PM2/22/16
to Android-x86
Here is the final with my alterations in case someone else could use it. http://hastebin.com/ijoqilasav.hs

Metta Crawler

unread,
Feb 23, 2016, 6:43:49 AM2/23/16
to Android-x86
Regrettably,

export $ANDROID_PRODUCT_OUT = /home/android/android-x86/out/target/product/android_x86

It does this:

bash: export: `=': not a valid identifier
bash: export: `/home/android/android-x86/out/target/product/android_x86': not a valid identifier

Antony Stone

unread,
Feb 23, 2016, 6:49:53 AM2/23/16
to andro...@googlegroups.com
On Tuesday 23 February 2016 at 12:43:48, Metta Crawler wrote:

> Regrettably,
>
> export $ANDROID_PRODUCT_OUT =
> /home/android/android-x86/out/target/product/android_x86
>
> It does this:
>
> bash: export: `=': not a valid identifier
> bash: export: `/home/android/android-x86/out/target/product/android_x86':
> not a valid identifier

Omit the spaces either side of =


Antony.

--
What do you get when you cross a joke with a rhetorical question?

Please reply to the list;
please *don't* CC me.

Metta Crawler

unread,
Feb 23, 2016, 6:50:50 AM2/23/16
to Android-x86

Luke

unread,
Feb 26, 2016, 12:20:40 AM2/26/16
to Android-x86
Few changes so script can be run using source.

3c3
< prog=$(basename $0)
---
> prog=$(basename $PWD)
7c7
<     exit 1
---
>     return 1
17c17
<     exit 1
---
>     return 1
20c20
< pushd $(dirname $0) > /dev/null
---
> pushd $(dirname "${BASH_SOURCE[0]}") > /dev/null

Midi Jari

unread,
Feb 26, 2016, 7:29:16 AM2/26/16
to Android-x86
I think you should add "lzip" to your requirement list. Thanks for this script :D

Metta Crawler

unread,
Feb 26, 2016, 7:33:16 AM2/26/16
to Android-x86
Can you run "diff -u" instead of just "diff" and post again, please?

Hypo Turtle

unread,
Feb 26, 2016, 3:46:17 PM2/26/16
to Android-x86
Could someone run: wget --secure-protocol=TLSv1_2 https://github.com/opengapps/x86/releases/download/20160226/open_gapps-x86-6.0-pico-20160226.zip and see if it downloads.

Or try the full script http://hastebin.com/savabapowo.hs (untested)

Midi Jari

unread,
Feb 26, 2016, 5:27:06 PM2/26/16
to Android-x86
your script got some problems:

1) why would you specify your OS arch to arm? unless you're releasing this to ANY android build

2) is there any way to make the OS autodetectable from the build folder?

3) the first part of the script may have some problems in the first lines.

4) wget --secure-protocol=TLSv1 https://github.com/opengapps/x86/releases/download/20160226/open_gapps-x86-6.0-pico-20160226.zip <<< I changed the secure protocol for it to work.
Message has been deleted

Hypo Turtle

unread,
Feb 26, 2016, 6:14:11 PM2/26/16
to Android-x86
Thanks I have tested it since and fixed it up a bit: http://hastebin.com/lipaxugovo.bash


On Friday, 26 February 2016 23:27:06 UTC+1, Midi Jari wrote:
your script got some problems:

1) why would you specify your OS arch to arm? unless you're releasing this to ANY android build
Just for completeness... even with the x86 packages you are getting apps from arm devices 
2) is there any way to make the OS autodetectable from the build folder?
There should be (printenv after running a built and check output); but I don't think they have released anything for x86_64   
3) the first part of the script may have some problems in the first lines.
Fixed now I believe 
4) wget --secure-protocol=TLSv1 https://github.com/opengapps/x86/releases/download/20160226/open_gapps-x86-6.0-pico-20160226.zip <<< I changed the secure protocol for it to work.
 I've ran it without the the --secure-protocol and with the TLSv1_2 (githubs protocol) as listed and both work, can you confirm? using GNU Wget 1.16.1

Midi Jari

unread,
Feb 26, 2016, 6:30:47 PM2/26/16
to Android-x86
4) wget --secure-protocol=TLSv1 https://github.com/opengapps/x86/releases/download/20160226/open_gapps-x86-6.0-pico-20160226.zip <<< I changed the secure protocol for it to work.
 I've ran it without the the --secure-protocol and with the TLSv1_2 (githubs protocol) as listed and both work, can you confirm? using GNU Wget 1.16.1
Works with and without :) 

Midi Jari

unread,
Feb 26, 2016, 6:36:14 PM2/26/16
to Android-x86
here is an output ... kinda confusing

1 android_x86 #it would be better do as 1) android_x86
Enter number corresponding to build product or no to enter path manually #instead of no, type manual
1
Next Time please specify product by running "lunch [...]" to set $ANDROID_PRODUCT_OUT variable #WTH?
1. cleaning up...
2. unpacking gapps archive...
grep
: .: Is a directory
A gapps
.zip wasn't found, so let's download one
Which package do you want to download: pico, nano, mini, micro, full, stock
#I stopped the script here


Hypo Turtle

unread,
Feb 26, 2016, 7:50:51 PM2/26/16
to Android-x86
Thanks for the feedback, of course some of the echos could be tweaked; but I think it's functionally sound now.
The lunch echo was from a previous version of this script; as if $A_P_O is already set - via lunch/envsetup.sh from running a build then the $APO doesn't need to be reset by this.

Changes apart from echos to be made:
codewise: have any non-numeric ask for manual path entry, and perhaps remove selection if only one selection if [ ! $APOno =~ "^[0-9]+$" ];
change pico,nano,micro,mini... to p,n,u,m...
set a default zip to download (what should this be: 6.0 x86 pico?) - can someone post printenv/compgen -v after a build/compile...

Andreas Pilz

unread,
Mar 2, 2016, 8:44:29 AM3/2/16
to Android-x86
This looks a little bit complicated. This is on how i do it for my other Software:

create a "opengapps.xml" under .repo/local_manifests in your android x86 source with this content:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="opengapps"
       
fetch="https://github.com/opengapps/"  />
<project path="vendor/google/build" name="aosp_build" revision="master" remote="opengapps" />
<project path="vendor/opengapps/sources/all" name="all" clone-depth="1" revision="master" remote="opengapps" />
<project path="vendor/opengapps/sources/arm64" name="x86" clone-depth="1" revision="master" remote="opengapps" />
</manifest>


In your device/manufacturer/product/device.mk file, in the beginning, add:
GAPPS_VARIANT := <variant>


towards the end, add:
$(call inherit-product, vendor/google/build/opengapps-packages.mk)

To add more Modules in device.mk or vendor/aicp/core/common.mk
This uses the module name. You can find the module name for a package by
checking vendor/google/build/modules/ and look at the LOCAL_MODULE value:
PRODUCT_PACKAGES += [modulname]


that should do the trick and the opengapps should be included during compilation. At least that is how it works on cm and asoap based devices on arm/arm64


Midi Jari

unread,
Mar 26, 2016, 7:21:26 PM3/26/16
to Android-x86
ill be trying this now, tho the sources seem to be heavy...really heavy!
thanks for the sharing.
just to understand well, can you rephrase your statements from "T add more module..." i didnt get it :(

Hypo Turtle

unread,
Mar 26, 2016, 10:26:16 PM3/26/16
to Android-x86
I think looking at these will make it clear:
https://github.com/opengapps/aosp_build/tree/master/modules

The adding more 'modules' is I guess if you want to go off the standard nano/pico/full etc. and want to include any additional app(s).

Andreas Pilz

unread,
Mar 28, 2016, 10:21:57 AM3/28/16
to Android-x86
The Variant i posted is just with the core features to install the play store and play services. With more modules I meant that you can add more google apps to be included in your build

Midi Jari

unread,
Mar 28, 2016, 10:28:10 AM3/28/16
to andro...@googlegroups.com
Thanks that really helped, but once I built the iso i got a PS and PSS FCs :( anyway ill try again. (Note: I changed arm64 that you put into x86 as said in the guide).

--
You received this message because you are subscribed to a topic in the Google Groups "Android-x86" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/android-x86/nbq1VkAJqdo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to android-x86...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-x86.
For more options, visit https://groups.google.com/d/optout.

György Pejović

unread,
Mar 28, 2016, 10:46:03 AM3/28/16
to Android-x86
Gapps for marshmallow-x86 with mesa 11.1.2

Download and extract this file.

Put in your source folder

Add this line into device/generic/common/device.mk

# Get Gapps
$(call inherit-product-if-exists,vendor/google/gapps/gapps.mk)

 

Midi Jari

unread,
Mar 28, 2016, 11:06:29 AM3/28/16
to Android-x86
Can't you add Google Search and Google now? so that we get Now on Tap and stuff.

György Pejović

unread,
Mar 28, 2016, 12:21:36 PM3/28/16
to Android-x86
I have added it and tested.

download

Midi Jari

unread,
Mar 30, 2016, 7:11:25 AM3/30/16
to Android-x86
The file is locked and asks for permission, would you please share a public link?

György Pejović

unread,
Mar 30, 2016, 3:56:06 PM3/30/16
to Android-x86
Try now

Midi Jari

unread,
Mar 30, 2016, 10:35:08 PM3/30/16
to Android-x86
thanks it worked :D

Jason Lammers

unread,
Apr 3, 2016, 10:38:30 PM4/3/16
to Android-x86
Sorry for being noobish, but when reading this: "In your device/manufacturer/product/device.mk file, in the beginning, add:
GAPPS_VARIANT := <variant>" does that mean I put "GAPPS_VARIANT := <variant>" or does it mean I put "GAPPS_VARIANT := pico" or does it mean I put "GAPPS_VARIANT := <pico>"?

Midi Jari

unread,
Apr 3, 2016, 11:02:50 PM4/3/16
to Android-x86

Just pico not <pico>


--

Jason Lammers

unread,
Apr 4, 2016, 12:46:45 AM4/4/16
to Android-x86
Thanks Midi!

zhongtian xie

unread,
Apr 4, 2016, 9:19:25 AM4/4/16
to andro...@googlegroups.com
Hi Mid, how to add SetupWizard.apk(where i can download it ) to prebuilt package, thanks!

--
You received this message because you are subscribed to the Google Groups "Android-x86" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-x86...@googlegroups.com.

zhongtian xie

unread,
Apr 4, 2016, 11:46:25 PM4/4/16
to Android-x86
Hi i noticed  vendor.tar.gz file not include "SetupWizard" , can you add it or tell me how to add it thanks!

在 2016年3月31日星期四 UTC+8上午3:56:06,György Pejović写道:

zhongtian xie

unread,
Apr 4, 2016, 11:46:29 PM4/4/16
to Android-x86
Hi i noticed  vendor.tar.gz file not include "SetupWizard" , can you add it or tell me how to add it thanks!

在 2016年3月31日星期四 UTC+8上午3:56:06,György Pejović写道:
Try now

zhongtian xie

unread,
Apr 5, 2016, 1:18:41 AM4/5/16
to Android-x86
The file is locked and asks for permission !

在 2016年4月5日星期二 UTC+8上午11:46:29,zhongtian xie写道:

zhongtian xie

unread,
Apr 5, 2016, 4:21:49 AM4/5/16
to andro...@googlegroups.com

​Hi György, there isn't "setupwizard", are you sure add it in vendor.tar.gz

--

zhongtian xie

unread,
Apr 5, 2016, 5:16:51 AM4/5/16
to Android-x86
Hi  Andreas,
     i followed the way as below and build lolilipop-x86 succeed, but when i run it something wrong  about setupwizard (unforunately Setup Wizard has stoped):
what i do is:
1.
i create a "opengapps.xml" under .repo/local_manifests in my android x86 source with the content you porvide and run "repo sync"
    
2. add below to "device/generic/common/device.mk"
GAPPS_VARIANT :=pico
$
(call inherit-product, vendor/google/build/opengapps-packages.mk)
3. fix aapt path in "vendor/google/build/config.mk"
GAPPS_AAPT_PATH := prebuilts/sdk/tools/$(HOST_OS)/aapt$(HOST_EXECUTABLE_SUFFIX)

logcat with attachment:


在 2016年3月2日星期三 UTC+8下午9:44:29,Andreas Pilz写道:
logcat-gapps.txt

György Pejović

unread,
Apr 5, 2016, 5:43:44 AM4/5/16
to Android-x86
2016. április 5., kedd 6:18:41 UTC+1 időpontban zhongtian xie a következőt írta:
The file is locked and asks for permission !

Vendor.tar.gz is public

2016. április 5., kedd 9:21:49 UTC+1 időpontban zhongtian xie a következőt írta:

​Hi György, there isn't "setupwizard", are you sure add it in vendor.tar.gz
No, SetupWizard not included


2016. április 5., kedd 4:46:25 UTC+1 időpontban zhongtian xie a következőt írta:
Hi i noticed  vendor.tar.gz file not include "SetupWizard" , can you add it or tell me how to add it thanks!

Gapps for Marshmallow!

 - if you have SetupWizard.apk

Put your SetupWizard.apk into vendor/google/gapps/prebuilt/SetupWizard

Add this in the vendor/google/gapps/prebuilt/Android.mk
include $(CLEAR_VARS)
LOCAL_MODULE := GooglePartnerSetup
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(LOCAL_MODULE)/$(LOCAL_MODULE).apk
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_MODULE_CLASS := APPS
LOCAL_PRIVILEGED_MODULE:= true
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
include $(BUILD_PREBUILT)

and in the vendor/google/gapps/gapps.mk
                SetupWizard \

zhongtian xie

unread,
Apr 5, 2016, 7:42:32 AM4/5/16
to Android-x86


在 2016年4月5日星期二 UTC+8下午5:43:44,György Pejović写道:
2016. április 5., kedd 6:18:41 UTC+1 időpontban zhongtian xie a következőt írta:
The file is locked and asks for permission !

Vendor.tar.gz is public

2016. április 5., kedd 9:21:49 UTC+1 időpontban zhongtian xie a következőt írta:

​Hi György, there isn't "setupwizard", are you sure add it in vendor.tar.gz
No, SetupWizard not included

2016. április 5., kedd 4:46:25 UTC+1 időpontban zhongtian xie a következőt írta:
Hi i noticed  vendor.tar.gz file not include "SetupWizard" , can you add it or tell me how to add it thanks!

Gapps for Marshmallow!

Only Marshmallow ?? i download gapps from "http://opengapps.org/" (select "x86_64" + "5.1" + "pico") ; i want to let it run on  lollipop-x86
 
 - if you have SetupWizard.apk

Put your SetupWizard.apk into vendor/google/gapps/prebuilt/SetupWizard

Add this in the vendor/google/gapps/prebuilt/Android.mk
include $(CLEAR_VARS)
LOCAL_MODULE := GooglePartnerSetup
yes i add LOCAL_MODULE := SetupWizard

Andreas Pilz

unread,
Apr 5, 2016, 5:05:18 PM4/5/16
to Android-x86

@zhongtian xie: Sorry in the sample code I provided , you need to change arm64 in x86 of the local manifest. I havent actually tried it on an x86 build myself yet just on a arm64 device and there it worked without problems for me
Reply all
Reply to author
Forward
0 new messages