How to setup OTM android

162 views
Skip to first unread message

Nico Aliotta

unread,
May 9, 2016, 2:05:37 PM5/9/16
to opentreemap-user
I'm tryng to use otm android on android studio 2.1. I've installed all the necessary software and all that needs android studio (SDK, extras etc)

but i recieve from the app:
20:05:19 Gradle sync started
20:05:48 Gradle sync failed: C:\otm-android-master\OpenTreeMapSkinned\AndroidManifest.xml (Impossibile trovare il file specificato)
         Consult IDE log for more details (Help | Show Log)

So i think that i've to edit  the AndroidManifest.xml and default.xml in C:\otm-android-master\templates and copy and paste them in C:\otm-android-master\OpenTreeMapSkinned\ ???

this is my default.xml

<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- Instance specific -->
<string name="app_name">Napoli</string><string name="skin_code">%(url_name)s</string>
<!-- backend specific -->
<string name="base_url">http://localhost:7070/</string><string name="api_url">http://localhost:7070/api/v3</string><string name="tiler_url">http://localhost:7070/tile/</string><string name="access_key">accesskey</string><string name="secret_key">secretkey</string>
<!-- build specific -->
<string name="platform_ver_build">1</string>
<!-- Developer specific -->
<string name="google_maps_api_key">MY_GOOGLE_MAP_APIKEY</string>
<!-- TODO: Constants should probably be in the main repo -->
<string name="starting_zoom_level">12</string></resources>              and the AndroidManifest.xml            
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionName="1.0" android:versionCode="1" package="org.napoli" xmlns:android="http://schemas.android.com/apk/res/android"><uses-sdk android:targetSdkVersion="16" android:minSdkVersion="10"/></manifest>
Sorry but the readme is not clear for me.
Is it correct? or the problem is another?

and

Michael Maurizi

unread,
May 10, 2016, 10:08:02 AM5/10/16
to opentreemap-user
Nico,

Your AndroidManifest.xml looks correct, but you need to correct the values in default.xml.

You'll need to fill in the "skin_code" to match the "url_name" of the tree map you created in step 10 of the installation guide (https://github.com/OpenTreeMap/otm-core/wiki/Installation-Guide#step-10-create-a-treemap-instance).

You'll also need to fill in appropriate values for access key and secret key.  You can look at https://groups.google.com/forum/?fromgroups#!searchin/opentreemap-user/android/opentreemap-user/v9kpMG6C72s/W4SzmwbWQl0J where someone else on the mailing list had similar issues.

Also important, you can't use "http://localhost:7070/" for your URLs.  In this context, that would mean that your phone would try and connect to itself when trying to connect to the opentreemap server.  You should replace "localhost" with the IP address or domain name of your server (for example, for the SaaS product, we use "opentreemap.org").

Both files will need to be placed into the correct locations.  AndroidManfiest.xml needs to go at "OpenTreeMapSkinned/AndroidManifest.xml", and defaults.xml needs to be at "OpenTreeMapSkinned/res/values/defaults.xml"

 - Michael

--
You received this message because you are subscribed to the Google Groups "opentreemap-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opentreemap-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

Michael Maurizi, Software Developer
Azavea |  990 Spring Garden, 5th Floor, Philadelphia, PA
mmau...@azavea.com | Web azavea.com  |  @azavea

Nico Aliotta

unread,
May 10, 2016, 12:46:21 PM5/10/16
to opentreemap-user
in step 10 i did:
./manage.py create_instance Napoli --url_name=Napoli --user=nicoaliotta --center=14.264335,40.8650474

so my url_name is Napoli

<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- Instance specific -->
<string name="access_key">accesskey</string>
<string name="secret_key">secretkey</string>
<!-- build specific -->
<string name="platform_ver_build">1</string>
<!-- Developer specific -->
<string name="google_maps_api_key">MY_GOOGLE_MAP_APIKEY</string>
<!-- TODO: Constants should probably be in the main repo -->
<string name="starting_zoom_level">12</string></resources>              and the AndroidManifest.xml
is it ok <string name="skin_code">Napoli</string> or i need also the % in the string?

Only for test can i use the local ip of the server 192.168.1.36?
I know that will work only on wifi for now.


<string name="access_key">accesskey</string>
<string name="secret_key">secretkey</string>

Thanks Always for your help
Message has been deleted

Nico Aliotta

unread,
May 14, 2016, 2:14:28 PM5/14/16
to opentreemap-user
I can see on smartphone the splash screen of the app but nothing happens after
 
this is the error log in android monitor:


the other pastebin was not correct

Nico Aliotta

unread,
May 17, 2016, 2:50:38 PM5/17/16
to opentreemap-user
Finally with the help of Maurizi i created the 2 Keys to add in default.xml

I write here what i did so if someone in future will have problems can follow this instructions:

cd /usr/local/otm/app/opentreemap 
python manage.py shell
then
(InteractiveConsole)
>>> from api.models import APIAccessCredential
>>> key = APIAccessCredential.create()

then run these 2 commands to see at screen the Keys that you will have to copy and paste in default.xml:
>>> print key.access_key and then
>>> print key.secret_key

Now i've created in C:\otm-android-master\OpenTreeMapSkinned\res\values\default.xml

and this is the content

but in android studio i recieve

:OpenTreeMapSkinned:generateDebugResources
:OpenTreeMapSkinned:mergeDebugResources
C:\otm-android-master\OpenTreeMapSkinned\res\values\defaults.xml:3:1: Error: Il contenuto non è consentito nel prologo. = (Content is not allowed in prolog)
:OpenTreeMapSkinned:mergeDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':OpenTreeMapSkinned:mergeDebugResources'.
> C:\otm-android-master\OpenTreeMapSkinned\res\values\defaults.xml:3:1: Error: Il contenuto non è consentito nel prologo. = Content is not allowed in prolog
* 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: 13.359 secs



Nico Aliotta

unread,
May 18, 2016, 1:56:21 PM5/18/16
to opentreemap-user
The problem was the typo - before resource (thanks to my guardian angel Maurizi)

Here i'm with another problem! i can see my instance, i can see the map but when the app starts i cannot see my area of "studio" that is Italy
but the map is in the middle of the Atlantic Ocean. ( i can see only water) If i zoom out and move in Italy i can see also the trees that i added!

If i go on the web page from browser of smartphone of my istance i can see from the first time italy.

Do i've to set something in the app to set the center of the map?
i've <string name="starting_zoom_level">12</string> in default.xml as you suggest in readme
 

 

Ricard Roca Munárriz

unread,
May 20, 2016, 11:49:13 AM5/20/16
to opentreemap-user
Hello Nico,

In my opinion your problem is due to lat,lon order.
http://stackoverflow.com/questions/7309121/preferred-order-of-writing-latitude-longitude-tuples
Just swap your coordinates tuple order creating your instance. Seems PostGIS expects lng/lat.

Hope it solves your problem


El dimecres, 18 maig de 2016 19:56:21 UTC+2, Nico Aliotta va escriure:

Nico Aliotta

unread,
May 21, 2016, 1:04:54 AM5/21/16
to opentreemap-user
Lat/lon was correct infact via browser all was fine.

I closed app reopened and all was fine :)

Don't know why but the first time that i runned was wrong.
Reply all
Reply to author
Forward
0 new messages