Profile wont matched with graph cache in version 9.0

Hey Community ,

I have created graph-cache data using area.osm.pbf using graph hopper version 9.0.What I am facing currently while loading graph-cache from internal storage from android its land into exception says

"Profiles do not match:
Graphhopper config: car|1078853760
Graph: car|475363489
Change configuration to match the graph or delete /data/user/0/com.bps.bpass.mainpackage/files/graph-cache/"

where as I am using config file of car which is provided by graph hopper version 9.0 so what exactlty went wrong ?

This is my code to initialze graph hopper profile

GraphHopper hopper = new GraphHopper();
** hopper.setGraphHopperLocation(graphCacheDir.getAbsolutePath());**
** Profile carProfile = new Profile(“car”)**
** .setName(“car”); // Or load actual car.json if needed**
** hopper.setProfiles(carProfile);**
** hopper.load(); // Load from graph-cache**

where as I am using config.yml sample exist in the repository of graph hopper.Need help commmunity !

Have you tried deleting the cache in /data/user/0/com.bps.bpass.mainpackage/files/graph-cache/? This happens when you change the profile and try to rerun without deleting the cache data.

@omduggineni Yes I have deleted the graph-cache file using adb shell command and even uninstalled application afterward but it shows same exception

I am using the basic provided config.yml file along with this patch of code version is 9.0 of graph hopper.

This is my code snippet for you where I defined options exist in config.yml file.If something is missed do let me know please to add !

Link for config.yml provided by library but it wont able to match profiles :

 private class LoadGraphHopperTask extends AsyncTask<Void, Void, GraphHopper> {

        @Override
        protected GraphHopper doInBackground(Void... params) {
            try {
                File graphCacheDir = new File(getFilesDir(), "graph-cache");
                // Step 1: Copy graph from assets if not already copied
                if (!graphCacheDir.exists() || graphCacheDir.list() == null || Objects.requireNonNull(graphCacheDir.list()).length == 0) {
                    copyAssetsFolder(getApplicationContext(), "map/graph-cache", graphCacheDir.getAbsolutePath());
                }
                GraphHopper hopper = new GraphHopper();
                hopper.setGraphHopperLocation(graphCacheDir.getAbsolutePath());
                hopper.setEncodedValuesString("car_access, car_average_speed");
                hopper.setProfiles(new Profile("car").setCustomModel(GHUtility.loadCustomModelFromJar("car.json")));
                hopper.getCHPreparationHandler().setCHProfiles(
                        new CHProfile("car")
                );
                hopper.load();
                return hopper;
            } catch (Exception e) {
                Log.e("GraphHopper", "Error loading GraphHopper data", e);
                return null;
            }
        }

        @Override
        protected void onPostExecute(GraphHopper hopper) {
            if (hopper != null) {
                // Calculate route now
                GeoPoint start = new GeoPoint(33.6844, 73.0479); // Example: Islamabad
                GeoPoint end = new GeoPoint(33.7380, 72.9998);   // Example: Near Islamabad
                drawGraphHopperRoute(hopper, start, end);
            }
        }
    }

@omduggineni This is what appears inside library code even I am using same car.json

car profiles id mismatched so what exactly went wrong ?

Hi @karussell , kindly look into it !

I dont know why ids are Mismatched in version 9.0 even car.json is same when created graph-cache using web server and I have checked same json exist in jar file of com.graphhopper

Attaching image of imported lib of gh

I think for the profile ids to match they need to be identical, see this code in Profile.java:

    private String createContentString() {
        // used to check against stored custom models, see #2026
        return "name=" + name + "|turn_costs={" + turnCostsConfig + "}|weighting=" + weighting + "|hints=" + hints;
    }

    public int getVersion() {
        return Helper.staticHashCode(createContentString());
    }

In your config.yml the profile looks like:

  profiles:
   - name: car
     custom_model_files: [car.json]

But in your Java code you set the custom model directly (which uses the custom_model key in the hints map).