Google Maps works in debug not in apk - android

I added a map to a layout with a text view on top of it. In debug when I run the app on my phone the map comes up as expected. I pass my current longitude and latitude to the intent and the map centers on my location. The text view is visible and I can drop and pin and get the new coordinates.
I wanted to share the apk with someone so I first generated the file and emailed it to myself. After downloading and installing on my phone as a test I noticed the map no longer displays. There are no exceptions thrown. The text view is visible and the small 'Google' logo is in the bottom right, so the map there, but it is just a white screen. There is no map image. I tried to pinch thinking I am too zoomed in or out, but nothing changes.
Below is the layout of the activity. When I view it in design mode there is rendering problem. Part of the output from the rendering exception is below. the exception was 1025 lines long, which made it too long for a SO post. It was a lot of repeat, so i cut it down. I'm not sure if the two issues are related.
Is there anything wrong with my layout that would account for the problems? The phone shows that the app has the correct permissions for Location services.
I'm in Android Studio 1.4.0/ SDK 23
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapActivity" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
android:layout_height="match_parent" android:id="#+id/map" tools:context=".GarbageLocator"
android:name="com.google.android.gms.maps.SupportMapFragment"
tools:layout="#layout/activity_garbage_locator" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin">
<TextView
android:id="#+id/ItemName"
android:text="#string/hunt_item"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:textSize="32sp"/>
</RelativeLayout>
</FrameLayout>
java.lang.StackOverflowError
at java.security.AccessController.doPrivileged(Native Method)
at javax.xml.parsers.SecuritySupport.getSystemProperty(SecuritySupport.java:62)
at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:229)
at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:120)
at com.android.utils.XmlUtils.parseDocument(XmlUtils.java:432)
at com.android.utils.XmlUtils.parseDocumentSilently(XmlUtils.java:484)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.findCycles(LayoutlibCallbackImpl.java:397)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.getParser(LayoutlibCallbackImpl.java:315)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.getParser(LayoutlibCallbackImpl.java:306)
at android.content.res.BridgeResources.getLayout(BridgeResources.java:396)
at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:135)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:879)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:831)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:197)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:879)

Part of the mystery solved. The rendering problem is because when I clicked on the design tab AS asked me to choose which layout I wanted to display in the fragment, so I chose the layout for the activity. AS then added the line 'tools:layout="#layout/activity_garbage_locator"' to the layout, which I guess caused a sort of circular reference. Ugh!
Also, after adding the new API key the map no longer works in either Debug or Release. Consistency in failure is progress, I guess. I added a new activity with a Google map and ran it as-is, that is to say, without any additional code, and it won't display a map either. I get the same thing: an off-white screen with the Google logo in the bottom left. Just as I would get if there was a map, but no map.
In my original activity with code to trap the longitude and latitude of a dropped pin, the map actually does work in that it returns a new longitude and latitude when I tap on the screen. It just doesn't show the stupid map!
Greg

It was an API issue, but I'm not really sure what was going on. I tried several different things after reading several different posts regarding this problem. I think what fixed it was hard coding the API key in the manifest, as one post suggested.
Original manifest entry
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
Change to
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIz_MY_ACTUAL_KEY" />

Related

Android Google Maps V2: Only Loads after zooming

I just started programming my first Android app. However, even after thouroughfully following the Google Tutorial, including (!) getting a valid API key, the Google Maps doesn't load from the beginning (that means I can only see the grid).
The tiles are (weird?) only loaded after I use finger gestures (+- does not work) to adjust the zoom to a (random?) level. I don't have any idea on what could be the matter...once the first tile got loaded, the app works as expected.
I already worked through StackOverflow, the problem with everybody else was they were using MapView (V1).
I'm using
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/map"
tools:context=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
however...

Android Studio Google Map V2 fragment rendering

I tried to write a test demo for Google Map V2 in Android Studio. I followed every step from Androidhive Google Map V2 or better I think I need.
I'm using the same layout_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
but I'm getting always the same rendering problem:
Rendering Problems
A <fragment> tag allows a layout file to dynamically include different layouts at runtime. At layout editing time the specific layout to be used is not known. You can choose which layout you would like previewed while editing the layout...
I have absolutely no idea what's the problem. Did I forget something?
I just need to add Google services in the build.gradle like
compile 'com.google.android.gms:play-services:4.4.52'
I copied the manifest from the demo and changed the API Key.
The accepted answer is not wrong but it does not help.
As Dan wrote, Android Studio (also Version 1.0) will not display the map.
Maps needs an API key and dynamic processed code, maybe some day we will have that but so far not.
I've a 5 minute solution for those who want to see their app properly in layout preview:
To properly develop I still needed something else than a blank background.
I added overlays and buttons on top of the map, I really needed to see the map while placing elements over it.
The solution is simple:
1. Make a screenshot of your app with the map running (Power + Volume Down)
2. Download the screenshot and use an image editor to remove the top and bottom UI elements, so you will end up with only the map itself as an image.
3. Import that image into android studio drawables
4. create a new layout, name it dummy_mapviewfragment, put only a linearlayout and an imageview in
5. make the imageview "fill" the parent, and set "src" to the cropped image you just imported
6. back to your layout, add this into your Mapview Fragment xml :
tools:layout="#layout/dummy_mapviewfragment"/>
That's it, now you will have a non-interactive mapview fragment which displays a real map.
Your app will look like it looks on your mobile phone.
If you made errors in your image cropping you can "fix" it by setting the image scale to "centerCrop" so it will properly stretch out.
Update: You can get a screenshot without need to crop directly from within Androidstudio! Makes it a bit more convenient ;)
Rendering Problems
A tag <fragment> allows a layout file to dynamically include different layouts at runtime. At layout editing time the specific layout to be used is not known. You can choose which layout you would like previewed while editing the layout...
This is just the preview window telling you that it can't display a preview for the <Fragment.../> tag, because it doesn't know what kind of fragment you're going to put in it. You can safely ignore that message - your actual app will render the fragment fine when you run it (as long as you code it up correctly!).
Android Studio automatically offers a solution within the error description, which is adding the name of the fragment layout.
tools:layout="#layout/fragment_my"
Add a dummy layout "#android:layout/simple_gallery_item" as:
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="317dp"
android:layout_height="385dp"
android:id="#+id/map"
tools:context="com.example.XYZ.googlemaps.MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment"
tools:layout="#android:layout/simple_gallery_item"/>

Android Studio: xmlns:map not working

After doing a lot of research, and not finding anything... quick question, does anybody has an idea why Android Studio is not taking the Map tag? The code below is a fragment of the maps sample in the SDK. Already added google play services lib and support, but nothing.
It's showing the error
Unexpected namespace prefix "map" found for tag fragment.
Thanks a lot in advance!
<fragment
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
map:cameraZoom="10" />
I had the same problem once I've been moving the map fragment into FrameLayout (so I could add a button on top of the map).
I don't know what I've really done as I'm a noob in Android apps and XML, but it looks that I found the solution :-)
I tried to make the trick including the fragment from a separate file (using 'include' directive) and once I put the bare map fragment without any namespace definitions it proposed me 2 options:
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:map="http://schemas.android.com/tools"
I realized that maybe the 2nd one will work in the original file (although in original file Android Studio is not proposing it, but only the 1st one instead).
Conclusion:
Just change this line:
xmlns:map="http://schemas.android.com/apk/res-auto"
with this:
xmlns:map="http://schemas.android.com/tools"
AS I MENTIONED - I'M A NOOB AND MAYBE MY SOLUTION GOT SOME SIDE EFFECTS SO PLEASE LET ME KNOW IF SO (although everything seemed to be working fine by so far...).
That's my working map layout with a button on the top and no errors:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/tools"
tools:context="com.maverickrider.myapp.inviteActivity.MapsActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/purpura_E51B4A">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
map:cameraTargetLat="51.513259"
map:cameraTargetLng="-0.129147"
map:cameraTilt="30"
map:cameraZoom="13"
/>
<Button
android:id="#+id/startActivityButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:onClick="cokolwiek"
android:text="Baton z dupy"
android:layout_alignParentBottom="true"
/>
</FrameLayout >
I had this problem as well. I did Project/Clean and the error went away and it works fine now. This assumes that the map namespace is properly defined above where it's being used.
I'm running 0.5.8 and the XML viewer is underlining the attrs with map: - however the app is building fine. YMMMV.

Android Google Maps fragment in the xml. I get "Unexpected namespace prefix"

I'm trying to learn android, and having followed the instructions on how to use the Google Maps API V.2 I now got it working.
However, the instructions on how to configure the initial state of the maps, found at developers.google.com, suggests a namespace defined in the xml-file, in this case "map".
The xml-code below gives med the error "Unexpected namespace prefix "map"". Trying to define the xmlns:map inside the fragment tag gave the same error but with "xmlns".
I'm obviously missing some fundamental xml-knowledge here, can someone help me out?
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto" <!-- Definition -->
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
map:cameraBearing="112.5"/> <!-- PROBLEM -->
</RelativeLayout>
I had this problem as well. I did Project/Clean and the error went away and it works fine now.
You have to do two things:
First:
https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw
Add the dependency to Google Play Services into your project
Project -> Properties -> Android -> Library, Add -> google-play-services_lib
Second:
https://developers.google.com/maps/documentation/android/intro
Select Project > Properties, select Java Build Path, and navigate to Libraries.
Select Add External Jars, include the following jar files, and click OK:
<android-sdk-folder>/extras/android/compatibility/v4/android-support-v4.jar
Now my project shows no errors anymore :)
I have the same problem today. I upgraded the SDK last night and did not see this problem before. I had the Android Map V2 sample demo project loaded too and today the "multimap_demo.xml" file is showing the "Unexpected namespace prefix "map" found for tag fragment" error. I applied the xml include suggested and it is working again. Would give it a +1 but got no cred.
UPDATE:
I forgot about this problem and reworked my code today and removed the include. Of course the error came back. I found this and added it to the layout in the fragment stanza:
tools:ignore="MissingPrefix"
It seems to at least mask the problem.
Update: This bug apparently happens due to a bug in Android Lint Tool. Refer issue https://code.google.com/p/gmaps-api-issues/issues/detail?id=5002
There is another workaround that lets you continue to set everything up in layout files instead of in the Java code. Since the error only seems to happen when the SupportMapFragment is a child of a ViewGroup in the layout file, one can extract the <fragment> element into its own layout file and then just include it in the desired larger layout.
For example, given that you are trying to do this:
my_awesome_layout.xml
...
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
map:cameraBearing="112.5"/>
</RelativeLayout>
You could instead break it up like so:
include_map_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://scheams.android.com/apk/res-auto"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
map:cameraBearing="112.5"/>
my_awesome_layout.xml
...
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="#layout/include_map_fragment" />
</RelativeLayout>
Well, I know, this isn't really a solution for the name space problem, maybe this might help.
Since I don't know any XML solution, I did it programmatically:
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.setTrafficEnabled(true);
setupMapView();
private void setupMapView(){
UiSettings settings = mMap.getUiSettings();
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(
new CameraPosition(new LatLng(50.0, 10.5),
13.5f, 30f, 112.5f))); // zoom, tilt, bearing
mMap.setTrafficEnabled(true);
settings.setAllGesturesEnabled(true);
settings.setCompassEnabled(true);
settings.setMyLocationButtonEnabled(true);
settings.setRotateGesturesEnabled(true);
settings.setScrollGesturesEnabled(true);
settings.setTiltGesturesEnabled(true);
settings.setZoomControlsEnabled(true);
settings.setZoomGesturesEnabled(true);
}
So the Google Map is initialized default but gets its parameters directly after that from the code.
I've got exactly the same problem. The provided example
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
map:cameraBearing="112.5"
map:cameraTargetLat="-33.796923"
map:cameraTargetLng="150.922433"
map:cameraTilt="30"
map:cameraZoom="13"
map:mapType="normal"
map:uiCompass="false"
map:uiRotateGestures="true"
map:uiScrollGestures="false"
map:uiTiltGestures="true"
map:uiZoomControls="false"
map:uiZoomGestures="true"/>
works fine, but if you try to add it into a parent element it refuses to accept the xmlns. If you move the xmlns declaration to the top element it still refuses to accept the map prefix in the fragment:
Unexpected namespace prefix "map" found for tag fragment
Now if you extend SupportMapFragment and use a custom view such as this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
<com.google.android.gms.maps.MapView
android:id="#+id/map_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraBearing="0"
map:cameraTargetLat="54.25"
map:cameraTargetLng="-4.56"
map:cameraTilt="30"
map:cameraZoom="5.6"
map:mapType="normal"
map:uiCompass="true"
map:uiRotateGestures="true"
map:uiScrollGestures="true"
map:uiTiltGestures="true"
map:uiZoomControls="false"
map:uiZoomGestures="true">
</com.google.android.gms.maps.MapView>
</LinearLayout>
...then it doesn't complain and the resultant map is correct. For me that raises further problems however as there are no decent examples of how to do this subclassing, you have to do more than override onCreateView and when I try to do anything to the map subsequently I get the following:
java.lang.IllegalStateException: Map size should not be 0. Most likely, layout has not yet occured for the map view.
...even if I wait 30 seconds after the map has appeared.(only first loading)
I don't think you can put XML comments inside a tag like you are doing with <!-- Definition -->. If you remove that does the problem still occur?
Obviously this is just a mis-lead Lint check error. You can remove it when, in Eclipse's Problem view, you right-click the line with the error, select the Quick fix option and select e.g. Ignore Check for project.
The error goes away, the project builds and the app runs perfectly well.
In my case a big miss, I forget to add in the gradle file my google map dependency:
compile 'com.google.android.gms:play-services-maps:11.2.0'

Missing or Incorrect images and backgrounds randomly throughout app lifecycle

I was hoping someone here might have an idea what causes this sort of behaviour:
Throughout my application, in seemingly random places and in random conditions I'm observing this strange UI issue. Images are on occasion being loaded black (with the correct bounds) or with the incorrect image source (again, with the correct bounds). This effects ImageViews and has effected android:background tags with references to colour resources.
My application relies on 6 library projects, it runs Native Code via a Service and Activities in the App use GlSurfaceViews (although, not all Activities which display the problem contain OpenGL components). The problem could I suppose be from any of these places or a combination of them through using large amounts of memory.
You can see this behaviour in the following screen shots:
This is actually a 6 or so pixel wide column separator image which has been incorrectly drawn into my ImageView (the ImageView seems to have correctly sized itself).
When going out of the Application and then back in again (repeatedly) it instead appeared (and remained) like so:
After a Force Clear and a Clear App Data it returned to the correct format:
As you can also see the Magnifying Glass image next to it is displaying fine in each of these. The problems with these missing/incorrect images and backgrounds seems to happen randomly, throughout the application lifecycle, and I've been unable to find a way of reproducing it.
The layouts for these images are nothing special, I'm not doing anything funny during the rendering lifecycle (i'm not overriding onDraw() or onMeasure() or the like). The source of these images aren't being set dynamically but via the XML.
As you can see from the above example, it's not a build issue as it occurs between app lifecycles not between installs. It's also happening on different devices, Samsung 8.9, Acer Iconia Tab, Motarola XOOM,
It seems to me to be some sort of error with the reference table, could it perhaps have been nudged by my native code? Or is it an effect of me in some stages of the application using too much memory?
Here's the XML source for the above example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/browseProgressWrapper"
android:layout_width="match_parent"
android:layout_height="#dimen/actionbar_compat_height"
android:orientation="horizontal">
<RelativeLayout android:layout_width="#dimen/search_bar_width"
android:layout_height="match_parent">
<EditText android:id="#+id/browseFilter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="4dp"
android:layout_marginLeft="5dp"
android:imeOptions="actionSearch"
android:background="#drawable/edit_text_blue"
android:maxLength="30"/>
<ImageView android:id="#+id/clearSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_input_delete"
android:layout_marginRight="5dp"/>
</RelativeLayout>
<ImageView android:id="#+id/browseFilterButton"
android:src="#drawable/ic_menu_search"
android:scaleType="center"
android:layout_width="#dimen/actionbar_compat_height"
android:layout_height="#dimen/actionbar_compat_height"
android:layout_gravity="center_vertical"
android:minWidth="#dimen/actionbar_compat_height"/>
</LinearLayout>
A more full description of the code / layout surrounding another such occurrence I happened to get the screenshot for:
I have a "Settings" Activity which restarts my app after saving new settings details. It does this by stopping a Service, calling a new Activity (the Splash Activity) and finishing itself:
mConfiguration.save();
mConfiguration = new Configuration(Configuration.getInstance());
getActivity().stopService(new Intent(getActivity(), NativeService.class));
getActivity().finish();
startActivity(new Intent(getActivity(), SplashActivity.class));
Most of the time (and on most devices) this works fine, the Splash Activity contains an image which loads correctly. Sometimes though on some devices the Splash Activity loads either an incorrect resource (what my testers refer as "an upside down Nike tick") or just a blank box (as seen below). Does anyone know why?
Here is the Layout for the Splash page, as you can see it's pretty simple, no surprises:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/ContentBackgroundColor"
android:orientation="vertical" >
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="2" />
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/manager_android_400" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<ProgressBar
style="#android:style/Widget.ProgressBar.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="2" />
</LinearLayout>
Theory tested and debunct:
I've theorised that this could be a processor/memory issue where the Layout isn't being drawn fully before the Splash screen exits and moves onto the next Activity so I put in this piece of code:
image = (ImageView) findViewById(R.id.image);
image.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
#Override
public void onGlobalLayout() {
image.getViewTreeObserver().removeGlobalOnLayoutListener(this);
moveToStartScreen.start();
}
});
The hope was the code above would make sure the Image is definitely loaded before moving onto the Start page but seems to have had no observable effect.
Another Theory
I was also wondering if this could be being caused by the R.id / R.colour / R.drawable resources some how being currupted in program execution? Does anyone know why that might happen.
Could my native code be running rampant on some memory addresses that Android isn't correctly allocating?
Has anybody noticed this before - or perhaps know why this behaviour occurs?
Graeme, I had almost the same problem and found out that it was a reported bug of the android plattform. It was corrected in the 3.0 version I think. Which API are you compiling with? Try to build with the last available api and be sure to compile with JDK 1.6
If your problem is related to this bug, this should fix the problem.
This is a simple problem of refresh, clean, and rebuild.
Images in your various drawable folders or resource id indices are out of sequence because they were either changed outside of the eclipse IDE (via external source control such as GIT, SVN or other edits) and not refreshed in the eclipse navigator. Or, the files may have been updated in a library project upon which your UI Activity depends.
I have found that although .java file dependencies are propagated throughout the system, this is not always the case for resources such as images and .xml files.
The solution is fairly simple, clean everything, refresh all of your projects, and rebuild. The stretched or black edges should be gone.
Note: The predominant manifestation of this problem occurs when 9-patch images become treated like standard .png images. This means that they get stretched in a linear manner across the image instead of just at the edges. To me, this explains your 'Torn/Stretched' example. I have seen similar often. Another common manifestation is that text strings occasionally get displayed with the wrong resources!

Categories

Resources