Closed narayangour closed 4 years ago
Hi @narayangour. Please attach error log from Android LogCat.
please find attached below
Do you have valid token in values/developer-config.xml
?
" xml version="1.0" encoding="utf-8"? !-- Please put your MAPBOX_ACCESS_TOKEN here --> resources> string name="mapbox_access_token"></string /resources "
this is content from xml file. shall i mention same token as mention in gradle.properties file.
if i update token same as properties file the error:
Executing tasks: [:Examples:assembleDebug] in project /home/narayan/vision/mapbox-vision-android
FAILURE: Build completed with 2 failures.
Where: Script '/home/narayan/vision/mapbox-vision-android/gradle/generate-token.gradle' line: 33
What went wrong: A problem occurred evaluating script.
You haven't set MAPBOX_ACCESS_TOKEN. Please set it in
/src/main/res/values/developer-config.xml
What went wrong: A problem occurred configuring project ':Examples'.
compileSdkVersion is not specified. Please add it to build.gradle
Get more help at https://help.gradle.org
BUILD FAILED in 28s
does developer-config.xml and gradle.properties file token should be different ? not aware what is valid token in values/developer-config.xml , possible to share more on this.
It's good practice to have 2 tokens:
VISION:DOWNLOAD
scope (that one should go to ~/.gradle/gradle.properties
)VISION:READ
scope (that one should go to values/developer-config.xml
)
That's pretty strange gradle fails when you try to set token in values/developer-config.xml
. This file is generated by gradle automatically. Please add your token with VISION:READ
scope there and sync with gradle files again.still facing same issue. after creating two different token also.
attaching snapshot of two different token created and two files where i updated token.
gradle.properties:
android.enableJetifier=true android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m maven { mapboxMavenUser=mapbox mapboxMavenToken=sk.eyJ1IjoibmdvdXI5NiIsImEiOiJjazk4ZXR3NnIwMXFoM2dsbDBjYmxpYXV4In0.SKrI6tsv2Yhlu9FPQj3sfA }
generate-token.gradle :-
// // Configuration file for adding a developer-config.xml containing the MAPBOX_ACCESS_TOKEN env. variable. // task accessToken { final TOKEN_FILE = "developer-config.xml" final TOKEN_DIR = "src/main/res/values" final MAPBOX_ACCESS_TOKEN = "pk.eyJ1IjoibmdvdXI5NiIsImEiOiJjazk4Zmt3OHMxYm4zM21ydTkzMTRma3lpIn0.wEhynJIP6pFOB5G6kqHl2Q"
def tokenDir = new File("${projectDir}/${TOKEN_DIR}")
if (!tokenDir.exists()) {
tokenDir.mkdir()
}
def tokenFile = new File("${projectDir}/${TOKEN_DIR}/${TOKEN_FILE}")
String token
if (tokenFile.exists()) {
def startPos = tokenFile.text.indexOf(MAPBOX_ACCESS_TOKEN) + MAPBOX_ACCESS_TOKEN.length() + 2
def endPos = tokenFile.text.indexOf("<", startPos)
token = tokenFile.text.substring(startPos, endPos)
} else {
// check env
token = "$System.env.MAPBOX_ACCESS_TOKEN"
if (token == "null") {
token = ""
}
String tokenFileContents = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<!-- Please put your MAPBOX_ACCESS_TOKEN here -->\n" +
"<resources>\n" +
" <string name=\"" + MAPBOX_ACCESS_TOKEN + "\">" + token + "</string>\n" +
"</resources>"
tokenFile.write(tokenFileContents)
}
if (token == "") {
throw new InvalidUserDataException("You haven't set MAPBOX_ACCESS_TOKEN.\n" +
"Please set it in <module>/${TOKEN_DIR}/${TOKEN_FILE}")
}
}
gradle.projectsEvaluated { preBuild.dependsOn('accessToken') }
can u help me where i am doing wrong.
You do not need to update generate-token.gradle
file.
You need to put correct token inside file values/developer-config.xml
file.
<?xml version="1.0" encoding="utf-8"?>
<!-- Please put your MAPBOX_ACCESS_TOKEN here -->
<resources>
<string name="mapbox_access_token">YOUR_ACTUAL_TOKEN</string>
</resources>
BTW if going your way you need to init token
variable with actual token and not change final MAPBOX_ACCESS_TOKEN = "mapbox_access_token"
.
Yes , by doing this I am able to build and open app without crash in my mobile. but in ArActivity.java i notice source and target locations are hard coded. any idea how i can change to source= my current location always and target whatever i wish to feed.
it print of screen "can not calculate the route requested"
@kiryldz any update on my request ?
steps that i follow -: 1) i clone the SDK in my local machine from here := https://github.com/mapbox/mapbox-vision-android 2) I have created my mapbox account and created a token. 3) added token into gradle.properties(project Properties) like maven { mapboxMavenUser=mapbox mapboxMavenToken=my token(removed real one) } 4) Build into android studio 3.6.1 and run on my mobile one plus 7. installation is done , but when i open an app it looks like crashing it. attaching a screen shot from mobile device.
My question is : - 1) can i run a demo like shown in below link: road https://docs.mapbox.com/android/vision/examples/basic-ar-navigation/
if yes how to run standalone AR demo.
Please update me with exact procedure so that i can learn and develop something meaning.