mapbox / mapbox-vision-android

Other
50 stars 43 forks source link

not able to run "Basic AR navigation" demo in my mobile #241

Closed narayangour closed 4 years ago

narayangour commented 4 years ago

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. Screenshot_20200419-174214

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.

kiryldz commented 4 years ago

Hi @narayangour. Please attach error log from Android LogCat.

narayangour commented 4 years ago

please find attached below

Logcat.txt

kiryldz commented 4 years ago

Do you have valid token in values/developer-config.xml?

narayangour commented 4 years ago

" 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.

narayangour commented 4 years ago

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.

1: Task failed with an exception.

2: Task failed with an exception.

BUILD FAILED in 28s

narayangour commented 4 years ago

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.

kiryldz commented 4 years ago

It's good practice to have 2 tokens:

narayangour commented 4 years ago

still facing same issue. after creating two different token also.

attaching snapshot of two different token created and two files where i updated token.

Screenshot from 2020-04-20 18-02-30

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.

kiryldz commented 4 years ago

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".

narayangour commented 4 years ago

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"

narayangour commented 4 years ago

@kiryldz any update on my request ?