Why does the Android system throw this Exception?
05-18 12:33:44.169 W/System.err( 8230): java.io.IOException: Is a directory
05-18 12:33:44.169 W/System.err( 8230): at org.apache.harmony.luni.platform.OSFileSystem.read(Native Method)
05-18 12:33:44.169 W/System.err( 8230): at dalvik.system.BlockGuard$WrappedFileSystem.read(BlockGuard.java:165)
05-18 12:33:44.169 W/System.err( 8230): at java.io.FileInputStream.read(FileInputStream.java:290)
05-18 12:33:44.169 W/System.err( 8230): at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:166)
05-18 12:33:44.169 W/System.err( 8230): at java.io.BufferedInputStream.read(BufferedInputStream.java:324)
05-18 12:33:44.169 W/System.err( 8230): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
05-18 12:33:44.169 W/System.err( 8230): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:573)
05-18 12:33:44.169 W/System.err( 8230): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:384)
05-18 12:33:44.169 W/System.err( 8230): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:412)
05-18 12:33:44.169 W/System.err( 8230): at dalvik.system.NativeStart.run(Native Method)
05-18 12:33:44.169 D/skia ( 8230): ---- read threw an exception
I am loading the images into memory like this:
return BitmapFactory.DecodeFile(fullPathToImage);
This is not causing failing problems, but it does cause unnecessary delays in the loading.
The image is stored on the Environment.ExternalStorageDirectory.AbsolutePath. The path is the full path including the image filename and extension. The image does load properly, so why does it do this?
I saw this SO: java.io.IOException: Is a directory Android, but this seems to be related to drawable resources, which I am not using.
I'd be curious to see if you still get the error if you wrapped your DecodeFile call in a check to see whether the file system thinks it's a directory:
File f = new File(fullPathToImage);
if (!f.IsDirectory)
{
return BitmapFactory.DecodeFile(fullPathToImage);
}
else
{
Console.WriteLine("This is a directory: " + fullPathToImage);
}
One other possibly useful thought. If you're dealing with very large images and you don't need them to be full resolution, you could possibly improve performance by reducing their size:
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.InSampleSize = 4; //Cut the image size to 1/4 the original
return BitmapFactory.DecodeFile(imgFile, opts);
Related
Cordova App breaks on Android lollipop, During app installation this is what i see in the logcat, though i am not sure if these are the actual cause of the error. (app installs/works fine on versions < 5.0)
using cordova v-5.1.1 & cordova-android#4.0.2
I/PersonaManagerService( 3485): PersonaId don't exist
I/ActivityManager( 3485): do not start freezing screen for locked container getKeyguardshowstate = false
E/Parcel ( 3485): Class not found when unmarshalling: com.android.packageinstaller.InstallFlowAnalytics
E/Parcel ( 3485): java.lang.ClassNotFoundException: com.android.packageinstaller.InstallFlowAnalytics
further downword in the logs i see this
D/ApplicationPolicy( 3485): isStatusBarNotificationAllowedAsUser: packageName = com.android.providers.downloads,userId = 0
V/ApplicationPolicy( 3485): isApplicationStateBlocked userId 0 pkgname com.android.providers.downloads
W/NotificationService( 3485): Pray mode not found android.content.pm.PackageManager$NameNotFoundException: Application package com.sec.android.settings.praymodewidget not found
I/PackageManager( 3485): do mInstaller.dexopt : 0
D/PackageManager( 3485): Time to dexopt: 1.389 seconds
W/System.err( 3485): java.io.FileNotFoundException: /data/app/com.TestApp.Test-1: open failed: EISDIR (Is a directory)
W/System.err( 3485): at libcore.io.IoBridge.open(IoBridge.java:456)
W/System.err( 3485): at java.io.FileInputStream.<init>(FileInputStream.java:76)
W/System.err( 3485): at android.content.pm.PackageParser.getHashValueOfPackage(PackageParser.java:5170)
W/System.err( 3485): at com.android.server.pm.PackageManagerService.saveHash(PackageManagerService.java:19974)
W/System.err( 3485): at com.android.server.pm.PackageManagerService.access$5800(PackageManagerService.java:352)
W/System.err( 3485): at com.android.server.pm.PackageManagerService$21.run(PackageManagerService.java:19959)
W/System.err( 3485): Caused by: android.system.ErrnoException: open failed: EISDIR (Is a directory)
W/System.err( 3485): at libcore.io.IoBridge.open(IoBridge.java:446)
W/System.err( 3485): ... 5 more
W/System.err( 3485): remove failed: ENOENT (No such file or directory) : /data/system/packages.xml.bak
W/System.err( 3485): remove failed: ENOENT (No such file or directory) : /data/system/users/0/package-restrictions.xml.bak
D/PackageManager( 3485): New package installed
Though the application then installs successfully but there are rendering issue's when i start the app.
In-case you need some other information on the error let me know.
I'm porting our application using QT to the Android platform. This is a kiosk-type application, the devices are rooted and we have full control over them. In order to modify some system settings (networking in particular), our app needs to be installed as a system app. To accomplish this, I use the following commands in an adb shell (after an adb remount):
1) pm install /data/my_app.apk
2) rm /data/my_app.apk
3) cp -p /data/app/com.me.my_app-1.apk /system/app
4) rm /data/app/com.me.my_app-1.apk
5) cp -p /data/app-lib/com.me.my_app-1/* /system/lib
6) rm -rf /data/app-lib/com.me.my_app-1
7) rm /data/data/com.me.my_app/lib
8) ln -s /system/lib /data/data/com.me.my_app/lib
9) reboot
After the reboot, when I launch the application I get a message box:
"Your application encountered a fatal error and cannot continue."
logcat shows the following exception and stack trace:
I/Qt ( 1272): qt start
D/dalvikvm( 1272): No JNI_OnLoad found in /system/lib/libmy_app.so 0x411f0a08, skipping init
W/System.err( 1272): java.lang.Exception: Can't find main library 'my_app'
W/System.err( 1272): at org.qtproject.qt5.android.QtNative.startApplication(QtNative.java:196)
W/System.err( 1272): at org.qtproject.qt5.android.QtActivityDelegate.startApplication(QtActivityDelegate.java:635)
W/System.err( 1272): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 1272): at java.lang.reflect.Method.invoke(Method.java:511)
W/System.err( 1272): at org.qtproject.qt5.android.bindings.QtActivity.loadApplication(QtActivity.java:252)
W/System.err( 1272): at org.qtproject.qt5.android.bindings.QtActivity.startApp(QtActivity.java:643)
W/System.err( 1272): at org.qtproject.qt5.android.bindings.QtActivity.onCreate(QtActivity.java:872)
W/System.err( 1272): at android.app.Activity.performCreate(Activity.java:5104)
W/System.err( 1272): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
W/System.err( 1272): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
W/System.err( 1272): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
W/System.err( 1272): at android.app.ActivityThread.access$600(ActivityThread.java:141)
W/System.err( 1272): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
W/System.err( 1272): at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 1272): at android.os.Looper.loop(Looper.java:137)
W/System.err( 1272): at android.app.ActivityThread.main(ActivityThread.java:5041)
W/System.err( 1272): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 1272): at java.lang.reflect.Method.invoke(Method.java:511)
W/System.err( 1272): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
W/System.err( 1272): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
W/System.err( 1272): at dalvik.system.NativeStart.main(Native Method)
W/System.err( 1272): java.lang.Exception:
W/System.err( 1272): at org.qtproject.qt5.android.bindings.QtActivity.loadApplication(QtActivity.java:253)
W/System.err( 1272): at org.qtproject.qt5.android.bindings.QtActivity.startApp(QtActivity.java:643)
W/System.err( 1272): at org.qtproject.qt5.android.bindings.QtActivity.onCreate(QtActivity.java:872)
W/System.err( 1272): at android.app.Activity.performCreate(Activity.java:5104)
W/System.err( 1272): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
W/System.err( 1272): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
W/System.err( 1272): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
W/System.err( 1272): at android.app.ActivityThread.access$600(ActivityThread.java:141)
W/System.err( 1272): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
W/System.err( 1272): at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 1272): at android.os.Looper.loop(Looper.java:137)
W/System.err( 1272): at android.app.ActivityThread.main(ActivityThread.java:5041)
W/System.err( 1272): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 1272): at java.lang.reflect.Method.invoke(Method.java:511)
W/System.err( 1272): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
W/System.err( 1272): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
W/System.err( 1272): at dalvik.system.NativeStart.main(Native Method)
libmy_app.so is located in /system/lib along with all the other QT libraries (libQt5AndroidExtras.so, libQt5Widgets.so, etc)
Googling for "Can't find main library" has led me to the QT source but that hasn't been helpful in tracking down why it can't find the library.
So any insight as to what's going on would be appreciated. Or if there a a better, totally different solution to running a QT app as a system app, I'm open to that too.
Thanks in advance!
UPDATE
After some more investigation, it appears the problem is because QTNative.startApplication() is using nativeLibraryPath to look for libmy_app.so. nativeLibraryPath is defined in /data/system/packages.xml:
<package name="com.me.my_app" codePath="/system/app/com.me.my_app-1.apk" nativeLibraryPath="/data/app-lib/com.me.my_app-1" flags="572999" ft="1471c4d74c0" it="1471c4d7c39" ut="1471c4d7c39" version="1" userId="10063">
but /data/app-lib/com.me.my_app-1 doesn't exist when my_app is a system app. My first though was it's because I removed it in step 6 after moving the libraries to the /system/lib folder. But even leaving that step out, after rebooting the device /data/app-lib/com.me.my_app-1 is gone. I guess some Android package management process cleaned it up. If I create a symlink from /data/app-lib/com.me.my_app-1 point to /system/lib after the reboot, my application runs.
So my question at this point is what is nativeLibraryPath in packages.xml used for? It appears that Android searches for libraries via /data/data/com.me.my_app/lib, which is a symlink to either /data/app-lib/com.me.my_app-1 or /system/lib depending if it's a user or system app. And I figured this out because if I don't move the Qt libraries to /system/lib and change the symlink (steps 5, 7 and 8) my application throws an exception even earlier because Android can't find the QT libraries.
But it appears QT is using the value of nativeLibraryPath from packages.xml to find my library. Is changing it to /system/lib the correct solution? Are there any other potential side effects? Or is this a misbehaviour on QT's part and it should use the same search path as the rest of Android?
I think the right solution is recreating the symlink from /data/app-lib/com.me.my_app-1 to /system/lib after the reboot. It's only removed on the first reboot after moving the app to the system folder and is stable from that point across reboots and app updates. So I'm going to mark this as the answer in case anyone else runs into the same problem. For reference, the process I ended up with to install a QT app as a system app from the adb shell is:
1) pm install /data/my_app.apk
2) rm /data/my_app.apk
3) cp -p /data/app/com.me.my_app-1.apk /system/app
4) rm /data/app/com.me.my_app-1.apk
5) cp -p /data/app-lib/com.me.my_app-1/* /system/lib
6) rm /data/data/com.me.my_app/lib
7) ln -s /system/lib /data/data/com.me.my_app/lib
8) reboot
Start the adb shell again and then:
9) ln -s /system/lib /data/app-lib/com.me.my_app-1
You can use this patchset as a temporary solution: https://codereview.qt-project.org/194507
All libraries from android-build/libs/ must be deployed at /system/lib folder on device (or firmware before it built)
I am new to android and I am trying to explore the AccessibilityService. I have extended the AccessibilityService class, which gets the AccessibilityEvents and I am able to use the events.
I see a problem when I run "uiautomator dump". My AccessibilityService gets destroyed and I do not get any Accessibility Events. Is there a way to work around this problem?
Any help or suggestion appreciated. Thank you very much in advance.
The stack trace is attached below:
W/System.err( 3832): at com.example.myservice.MyAccessibilityService.onUnbind(MyAccessibilityService.java:185)
W/System.err( 3832): at android.app.ActivityThread.handleUnbindService(ActivityThread.java:2629)
W/System.err( 3832): at android.app.ActivityThread.access$1800(ActivityThread.java:141)
W/System.err( 3832): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1348)
W/System.err( 3832): at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 3832): at android.os.Looper.loop(Looper.java:137)
W/System.err( 3832): at android.app.ActivityThread.main(ActivityThread.java:5103)
W/System.err( 3832): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 3832): at java.lang.reflect.Method.invoke(Method.java:525)
W/System.err( 3832): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
W/System.err( 3832): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
W/System.err( 3832): at dalvik.system.NativeStart.main(Native Method)
UiAutomator can't be used along with an AccessibilityService. When you turn on the service the uiAutomator will crash.
However, as UiAutomator 2.0 is based on instrumentation you will probably be able to access the information you need without the service.
I faced the same problem & just found out the solution from here.
The answer was written in Kotlin so I modified mine here as I am writing in Java:
int flags = UiAutomation.FLAG_DONT_SUPPRESS_ACCESSIBILITY_SERVICES;
Configurator.getInstance().setUiAutomationFlags(flags);
mDevice = UiDevice.getInstance(getInstrumentation());
Please try with uiautomator2 having version above 18 and make disable supress accessibility service flag as true, which ll run accessibility service as well as driver seamlessly without terminating.
You could switch to UiAutmator2 with following code from appium-uiautomator2-server:
private void setAccessibilityServiceState() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
return;
}
Configurator.getInstance().setUiAutomationFlags(
UiAutomation.FLAG_DONT_SUPPRESS_ACCESSIBILITY_SERVICES);
} else {
// We can disable UiAutomation.FLAG_DONT_SUPPRESS_ACCESSIBILITY_SERVICES
// only when we set the value as zero
Configurator.getInstance().setUiAutomationFlags(0);
}
}
I was getting this failure on a ICS device with latest Google Play Services when trying to call GoogleAuthUtil.getToken(args). The issue was resolved by removing and adding Google account to the phone. I wasn't able to reproduce the error. Google searching stack trace provided no insights. Any ideas on how this issue could be prevented and what it means are appreciated!
W/System.err( 3145): java.lang.SecurityException: Permission Denial: reading com.google.android.gsf.gservices.GservicesProvider uri content://com.google.android.gsf.gservices/prefix from pid=3145, uid=10055 requires com.google.android.providers.gsf.permission.READ_GSERVICES
W/System.err( 3145): at android.os.Parcel.readException(Parcel.java:1327)
W/System.err( 3145): at android.os.Parcel.readException(Parcel.java:1281)
W/System.err( 3145): at com.google.android.gms.internal.a$a$a.a(Unknown Source)
W/System.err( 3145): at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
W/System.err( 3145): at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
W/System.err( 3145): at com.xxxxx.Backend.obtainSheetKeyAndInitService(Backend.java:112)
W/System.err( 3145): at com.xxxxx.Backend.fetchColumns(Backend.java:103)
W/System.err( 3145): at com.xxxxx.ProgressActivity$DummySectionFragment$3.doInBackground(ProgressActivity.java:288)
W/System.err( 3145): at com.xxxxx.ProgressActivity$DummySectionFragment$3.doInBackground(ProgressActivity.java:1)
W/System.err( 3145): at android.os.AsyncTask$2.call(AsyncTask.java:264)
W/System.err( 3145): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
W/System.err( 3145): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
W/System.err( 3145): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
W/System.err( 3145): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
W/System.err( 3145): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
W/System.err( 3145): at java.lang.Thread.run(Thread.java:856)
EDIT
As of time of reporting the bug:
google_play_services-lib android:versionName="3.2.65 (834000-30)"
Google Play Services version on device 4.0.31
Updated library to 4.0.30 and added requested permission to Manifest which seems to have worked. Waiting for Google to confirm that new library version fixes this issue because adding a new permission is a highly undesirable fix.
Bug report: http://code.google.com/p/android/issues/detail?id=61934
You should add
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
to the AndroidManifest.xml file. Thats all.
Today 2013-11-14 there has been a large drop in the number of error reports we have received due to this exception. Also I see Google Play Services version 4.0.33 is out, I didn't notice exactly when that released but it looks like yesterday.
Perhaps Google released a fix in 4.0.33? That would be great!
If anyone has been able to reproduce this bug, please let us know if 4.0.33 fixes it for you. (We have never been able to reproduce the bug on a dev device, although we have have zillions of traces from our installed base.)
[UPDATE] Google has definitely pushed a fix, we had only a handful of reports on 11/15 and zero on 11/16
It must be some idiotic thing that I am doing but I could not get it what is the problem...
My code snippet
try {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet("http://somehost/WS2/Upload.aspx?one=valueGoesHere");
client.execute(request);//it fails at this line
} catch (Exception e) {
and in my manifest I have internet access permission
from console
W/System.err( 4210): java.net.UnknownHostException: somehost
W/System.err( 4210): at java.net.InetAddress.lookupHostByName(InetAddress.java:513)
W/System.err( 4210): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:278)
W/System.err( 4210): at java.net.InetAddress.getAllByName(InetAddress.java:242)
W/System.err( 4210): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
W/System.err( 4210): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
W/System.err( 4210): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
W/System.err( 4210): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
W/System.err( 4210): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
W/System.err( 4210): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
W/System.err( 4210): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
W/System.err( 4210): at com.temp.services.httpclient.HttpGetDemo.onCreate(HttpGetDemo.java:29)
W/System.err( 4210): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)
W/System.err( 4210): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
W/System.err( 4210): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
W/System.err( 4210): at android.app.ActivityThread.access$2300(ActivityThread.java:135)
W/System.err( 4210): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2136)
W/System.err( 4210): at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 4210): at android.os.Looper.loop(Looper.java:144)
W/System.err( 4210): at android.app.ActivityThread.main(ActivityThread.java:4937)
W/System.err( 4210): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 4210): at java.lang.reflect.Method.invoke(Method.java:521)
W/System.err( 4210): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
W/System.err( 4210): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
W/System.err( 4210): at dalvik.system.NativeStart.main(Native Method)
I/ActivityManager( 120): Displayed activity com.temp.services/.httpclient.HttpGetDemo: 119 ms (total 304 ms)
Try to add the following before your http request code
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Don't forget to declare the INTERNET permission in the Android manifest:
<uses-permission android:name="android.permission.INTERNET"/>
You should make sure your are not running on your main thread, check if you get this exception:
android.os.NetworkOnMainThreadException
ok, What about trying this :
URL uri = new URL(rootUri);
HttpURLConnection connection = (HttpURLConnection) uri.openConnection();
connection.setRequestMethod("GET");
connection.setDoInput(true);
connection.connect();
Do you execute this request in the emulator or on an android device ?
if it's on the emulator, maybe the internet connection is not shared with it.
If it's on an android device, seems you don't have internet access ( not the permission, just the access )
Assuming that the URL is a valid one, I suggest that you should call :
try {
InetAddress address = InetAddress.getByName(url);
} catch (UnknownHostException e) {
e.printStackTrace();
}
This is DNS pre-fetching so that your device can resolve it URl to an IP address.
Although this isn't enough for it to guarantee to work. What actually worked for me is a retrying mechanism. Give it some good old F5 F5 F5 F5 till the website responds :D
The Problem is with URL.As it shows in Log Exception is
java.net.UnknownHostException: somehost
Try with your true URL.
& BTW www.google.com works fine