Hello, I am trying to download a map for offline use but am running into trouble with generating the parameters as per this error I get (I have included my code also):
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_offline); // inflate MapView from layout aMapView = (MapView) findViewById(R.id.mapView); map = new ArcGISMap(Basemap.Type.LIGHT_GRAY_CANVAS_VECTOR, 48.6596, -113.7870, 9); aMapView.setMap(map); // create a graphics overlay and symbol to mark the extent mGraphicsOverlay = new GraphicsOverlay(); aMapView.getGraphicsOverlays().add(mGraphicsOverlay); mProgressLayout = (RelativeLayout) findViewById(R.id.progressLayout); final ProgressBar progressBar = (ProgressBar) findViewById(R.id.taskProgressBar); mProgressTextView = (TextView) findViewById(R.id.progressTextView); // get the callout that shows attributes //aCallout = aMapView.getCallout(); // layer 0, facilities table0 = new ServiceFeatureTable(getResources().getString(R.string.layer0_url)); final FeatureLayer featureLayer0 = new FeatureLayer(table0); map.getOperationalLayers().add(featureLayer0); // get the callout that shows attributes //aCallout = aMapView.getCallout(); // layer 1, trails table1 = new ServiceFeatureTable(getResources().getString(R.string.layer1_url)); final FeatureLayer featureLayer1 = new FeatureLayer(table1); map.getOperationalLayers().add(featureLayer1); // create a graphics overlay and symbol to mark the extent final GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); aMapView.getGraphicsOverlays().add(graphicsOverlay); final SimpleLineSymbol boundarySymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.RED, 5); final Button startdownload = (Button) findViewById(R.id.startdownload); // create a geodatabase sync task final GeodatabaseSyncTask geodatabaseSyncTask = new GeodatabaseSyncTask(getString(R.string.glacier_sync)); geodatabaseSyncTask.loadAsync(); geodatabaseSyncTask.addDoneLoadingListener(() -> { // generate the geodatabase sync task startdownload.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // show the progress layout progressBar.setProgress(0); mProgressLayout.setVisibility(View.VISIBLE); // clear any previous operational layers and graphics if button clicked more than once map.getOperationalLayers().clear(); graphicsOverlay.getGraphics().clear(); // show the extent used as a graphic Envelope extent = aMapView.getVisibleArea().getExtent(); Graphic boundary = new Graphic(extent, boundarySymbol); graphicsOverlay.getGraphics().add(boundary); // create generate geodatabase parameters for the current extent final ListenableFuture<GenerateGeodatabaseParameters> defaultParameters = geodatabaseSyncTask .createDefaultGenerateGeodatabaseParametersAsync(extent); defaultParameters.addDoneListener(new Runnable() { @Override public void run() { try { // set parameters and don't include attachments ******* GenerateGeodatabaseParameters parameters = defaultParameters.get(); // set the sync model to per layer parameters.setSyncModel(SyncModel.PER_LAYER); // define the layers and features to include int facilities = 1; int trails = 3; // Clear and re-create the layer options parameters.getLayerOptions().clear(); parameters.getLayerOptions().add(new GenerateLayerOption(facilities)); parameters.getLayerOptions().add(new GenerateLayerOption(trails)); parameters.setReturnAttachments(false); /* // define the local path where the geodatabase will be stored final String localGeodatabasePath = getCacheDir().toString() + File.separator + getString(R.string.file_name); // create and start the job final GenerateGeodatabaseJob generateGeodatabaseJob = geodatabaseSyncTask .generateGeodatabaseAsync(parameters, localGeodatabasePath); generateGeodatabaseJob.start(); mProgressTextView.setText(getString(R.string.progress_started)); // update progress generateGeodatabaseJob.addProgressChangedListener(() -> { progressBar.setProgress(generateGeodatabaseJob.getProgress()); mProgressTextView.setText(getString(R.string.progress_fetching)); }); // get geodatabase when done generateGeodatabaseJob.addJobDoneListener(new Runnable() { @Override public void run() { mProgressLayout.setVisibility(View.INVISIBLE); if (generateGeodatabaseJob.getStatus() == Job.Status.SUCCEEDED) { final Geodatabase geodatabase = generateGeodatabaseJob.getResult(); geodatabase.loadAsync(); geodatabase.addDoneLoadingListener(new Runnable() { @Override public void run() { if (geodatabase.getLoadStatus() == LoadStatus.LOADED) { mProgressTextView.setText(getString(R.string.progress_done)); for (GeodatabaseFeatureTable geodatabaseFeatureTable : geodatabase .getGeodatabaseFeatureTables()) { geodatabaseFeatureTable.loadAsync(); map.getOperationalLayers().add(new FeatureLayer(geodatabaseFeatureTable)); } startdownload.setVisibility(View.GONE); Log.i(TAG, "Local geodatabase stored at: " + localGeodatabasePath); } else { Log.e(TAG, "Error loading geodatabase: " + geodatabase.getLoadError().getMessage()); } } }); // unregister since we're not syncing ListenableFuture unregisterGeodatabase = geodatabaseSyncTask .unregisterGeodatabaseAsync(geodatabase); unregisterGeodatabase.addDoneListener(new Runnable() { @Override public void run() { Log.i(TAG, "Geodatabase unregistered since we wont be editing it in this sample."); Toast.makeText(OfflineActivity.this, "Geodatabase unregistered since we wont be editing it in this sample.", Toast.LENGTH_LONG).show(); } }); } else if (generateGeodatabaseJob.getError() != null) { Log.e(TAG, "Error generating geodatabase: " + generateGeodatabaseJob.getError().getMessage()); } else { Log.e(TAG, "Unknown Error generating geodatabase"); } } });*/ } catch (InterruptedException | ExecutionException e) { Log.e(TAG, "Error generating geodatabase parameters : " + e.getMessage()); } } }); } }); }); } E/CRGdb: Error generating geodatabase parameters : com.esri.arcgisruntime.ArcGISRuntimeException: Invalid response
*******I have commented out portions of the code because it was returning this error each time and I wanted to know when it began (apparently it was after this line:
GenerateGeodatabaseParameters parameters = defaultParameters.get();
I realize this thread is ancient, but curious if anyone else has encountered this or has a solution? I am having the same issue when upgrading an app to 100.* The specific error message when running the .get() method is: "extent geometry and spatial reference must be non-null. The createDefaultGenerateGeodatabaseParametersAsync method doesn't take a spatial reference parameter and I am passing an extent into the the method, so the error message doesn't make sense in this context.