Select to view content in your preferred language

Fatal exceptions when updating from Beta to Release

2386
19
12-30-2011 09:18 AM
JasonKiesel
Deactivated User
We just updated the ESRI Android SDK to the latest version (going from beta to release) and we were at once riddled with new errors. The project didn't even build once when the .JAR files were updated. We had something on the order of 50 to 60 build errors. We've finally got the build errors gone, but now we can't even view an Activity that has a MapView included.

We've looked at the docs, even double checked them, but we're getting a fatal exception with the new SDK.
0 Kudos
19 Replies
PeterGlenewinkel
Occasional Contributor
Hi,

i have had the same problem i think.

mMapView.addLayer(new ArcGISDynamicMapServiceLayer(getString(R.string.url)));

This is the point which causes the Nullpointerexception. You can do a workaround if you create a string:
String url = getResources().getString(R.string.url);
then do:
mMapView.addLayer(new ArcGISDynamicMapServiceLayer(url);

I think if you would do it your way the string returned from "getString(R.string.url)" is null because the android system initializes the mapview before the strings from the call getString could be initialized.

Please excuse my poor english! 🙂
0 Kudos
DennisBaliton
Emerging Contributor
Hello,

glenewinkel89, I tried that and I'm still getting a null return value.

Dennis
0 Kudos
SaurabhGupta
Emerging Contributor
Hi Dennis,

Can you please try creating a new ArcGIS Android Project (not a sample) and then port your code into that project. And see if you still get the same error ?

Also, if you can debug your app and see if the value for getString(R.string.url) is null or not ?


Regards.
0 Kudos
DennisBaliton
Emerging Contributor
Hello,

I am still getting the same error.

1.) - Port the existing code using the following method.
------a.) Create an "ArcGIS Project for Android"
------b.) used the original Package Name
------c.) Imported the project
------d.) Fixed all the errors
------e.)Build and tested on an HTC Sensation
------f.)**Same result, null value when trying to addLayer.
------e.)line where the exception occurs.
mMapView.addLayer(new ArcGISDynamicMapServiceLayer(url));


2.) - I am using "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" and it is being evaluated at runtime

      String url = getString(R.string.url_map_tiles);
      mMapView.addLayer(new ArcGISDynamicMapServiceLayer(url));
0 Kudos
DanO_Neill
Deactivated User
Don't want to get too caught up on language but what do you mean in step 1c. "Imported the project"?   Be sure not to import your beta project, only the source as when you create a new project with the SDK Eclipse plugin all your settings and required libraries are up to date for release app development.  At this point you should only need to bring in source java and/or XML files from your beta project and refactor appropriately. 

Next:  Can you test the service directly from the MapView.addLayer() method?  I would like to isolate your issue and confirm so please remove the String url and replace with the actual URL string "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" and let us know if your app starts working or if you continue to have issues.  I understand you may have a requirement to not access services in this way I just want to test and isolate the issue if possible.
0 Kudos
DennisBaliton
Emerging Contributor
I created another "ArcGIS Project for Android" project, manually moved the source files, fixed errors, and hardcoded the URL in the addLayer call.
Same result.
0 Kudos
DennisBaliton
Emerging Contributor
It's finally working, there was a missing close bracket in the layout xml.

Thank you for everyone's help.
0 Kudos
DanO_Neill
Deactivated User
Fantastic!  Glad you got it sorted out.
0 Kudos
SaurabhGupta
Emerging Contributor
Glad to hear that.

But just to be clear, it worked by using an ArcGIS Android project + manually copying the src files.
And it fails if you use an Android project.
0 Kudos
DennisBaliton
Emerging Contributor
I tried many things to make it work, but creating an ArcGIS Android project + manually copying the src files did work.  Be mindful of the fact that methods have been
re-written/changed and that you will have to refactor your code.  We have a medium to large collection of source files so refactoring the source took time to complete.
In hindsight, maybe I should have taken notes and documented the process.
0 Kudos