Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Install core service on earlier versions than Android 7.0 #70

Open
kenfast opened this issue Sep 13, 2017 · 20 comments
Open

Install core service on earlier versions than Android 7.0 #70

kenfast opened this issue Sep 13, 2017 · 20 comments

Comments

@kenfast
Copy link

kenfast commented Sep 13, 2017

I figured out how to modify the Tango core service (arcore-preview.apk) so that it would install on earlier versions of Android than the 7.0 that is specified in the current file. I was able to install the core service on my Moto X running 5.1, but it is only a 32bit CPU so it didn't work anyway.

Here is my approach.

Rename the .apk file to .zip and unzip to a new folder

Find the android:minSdkVersion and android:targetSdkVersion entries in the AndroidManifest.xml
The manifest file is in binary form. I used [xml-file-format] (http:https://www.olafdietsche.de/2015/05/11/exploring-android-binary-xml-file-format) to find the locations in the binary manifest.
In the stock Google version of the arcore manifest, 14272 bytes, the locations were:
android:minSdkVersion value 0x18 location 0x00001c09
android:targetSdkVersion value 0x17 location 0x00001c1d

Use vim to edit the binary manifest file and change the min and target values to Android 22, 5.1, 0x16.
I found help on the binary settings in vim [here] (https://vi.stackexchange.com/questions/343/how-to-edit-binary-files-with-vim).
vim name.xml
:set binary
:%!xxd
.... find locations, change values...
:%!xxd -r
:w new_name.xml

Replace the original manifest file with the new modified file.
Zip up the contents and rename package back to arcore-preview.apk

Sign the new apk with a local certificate.
I followed the directions [here] (https://stackoverflow.com/questions/31911149/adb-install-parse-failed-unexpected-exception).
I had deleted the META-INF folder from the apk before adding the new signature. I am not sure if this is necessary or not.

Install with adb install -r -d arcore-preview.apk

I built the arcore sample app in Android Studio and set the min and target sdk to 22.
When I run the sample app I get a message right away that Tango Core has stopped. It tries to restart, and then gives another identical message. I end up with a black screen with "searching for surfaces."

Logcat messages show fatal exception, couldn't find "libtango_service_library.so"

@thegreengree
Copy link

Hi, can I ask you to send me modified version of apk so I can test it on my device. I don't really want to go through all of these steps. (But thanks a lot for the info)

@tomthecarrot
Copy link
Owner

Yay! Thank you @kenfast!! Will link to this in the README.

@kenfast
Copy link
Author

kenfast commented Sep 13, 2017

@thegreengree , I am not sure if my apk will work for you since it would have a locally generated certificate that does not go against a public verification authority. You can give it a try. File is zipped.
arcore-preview_sdk_22.zip

@detomato
Copy link

Is there any differences between this modified apk and the one from this repo?

@kenfast
Copy link
Author

kenfast commented Sep 14, 2017

@detomato, the only difference is the values for minSdkVersion and targetSdkVersion in the manifest file. In the original one these are set to 23 (0x18) and 22 (0x17) respectively. In this file both are set to 22 (Android 5.1, 0x16). Oh, one other difference is the certificate. I had to resign this apk, so it has a local certificate from me instead of the original one from Google.

@thegreengree
Copy link

@kenfast So, I was able to install your arcore-preview on my Meizu M2 Note with Flyme 6 (Android 5.1). Android Studio project gave me black screen with "searching for surfaces" as well. Wonder if something can change if I upgrade to LineageOS 14.1 (Android 7.1.2)

@lvonasek
Copy link

Hey @kenfast this looks promising but as earlier Android does not have libcamera2ndk.so and libmediandk.so then it cannot work. (On rooted device there is some chance)

@anky6
Copy link

anky6 commented Sep 15, 2017

@kenfast i was trying your hack but having trouble reading binary xml file. Can u plz providea way to read the file. I am getting the binary file as:
00000000: 0300 0800 c037 0000 0100 1c00 941a 0000 .....7..........
00000010: 6d00 0000 0000 0000 0000 0000 d001 0000 m...............
00000020: 0000 0000 0000 0000 2200 0000 3e00 0000 ........"...>...
00000030: 5800 0000 7200 0000 9000 0000 ae00 0000 X...r...........
00000040: d200 0000 de00 0000 f800 0000 0401 0000 ................
00000050: 2601 0000 4001 0000 4e01 0000 6401 0000 &[email protected]...
00000060: 9001 0000 a401 0000 b201 0000 c001 0000 ................
00000070: d201 0000 fa01 0000 0e02 0000 2602 0000 ............&...
00000080: 3802 0000 4802 0000 6202 0000 8c02 0000 8...H...b.......
00000090: 9e02 0000 f602 0000 fa02 0000 0c03 0000 ................
000000a0: 4003 0000 7403 0000 8803 0000 ac03 0000 @...t...........
000000b0: 4e04 0000 5604 0000 7004 0000 8404 0000 N...V...p.......
000000c0: a604 0000 fc04 0000 5005 0000 a605 0000 ........P.......
000000d0: e005 0000 3206 0000 8406 0000 ba06 0000 ....2...........
000000e0: 0607 0000 5e07 0000 9a07 0000 b407 0000 ....^...........
000000f0: cc07 0000 e807 0000 2e08 0000 4408 0000 ............D...
00000100: 8408 0000 9808 0000 fa08 0000 1809 0000 ................
00000110: 2809 0000 8809 0000 9c09 0000 de09 0000 (...............
00000120: 440a 0000 aa0a 0000 040b 0000 5e0b 0000 D...........^...
00000130: ba0b 0000 160c 0000 6e0c 0000 ac0c 0000 ........n.......
00000140: f80c 0000 4e0d 0000 9e0d 0000 020e 0000 ....N...........
00000150: 640e 0000 ae0e 0000 fa0e 0000 0c0f 0000 d...............
00000160: 840f 0000 0010 0000 7810 0000 f210 0000 ........x.......
00000170: 2811 0000 8411 0000 0412 0000 8012 0000 (...............
00000180: 9412 0000 dc12 0000 2813 0000 7c13 0000 ........(...|...
00000190: d213 0000 2414 0000 7214 0000 7e14 0000 ....$...r......
000001a0: 9214 0000 f214 0000 3e15 0000 8215 0000 ........>.......
000001b0: ca15 0000 e815 0000 4016 0000 9c16 0000 ........@.......
000001c0: f816 0000 2e17 0000 7e17 0000 d217 0000 ........
.......
000001d0: 0618 0000 5818 0000 0f00 6900 6e00 7300 ....X.....i.n.s.
000001e0: 7400 6100 6c00 6c00 4c00 6f00 6300 6100 t.a.l.l.L.o.c.a.
000001f0: 7400 6900 6f00 6e00 0000 0c00 7300 6800 t.i.o.n.....s.h.
00000200: 6100 7200 6500 6400 5500 7300 6500 7200 a.r.e.d.U.s.e.r.
00000210: 4900 6400 0000 0b00 7600 6500 7200 7300 I.d.....v.e.r.s.
00000220: 6900 6f00 6e00 4300 6f00 6400 6500 0000 i.o.n.C.o.d.e...
00000230: 0b00 7600 6500 7200 7300 6900 6f00 6e00 ..v.e.r.s.i.o.n.
00000240: 4e00 6100 6d00 6500 0000 0d00 6d00 6100 N.a.m.e.....m.a.
00000250: 7800 5300 6400 6b00 5600 6500 7200 7300 x.S.d.k.V.e.r.s.
00000260: 6900 6f00 6e00 0000 0d00 6d00 6900 6e00 i.o.n.....m.i.n.
00000270: 5300 6400 6b00 5600 6500 7200 7300 6900 S.d.k.V.e.r.s.i.
00000280: 6f00 6e00 0000 1000 7400 6100 7200 6700 o.n.....t.a.r.g.
00000290: 6500 7400 5300 6400 6b00 5600 6500 7200 e.t.S.d.k.V.e.r.

@kenfast
Copy link
Author

kenfast commented Sep 15, 2017

@anky6, It is not just a matter of reading the binary, but also editing it and writing it back out. I did this using vim. There would be other ways to do it, depending on what tools you have available.

In my binary view I see:
....
0001c00: ffff ffff 0800 0010 1800 0000 1b00 0000 ................
0001c10: 0600 0000 ffff ffff 0800 0010 1700 0000 ................
0001c20: 1b00 0000 0400 0000 ffff ffff 0800 0010 ................
0001c30: 1900 0000 0301 1000 1800 0000 1000 0000 ................
....

The values you want are in bold above.
The value at 00001c08 is the minSdk, 0x18, 24
The value at 00001c1c is the targetSdk, 0x17, decimal 23, Android 23 (6.0)
The value at 00001c30 is the maxSdk, 0x19, 25

I changed the values for minSdk and targetSdk to 0x16, Android 22 (5.1)

As @lvonasek pointed out, this is a dead end unless there is some way to get a long list of shared libraries to bundle with the app APK. According to a comment by Alex Cohn in [this] (https://stackoverflow.com/questions/44185714/which-are-the-android-native-camera-supported-platforms) the following additional libraries would be needed:
libbinder \ liblog \ libgui \ libutils \ libandroid_runtime \ libcamera_client \ libstagefright_foundation \ libcutils \ libcamera_metadata \ libmediandk

@anky6
Copy link

anky6 commented Sep 16, 2017

@kenfast not able to install the arcore apk after performing all the beforementioned steps on my s6 edge phone. Saying "Package cannot be parsed".

@anky6
Copy link

anky6 commented Sep 16, 2017

@kenfast getting searching for surfaces with blank screen on note 2.

@sanchibansal
Copy link

@kenfast hi!
can't seem to find the manifest file from the zip file you gave.

@jumpjack
Copy link

jumpjack commented Feb 15, 2018

@jumpjack
Copy link

And, from official ARcore list of compatibile devices, some new entries!

Samsung Galaxy S7 SM-G930A, SM-G930F, SM-G930K, SM-G930L, SM-G930P, SM-G930R SM-G930S, SM-G930T, SM-G930U, SM-G930V, SM-G930W

@jumpjack
Copy link

This app works for me (others do not):
https://play.google.com/store/apps/details?id=com.hl3hl3.arcoremeasure&hl=it

@jumpjack
Copy link

@tomthecarrot
Copy link
Owner

@jumpjack Thanks for providing that information. The application you referenced might be utilizing an ARCore API modification (such as the one from this repo).

@anawim
Copy link

anawim commented Feb 16, 2018

S7 working with Atom Visualizer and Motion Still NOT working with Measure

@jumpjack
Copy link

there are 2 versions of arcore measure: "standard" and "for all".
And just a week ago it came out preview 2 of ARcore.

@anawim
Copy link

anawim commented Feb 16, 2018

After system reboot Measure (NOT the one for all obviously) works

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

No branches or pull requests

9 participants