lincomatic / osmbonuspack

Automatically exported from code.google.com/p/osmbonuspack
0 stars 0 forks source link

Problem of BonusPack tuto when porting in Android Studio #106

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Integration of OSMBonusPack tuto in Android Studio environment

What is the expected output? What do you see instead?
- in Eclipse IDE : no problem
- Android Studio : trouble with RoadManager and OSM API (road is not loaded, 
and waypoints not found ...)
"Error when loading the road"
"Error when loading KML"

see : attached snapshot (I can not attach the project ... too big)

What version of the products are you using (Android SDK, osmdroid,
OSMBonusPack)?
OsmBonusPack 5.1

Please provide any additional information below.

Original issue reported on code.google.com by courd...@gmail.com on 24 Jan 2015 at 9:10

Attachments:

GoogleCodeExporter commented 9 years ago
Some clues for explanation ?
-> in Android studion, I have included OsmBonusPack as a whole as a library (in 
a Android Studio module) that is declared as dependency of another module that 
integrates OsmBonusPackTuto as a whole.
-> doing this, building is Ok but I get failures when OsmBonusPack classes 
tries to connect to internet : so this is a clue ->  something may be wrong 
with permission.
-> on internet, I found a thread indicating that in Android Studio, each module 
has its own Manifest
-> so, I have added INTERNET permission to the Manifest attached to the 
OmsBonusPack module, but result is the same :-( ...

/////////////////////////
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.osmdroid.bonuspack"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="11" />

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
////////////////////////

Anybody has an idea ?

Original comment by courd...@gmail.com on 25 Jan 2015 at 10:31

GoogleCodeExporter commented 9 years ago
New trials : if i use directly osmbonuspack as a lib in my Android studio 
Project, i get the same problem as with osmbonuspack as a library module. So 
the problem comes from the way to use the library and how to give it adequate 
internet permissions.... 
No idea ?

Original comment by tryphon....@gmail.com on 26 Jan 2015 at 10:32

GoogleCodeExporter commented 9 years ago
Nobody has a solution ???

Original comment by courd...@gmail.com on 31 Jan 2015 at 6:17

GoogleCodeExporter commented 9 years ago
I've not tried Android Studio yet. 

1) Have you carefully read the "Important note about network calls" in 
Tutorial_0?

2) If you have to set a Manifest and permissions inside OSMBonusPack lib (which 
sounds really strange), then you certainly have to do the same on osmdroid lib. 

Original comment by mathieu....@gmail.com on 31 Jan 2015 at 5:49

GoogleCodeExporter commented 9 years ago
You were right Mathieu !

After reading 1) i deviced to downgrade sdk version.

In Android studio, build.gradle file is the place where you put such 
information. Manifest.xlm can still indicate but is not taken into account 
(there are still some parameters to place in manifest , i have to check).

So i modified  targetSdkVersion value in build.gradle file (see copy below) : 9 
is ok but over 10 does not work.

You will see in build.gradle that i use .jar version of osmbonuspack (5.1) 
placed in libs folder.

////////
apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "com.example.osmbonuspacktuto"
        minSdkVersion 7
        targetSdkVersion 9
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
compile project(':aFileChooser')
//compile project(':OSMBonusPack')
    compile fileTree(dir: 'libs', include: ['*.jar'])
}
//////////////////

Original comment by courd...@gmail.com on 1 Feb 2015 at 7:03