Issue with your examples

13 posts / 0 new
Last post
Euon
Issue with your examples

Hello, 

i'm trying to use your service in my android app. I followed your step-by-step guide (Put a Marker on the Map section), but when i launch the app nothing is shown: a totally black screen. In the log i can see:

"Request failed due to a permanent error: 
MapboxAccountManager was not started correctly. Use MapboxAccountManager#start(Context, String) to initialise. 
More information in this guide https://www.mapbox.com/help/first-steps-android-sdk/#access-tokens."

and

"{beron.semiperdo}[HttpRequest]: Please contact MapQuest Developer Services to obtain a valid key.
{beron.semiperdo}[Setup]: loading style failed: 
MapboxAccountManager was not started correctly. Use MapboxAccountManager#start(Context, String) to initialise. 
More information in this guide https://www.mapbox.com/help/first-steps-android-sdk/#access-tokens."

I don't understand what is the matter and why it is asking for mapbox (???) access token. 

Thanks


MQBrianCoakley
Is the application key set in
Is the application key set in the activity_main.xml file as the sample code shows?   app:mapquest_app_key="YOUR_MAPQUEST_KEY_HERE"

Euon
Yes

I put that line of code here: 

 

<com.mapquest.mapping.maps.MapView
android:id="@+id/mapquestMapView"
app:mapquest_app_key="***"
android:layout_height="match_parent"
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

 

in the activity that are going to contain the map


MQBrianCoakley
Does the MainActivity.java
Does the MainActivity.java have MapQuestAccountManager.start(getApplicationContext());?

Euon
No

Mmm no! But.. where? The map is only in "MapActivity.java", where i have to put the key?


MQBrianCoakley
The key goes in activity_main
The key goes in activity_main.xml and the AccountManager goes in MainActivity.java.

TimKE
I have the same issue and if

I have the same issue and if I want to setup the AccountManager it says, that "Cannot resolve symbol 'MapQuestAccountManager'" why is that?

I'm trying to import the following: "import com.mapquest.mapping.MapQuestAccountManager;"


MQBrianCoakley
It seems like the sdk may not
It seems like the sdk may not be getting imported into the project. Are the url and version correct in the build.gradle files? What version are you using?

TimKE
I followed your instructions

I followed your instructions on this side: https://developer.mapquest.com/documentation/android-sdk/

1. Project build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
maven {
url "http://artifactory.cloud.mapquest.com/artifactory/et-android-binaries"
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

2. Module:app build.gradle

apply plugin: 'com.android.application'

def getApiKey() {
def props = new Properties()
file("mapquest.properties").withInputStream { props.load(it) }
return "\"" + props.getProperty("api_key") + "\""
}

android {
compileSdkVersion 27
defaultConfig {
applicationId "xxxxx"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
applicationVariants.all { variant ->
variant.buildConfigField "String", "API_KEY", getApiKey() // Provides key for the Navigation SDK
variant.resValue "string", "API_KEY", getApiKey() // Provides key for the MapView used in app layouts
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:design:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation('com.mapquest:navigation:3.3.0') // the MapQuest Navigation SDK
implementation('com.mapzen.android:lost:3.0.4') // used for GPS Location Acquisition (see notes)

implementation('com.mapquest:mapping-android-sdk:2.0.1') { // for Mapping SDK MapView; displays route to navigate
exclude group: 'com.android.support' // (note: in your app, you might omit this 'exclude')
}

implementation('com.mapquest:search-ahead-v3:1.2.9') // for the MapQuest "Search Ahead" feature (optional)

implementation('com.mapquest:mapping-android-sdk:1.3.2@aar') {
transitive = true
}
}

3. (Shows up fine in the Preview)

<com.mapquest.mapping.maps.MapView xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mapquestMapView"
app:mapquest_app_key="xxxMAPQUEST_KEYxxxx"
/>

So far everything compiles without any errors. But when I start my app it crashes with the mentioned message above. So I tried adding the import line as mentioned in my MainActivity. But that doesn't seem to work.

I'm using AndroidStudio 3.1.2 with Linux Mint x64.


shoelerMQ
Hi Tim,
Hi Tim, It seems like your mapquest.properties file is not configured correctly.  This file should be named 'mapquest.properties' and should be stored in the parent folder of the project.  There is a single line of information stored in the file and it should look like this: api_key=YOUR_API_KEYI have attached an image of the directory structure based on our sample application.  Please let us know if you have any other questions.   Thanks

TimKE
Hi shoelerMQ,

Hi shoelerMQ,

Thank you for your answer, I'll try your solution.

It seems like i missunderstood the instructions on this page: https://developer.mapquest.com/documentation/nav-sdk/android/v3.3/

I thought it belongs inside the 'app' folder, inside my projekt and not next to it, the way it is on your image.

 

Best Regards

TimKE


TimKE
When I move the file, I get

When I move the file, I get the following error: /home/TimKe/AndroidStudioProjects/xxxxxx/app/mapquest.properties (No such file or directory)


shoelerMQ
Hi Tim,
Hi Tim, You will want to place that file in the parent of the 'app' folder.    /home/TimKe/AndroidStudioProjects/xxxxxx/mapquest.properties You may need to create this file with a standard text editor.  For some reason, Android Studio will not write files to the root project directory. Please let us know if this does not work for you. Thanks, Schuyler