android untrue resource not found exception - android

I am not a new developer to android. I have an application on the market. However, sometimes I get reported strange exceptions to have occured:
java.io.FileNotFoundException: res/drawable-mdpi/background.png
android.content.res.Resources$NotFoundException: File res/drawable-mdpi/background.png from drawable resource ID #0x7f02001f
This is by all means untrue because otherwise I wouldn;t have compiled or run the program myself. Also I am sure the resources are there. This is just one of the exception I have been reported. There are same exceptions for other resources mainly layouts.
So my question is how would this happen? Is it because the android system has failed installing correctly my app? I almost sure this must be the case because I have many users who use it without problem.
Please help regarding this.

There can be several possible reasons:
Moving application to SD card.
There was some problem in downloading or installing APK from market (file can be corrupted).
User get APK with corrupted file from other source (for example via bluetooth from other user)
Some system bug (from software, to brocken hardware)
Any way You can't do anything with this problem.

Could it be that the application was pushed to SD Card and something happens to the drawable while on SD. I saw similar issues with layouts rather drawable and it was because the application was pushed to SD.

Maybe you have included certain codes that reference content from Android SDK.
In my case, I faced similar issue and when I removed the line
android:background="?android:attr/actionBarItemBackground"
from my xml, everything works fine again.

Related

Android Skobbler Maps 2.4 SDK - Offline/Prebundled Maps Crashing

I have been using the older version of Skobbler maps for a fair while now, and have found it to be quite successful. I have recently began upgrading to version 2.4, to gain some of the extra functionality provided in this version ('via points' being the main feature I am interested in).
I can get the AndroidSDKDemo project running. I can get my own project running. But as soon as I add an offline package, the app crashes every time on start up, with a "Fatal Signal 11 0x00000004".
After I have added the offline maps package to the SKMaps.zip file, it does not matter if I set the connectivity mode to online or offline, the app still crashes, just based on the presence of the files in the preinstalled maps folder.
I downloaded the offline maps package via the AndroidSDKDemo project. I then used the android "adb backup -noapk" command to create a compressed version of the app's files, and extracted the SKMaps folder. I then moved the "v1" folder from "Maps" into "PreinstalledMaps", and zipped the file, and then added this file to my test application (the one that crashes) in the assets folder.
It also appears that the crashing may have something to do specifically with the SKMaps.zip... If I take the SKMaps.zip file from the demo project (unchanged, just downloaded straight off the web), and place it in my test app - the app works fine. If I take the SKMaps folder that was made in the backup (and therefore contains information in the "Maps" folder, and without moving ANYTHING in this file (not even moving anything to "/PreinstalledMaps"), and put this folder in my test project, the app crashes.
Does anyone have any ideas on how I can fix this problem? It's been hugely frustrating for me, as I can't really figure out why things aren't working. I may be doing something wrong, but I am lost as to what this might be.
Thanks in advance for your help
I have had a similar problem when loaded maps in sdk 2.3.
I solved it by executing this thread before initializing the Maps.
final SKPrepareMapTextureThread prepThread = new SKPrepareMapTextureThread(this, mapResourcesDirPath, zip, this);
prepThread.start();
When the method:
#Override
public void onMapTexturesPrepared(boolean arg0) {
}
"onMapTexturesPrepared" is called, you can initialize the Maps with preinstalled maps:
initMapSettings.setPreinstalledMapsPath(mapResourcesDirPath+"/PreinstalledMaps");
(....)
SKMaps.getInstance().initializeSKMaps(getApplicationContext(), initMapSettings, API_KEY);
I hope that helps, it worked for me.
Turns out I was being slightly stupid. I was compressing the SKMaps folder, instead of the files inside of the SKMaps folder. This means my zip looked like this:
SKMaps.zip/SKMaps/PreinstalledMaps/...
It needed to look like this:
SKMaps.zip/PreinstalledMaps/...
Simple solution, but it was not immediately apparent to me.
Apologies for the waste of time.
The structure from the SKMaps.zip has to be the same as in the demo, modifying or deleting any files might lead to some unexpected behavior in the worse case app crashes.
For using offline maps you first have to set the preinstalledMapsPath (In our AndroidSDKDemo DemoUtils method initializeLibrary uncomment initMapSettings.setPreinstalledMapsPath(app.getMapResourcesDirPath()
+ "/PreinstalledMaps"); ) and then there are 2 ways
Change the assets in the following way: Decompress SKMaps zip and add a .skm map for 2.4, in the folder PreinstalledMaps/v1/20141230/package/ Re-make the archive in assets<- this method unfortunately is not very reliable for big map packages
Another option would be to add packages manually. In our AndroidSDKDemo by default and if there is space the map resources are placed on the internal memory, but this can be changed in SplashActivity in the method chooseStoragePath so that the method returns just context.getExternalFilesDir(null).toString(). Use a file manager app (e.g.Astro File Manager) copy the files to [external storage]/Android/data/com.skobbler.sdkdemo/files/SKMaps/PreinstalledMaps/v1/20141230/package/

Android OpenCV Tutorial 3 Error Saving Image

I loaded up the OpenCV library and demos into Eclipse and was able to run them without issues. I have since taken the tutorial 3 code (capture image, etc.) and modified it slightly to instead save an image with the same name every time in a specific location, where after I proceed to run some other OpenCV functions on this. This was working until a few days ago when I accidentally deleted the folder where this image was stored on my phone. My code checked to make sure the folder existed and if not then it created it before the photo was to be taken. Now though, the image never saves and there is no specific error in the logcat as to why. I will get a logcat posted in a few hours as I don't currently have my laptop with me. If anyone has any idea why this would occur please let me know. Thank You.
It is likely that you created the folder with some user or access permissions that do not allow your Android application to write on that folder. You need to research more about Android file system permissions...
Also make sure your Android application is allowed to read/write to the filesystem:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
You will find dozens of posts here on SO and elsewhere addressing these issues.

Android jni lib not found when moving app to system app

I've been not able to solve my problem, I look around and I couldn't find a good solution.
The things is that I have an Android app that must be system app. I have my own devices so I'm able to install them on system app.
I'm doing this using a pre-installed app on system app. This app takes the .apk file from assets save it on the data/data and the move it to system/app/ folder.
Everything goes good, except when I launch it, it gets an exception java.lang.ExceptionInInitializerError, this means that the jni lib is not found. Probably because it has not been installed in the /system/lib directory.
Anyone know how can I solve this?
I know one solution is to look for the jni lib in the system and move it to system/lib but I would like to avoid this.
thank you.

Android SD card writing fails, but not consistently

I've got a pretty thorny problem with Android 2.3: I have an app that gathers various logs for debugging and support purposes (my company does Linux for rugged hardware), and has stopped working lately, because it's failing to write to the SD card. Here are the symptoms I've seen and the investigations I've carried out:
Happens across multiple devices of multiple types with different SD cards, all of which have been checked for filesystem corruption (no issues found).
All devices report: Environment.getExternalStorageState() equals Environment.MEDIA_MOUNTED.
All devices also report that Environment.getExternalStorageDirectory().getAbsolutePath().canWrite() is false.
Via PackageManager.checkPermission(), my app reports that it has the WRITE_EXTERNAL_STORAGE permission.
OI File Manager is able to create directories and move files on the SD card; my app can do neither.
This code is sufficient to cause a failure:
String sdcardDirectory = Environment.getExternalStorageDirectory().getAbsolutePath();
File directory = new File(sdcardDirectory + "/logger");
if(!directory.mkdirs()){
//fails here.
Log.w("Logger", "Could not create logger directory.");
}
Since I have access to the keys for this device, I even went so far as to sign the app with the platform key and run it as android.uid.system, with no luck. Anyone have any ideas?
It turns out this is a case partly of bad diagnosis on my part, and partly an apparent change in 2.1 to 2.3.
The bad diagnosis was that the directory above was indeed being created. The apparent change between 2.1 and 2.3 may be Android internally, or it may be the way we're setting up paths, PATH, and symbolic links in our own builds. Further down from the code in the original post, there are a few calls to exec() to get e.g. output from logcat and copies of various bits of useful information in /proc; using absolute paths to the commands fixed the problem.
Thanks for the help in ruling things out.

Android application uploaded using eclipse seems to still be taking up space even though I deleted it

I recently had to build an app which was pretty big (just under 180mb) mostly of stuff in the assets folder.
At one point I was running the application from eclipse and I got a strange error. I wish I recorded it but as far as I remember it was something along the lines of
Failed to launch application (null)
I was about to try install again when I realized the app had appeared on my phone. I ran it and everything was fine. Then I uninstalled it using adb uninstall.
I tried installing another app and it said I didn't have enough space. The available internal storage on my phone was around 250mb. Now it's 70mb. It looks like the previous application I ran is stuck somewhere in my phones internal storage even after I uninstalled. I had even set
android:installLocation="preferExternal"
The extra content doesn't seem to be accounted for anywhere. The application manager says my largest application is 12mb. Can't find anything strange in the DDMS file explorer.
Has anyone come across this kind of thing before? Is there some way of clearing out the internal storage? If I root my phone and go in to delete the file myself does anybody know where the file might be?
EDIT:
I did try the solution to 99% of problems - turning the phone off and on again.
Just in the event that this ever happens to another person, taking the battery out removed the unwanted data. I guess I should have thought of that sooner. So Blundells comment was mostly correct but didn't take in to account my pseudo-debility.

Categories

Resources