jcodec Permission Denied for NIOUtils.readableFileChannel - android

I'm trying to use JCodec to get all the frames from an MP4 on my emulator. I have the following permissions in my manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
The file through my adb shell looks like this:
root#generic_x86_64:/sdcard/Download # pwd
/sdcard/Download
root#generic_x86_64:/sdcard/Download # ls -la
-rwxrwx--x root sdcard_rw 19967250 2015-10-12 16:39 Hummingbird.MP4
I've tried doing a chmod 777 Hummingbird.MP4, but that doesn't change the last set of permissions for some reason?
The following code produces the exception below.
String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
String fn = baseDir + "/Download/Hummingbird.MP4";
// test dir to make sure I'm in right place
String dir = baseDir + "/Download";
File fDir = new File(dir);
Log.i("TAG", "fDir.isDir()=" + fDir.isDirectory()); // this is true
fileMp4 = new File(fn);
try {
ch = NIOUtils.readableFileChannel(fileMp4); // line 220 in trace below
} catch (FileNotFoundException e) {
e.printStackTrace();
}
I also did a fileMp4.exists() which returns true.
Exception
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: java.io.FileNotFoundException: /storage/1F1A-300C/Download/Hummingbird.MP4: open failed: EACCES (Permission denied)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at libcore.io.IoBridge.open(IoBridge.java:452)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at java.io.FileInputStream.<init>(FileInputStream.java:76)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at org.jcodec.common.NIOUtils.readableFileChannel(NIOUtils.java:336)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at medloh.com.mp4frames.MainActivity.onActivityResult(MainActivity.java:220)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at android.app.Activity.dispatchActivityResult(Activity.java:6428)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at android.app.ActivityThread.deliverResults(ActivityThread.java:3695)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at android.app.ActivityThread.-wrap16(ActivityThread.java)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at android.os.Looper.loop(Looper.java:148)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at java.lang.reflect.Method.invoke(Native Method)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at libcore.io.Posix.open(Native Method)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: at libcore.io.IoBridge.open(IoBridge.java:438)
10-14 23:32:27.090 4595-4595/medloh.com.mp4frames W/System.err: ... 14 more
See any problems with this code/configuration?

I was able to get the 'NIOUtils.readableFileChannel(fileMp4)' statment working by creating the file at /data/tmp/Hummingbird.MP4 (adb push). Not sure if it's something about /sdcard and its symbolic links, or maybe I just needed to make sure all the directories and file were owned by system instead of root.
Anyway, I'm now on to other issues and problems decoding the MP4 but that's another story.

Related

can't load images from url with Picasso

i'm using Picasso to download images into a listview in my android app.
it's working like a charm except when running on Kitkat environment.
My layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<ImageView
android:id="#+id/articleimage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="5dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:layout_alignParentTop="true"
/>
</RelativeLayout>
My logs
08-11 06:30:19.406 28898-28898/com.s W/System.err: com.squareup.picasso.Downloader$ResponseException: 404 Not Found
08-11 06:30:19.406 28898-28898/com.s W/System.err: at com.squareup.picasso.UrlConnectionDownloader.load(UrlConnectionDownloader.java:96)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at com.squareup.picasso.NetworkRequestHandler.load(NetworkRequestHandler.java:47)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:206)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:159)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at java.lang.Thread.run(Thread.java:841)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:411)
my config
compileSdkVersion 23
buildToolsVersion '23.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
using ImageLoader i get an error in downloading the images
http://url/uploads/Vous-ĂȘtes-cerveau-droit-ou-cerveau-gauche-300x160.jpg
08-15 10:05:09.042 1915-2474/com.s W/System.err: java.io.FileNotFoundException: http://url/uploads/Vous-ĂȘtes-cerveau-droit-ou-cerveau-gauche-300x160.jpg
08-15 10:05:09.042 1915-2474/com.s W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:186)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at java.net.URL.openStream(URL.java:470)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at com.s.ArticleActivity$DownloadImageTask.doInBackground(ArticleActivity.java:446)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at com.s.ArticleActivity$DownloadImageTask.doInBackground(ArticleActivity.java:436)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at java.lang.Thread.run(Thread.java:841)

File cant be created on Asus Nexus 7

i am developing on Asus nexus 7, and i am writing data to file on the internal storage. at run time i receive the below posted logcat output which casese the App
to terminate.
the same App tested against Samsung galaxx note 3 and it worked fine without crashing
i want to know how to fix these error when tesing against Asus nexux 7 and why that is happening.
Note: the required permission for writing on the external storage is added
please let me know what i am missing in the code
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
logcat:
: +++++ isExternalStorageMounted() +++++
11-26 15:53:51.329 24003-24003/com.example.com.bt_11 D/IOCtrl: isExternalStorageMounted(): -> media state: mounted
11-26 15:53:51.330 24003-24003/com.example.com.bt_11 D/IOCtrl: dir: /storage/emulated/0/CAN_BUS already exists
11-26 15:53:51.330 24003-24003/com.example.com.bt_11 D/IOCtrl: file: Test_00.txt will be created
11-26 15:53:51.330 24003-24003/com.example.com.bt_11 W/System.err: java.io.IOException: open failed: EACCES (Permission denied)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at java.io.File.createNewFile(File.java:939)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at com.example.com.bt_11.IOCtrl.createFile(IOCtrl.java:87)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at com.example.com.bt_11.ActConnect2$ATRx.onPreExecute(ActConnect2.java:844)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:604)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at com.example.com.bt_11.ActConnect2$ATConnect.onPostExecute(ActConnect2.java:702)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at com.example.com.bt_11.ActConnect2$ATConnect.onPostExecute(ActConnect2.java:574)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at android.os.AsyncTask.finish(AsyncTask.java:651)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at android.os.AsyncTask.-wrap1(AsyncTask.java)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at android.os.Looper.loop(Looper.java:148)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at java.lang.reflect.Method.invoke(Native Method)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
11-26 15:53:51.331 24003-24003/com.example.com.bt_11 W/System.err: at libcore.io.Posix.open(Native Method)
11-26 15:53:51.332 24003-24003/com.example.com.bt_11 W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
11-26 15:53:51.332 24003-24003/com.example.com.bt_11 W/System.err: at java.io.File.createNewFile(File.java:932)
11-26 15:53:51.332 24003-24003/com.example.com.bt_11 W/System.err: ... 14 more
11-26 15:53:51.332 24003-24003/com.example.com.bt_11 E/IOCtrl: <<createFile>>: Error creating file: open failed: EACCES (Permission denied)

Writing to SD Card always failing

I am trying to move files from any location (including internal device storage)
to SD Card,
For that I Have
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
in my manifest, and checked that it did work by checking if premissions are granted using :
Contex.checkCallingOrSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") and Contex.checkCallingOrSelfPermission("android.permission.READ_EXTERNAL_STORAGE")
and I have tried 3 diffrent ways to do that :
Files.move(original, newPath1), which comes with Guava com.google.common.io
this method :
public static void move(File src, File dst) throws IOException {
FileInputStream inStream = new FileInputStream(src);
FileOutputStream outStream = new FileOutputStream(dst);
FileChannel inChannel = inStream.getChannel();
FileChannel outChannel = outStream.getChannel();
inChannel.transferTo(0, inChannel.size(), outChannel);
inStream.close();
outStream.close();
}
original.renameTo(newPath1);
I read alot of SO posts about this, and all solutions i tried did not work, I made sure the SD Card is mounted, and that i didnt have my device connected to PC while trying. I even tried 2 diffrent devices with SD Cards. Notice that i could access the image with BitmapFactory.decode() with the exact same path and i could load that image to imageview.
I am always getting EACCES (Permission denied). I dont know what else to do to solve this :(
11-13 11:11:54.358 19192-19372/xaday.ofek.ron.xaday W/System.err: java.io.FileNotFoundException: /storage/sdcard1/DCIM/thai2/IMG-20150702-WA0001.jpg: open failed: EACCES (Permission denied)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.IoBridge.open(IoBridge.java:465)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at com.google.common.io.Files$FileByteSink.openStream(Files.java:245)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at com.google.common.io.Files$FileByteSink.openStream(Files.java:233)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at com.google.common.io.ByteSource.copyTo(ByteSource.java:248)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at com.google.common.io.Files.copy(Files.java:458)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at com.google.common.io.Files.move(Files.java:673)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at xaday.ofek.ron.xaday.XaDayIntentService.handleActionMove(XaDayIntentService.java:128)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at xaday.ofek.ron.xaday.XaDayIntentService.onHandleIntent(XaDayIntentService.java:84)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.os.Looper.loop(Looper.java:211)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.os.HandlerThread.run(HandlerThread.java:61)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.Posix.open(Native Method)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.IoBridge.open(IoBridge.java:451)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: ... 12 more
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: java.io.FileNotFoundException: /storage/sdcard1/DCIM/thai2/IMG-20150702-WA0001.jpg: open failed: EACCES (Permission denied)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.IoBridge.open(IoBridge.java:465)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:72)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at xaday.ofek.ron.xaday.FileUtils.move(FileUtils.java:36)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at xaday.ofek.ron.xaday.XaDayIntentService.handleActionMove(XaDayIntentService.java:136)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at xaday.ofek.ron.xaday.XaDayIntentService.onHandleIntent(XaDayIntentService.java:84)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.os.Looper.loop(Looper.java:211)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.os.HandlerThread.run(HandlerThread.java:61)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.Posix.open(Native Method)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.IoBridge.open(IoBridge.java:451)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: ... 9 more
Just to make sure I was not locking the file in some way, I used another file manager app to execute the same file move - and it worked! why is it not working for me?!
anyone has an idea?
On Android Kitkat (4.4), Google has changed how the developers can access to the removable storage (SD card). Quoting from source.android.com:
The WRITE_EXTERNAL_STORAGE permission must only grant write access to
the primary external storage on a device. Apps must not be allowed to
write to secondary external storage devices, except in their
package-specific directories as allowed by synthesized permissions.
Restricting writes in this way ensures the system can clean up files
when applications are uninstalled.
For this reason, even with the WRITE_EXTERNAL_STORAGE permission, you can't write on the SD card on KitKat and higher versions.
On Android Lollipop (5.0), Google adds a new set of API that allows the developers to manage the file on the SD Card through the Storage Access Framework.
This StackOverflow answer explains in detail how to use the new APIs and the existing limitations:
How to use the new SD card access API presented for Android 5.0 (Lollipop)?
Is the "uses-permission" tag outside of the "application" tag in the manifest.xml?

Android open failed: EACCES (Permission denied) in implementing PDF Reader library

I am implementing this library for PDF reader. I've implemented the code as explained in the link. but when I am running I am getting following exception. here's the logcat:
10:43:56.429 32577-32577/com.example.fahad.testpdfreaderlibrary I/PDFVIEWER: Intent { cmp=com.example.fahad.testpdfreaderlibrary/.TestPDFActivity (has extras) }
11-05 10:43:56.431 32577-32577/com.example.fahad.testpdfreaderlibrary I/PDFVIEWER: ST='file '/storage/emulated/0/pdf.pdf' has 433994 bytes'
11-05 10:43:56.432 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: java.io.FileNotFoundException: /storage/emulated/0/pdf.pdf: open failed: EACCES (Permission denied)
11-05 10:43:56.432 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at libcore.io.IoBridge.open(IoBridge.java:452)
11-05 10:43:56.432 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at java.io.RandomAccessFile.<init>(RandomAccessFile.java:117)
11-05 10:43:56.432 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at net.sf.andpdf.pdfviewer.PdfViewerActivity.openFile(PdfViewerActivity.java:841)
11-05 10:43:56.432 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at net.sf.andpdf.pdfviewer.PdfViewerActivity.parsePDF(PdfViewerActivity.java:815)
11-05 10:43:56.432 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at net.sf.andpdf.pdfviewer.PdfViewerActivity.setContent(PdfViewerActivity.java:221)
11-05 10:43:56.432 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at net.sf.andpdf.pdfviewer.PdfViewerActivity.onCreate(PdfViewerActivity.java:212)
11-05 10:43:56.433 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at android.app.Activity.performCreate(Activity.java:6237)
11-05 10:43:56.433 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
11-05 10:43:56.433 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
11-05 10:43:56.433 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
11-05 10:43:56.433 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at android.app.ActivityThread.-wrap11(ActivityThread.java)
11-05 10:43:56.433 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
11-05 10:43:56.433 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
11-05 10:43:56.433 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at android.os.Looper.loop(Looper.java:148)
11-05 10:43:56.433 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
11-05 10:43:56.434 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at java.lang.reflect.Method.invoke(Native Method)
11-05 10:43:56.434 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-05 10:43:56.434 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-05 10:43:56.434 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
11-05 10:43:56.434 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at libcore.io.Posix.open(Native Method)
11-05 10:43:56.434 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
11-05 10:43:56.434 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: at libcore.io.IoBridge.open(IoBridge.java:438)
11-05 10:43:56.434 32577-32577/com.example.fahad.testpdfreaderlibrary W/System.err: ... 17 more
also I've added in my AndroidManifest.xml following lines:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
but still getting the same exception
Simple solution: set your target SDK back to 22
Clean Solution: Request the Runtime Permissions
Check this out for more informations.

jGit fetch error: cannot open git-upload-pack

So I'm working with legacy code in an app I'm fixing up. The code uses jGit to pull a repo on startup. During the fetch call, I'm passing in the URL which is something like:
https://thisone#git.hungry.androider.com/myrepo.git
Problem is, when I make the fetch call, I get an error saying:
cannot open git-upload-pack
I noticed a few SO answers say to use a ProxySelector, but I noticed that in the ProxySelector, the select(Uri) call is being passed the following URI:
https://thisone#git.hungry.androider.com/myrepo.git/info/refs?service=git-upload-pack
My question is, where and why is
/info/refs?service=git-upload-pack
being added to my url/uri?
And how can I overcome this error?
Below is the full stack trace:
10-14 10:45:28.469 25237-25462/com.atimi.sportsapp W/System.err: org.eclipse.jgit.api.errors.TransportException: https://fugutest#git.sports.atimi.com/ahl-hershey-bears-qa.git: cannot open git-upload-pack
10-14 10:45:28.481 25237-25462/com.atimi.sportsapp W/System.err: at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:139)
10-14 10:45:28.492 25237-25462/com.atimi.sportsapp W/System.err: at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:261)
10-14 10:45:28.504 25237-25462/com.atimi.sportsapp W/System.err: at com.atimi.caviar.CaviarGitRepo$UpdateRunnable.update(CaviarGitRepo.java:577)
10-14 10:45:28.515 25237-25462/com.atimi.sportsapp W/System.err: at com.atimi.caviar.CaviarGitRepo$UpdateRunnable.run(CaviarGitRepo.java:441)
10-14 10:45:28.526 25237-25462/com.atimi.sportsapp W/System.err: at java.lang.Thread.run(Thread.java:818)
10-14 10:45:28.541 25237-25462/com.atimi.sportsapp W/System.err: Caused by: org.eclipse.jgit.errors.TransportException: https://fugutest#git.sports.atimi.com/ahl-hershey-bears-qa.git: cannot open git-upload-pack
10-14 10:45:28.562 25237-25462/com.atimi.sportsapp W/System.err: at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:524)
10-14 10:45:28.571 25237-25462/com.atimi.sportsapp W/System.err: at org.eclipse.jgit.transport.TransportHttp.openFetch(TransportHttp.java:309)
10-14 10:45:28.580 25237-25462/com.atimi.sportsapp W/System.err: at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136)
10-14 10:45:28.589 25237-25462/com.atimi.sportsapp W/System.err: at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122)
10-14 10:45:28.597 25237-25462/com.atimi.sportsapp W/System.err: at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1138)
10-14 10:45:28.606 25237-25462/com.atimi.sportsapp W/System.err: at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:130)
10-14 10:45:28.611 25237-25462/com.atimi.sportsapp W/System.err: ... 4 more
10-14 10:45:28.625 25237-25462/com.atimi.sportsapp W/System.err: Caused by: java.net.UnknownHostException: Unable to resolve host "/ahl-hershey-bears-qa.git/info/refs": No address associated with hostname
10-14 10:45:28.659 25237-25462/com.atimi.sportsapp W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:457)
10-14 10:45:28.668 25237-25462/com.atimi.sportsapp W/System.err: at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
10-14 10:45:28.677 25237-25462/com.atimi.sportsapp W/System.err: at java.net.InetAddress.getAllByName(InetAddress.java:215)
10-14 10:45:28.686 25237-25462/com.atimi.sportsapp W/System.err: at com.android.okhttp.HostResolver$1.getAllByName(HostResolver.java:29)
10-14 10:45:28.697 25237-25462/com.atimi.sportsapp W/System.err: at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:232)
10-14 10:45:28.706 25237-25462/com.atimi.sportsapp W/System.err: at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:124)
10-14 10:45:28.715 25237-25462/com.atimi.sportsapp W/System.err: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:272)
10-14 10:45:28.724 25237-25462/com.atimi.sportsapp W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211)
10-14 10:45:28.735 25237-25462/com.atimi.sportsapp W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:382)
10-14 10:45:28.746 25237-25462/com.atimi.sportsapp W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:332)
10-14 10:45:28.757 25237-25462/com.atimi.sportsapp W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:500)
10-14 10:45:28.769 25237-25462/com.atimi.sportsapp W/System.err: at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
10-14 10:45:28.780 25237-25462/com.atimi.sportsapp W/System.err: at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
10-14 10:45:28.790 25237-25462/com.atimi.sportsapp W/System.err: at org.eclipse.jgit.transport.http.JDKHttpConnection.getResponseCode(JDKHttpConnection.java:98)
10-14 10:45:28.799 25237-25462/com.atimi.sportsapp W/System.err: at org.eclipse.jgit.util.HttpSupport.response(HttpSupport.java:168)
10-14 10:45:28.808 25237-25462/com.atimi.sportsapp W/System.err: at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:475)
10-14 10:45:28.813 25237-25462/com.atimi.sportsapp W/System.err: ... 9 more
10-14 10:45:28.830 25237-25462/com.atimi.sportsapp W/System.err: Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
10-14 10:45:28.899 25237-25462/com.atimi.sportsapp W/System.err: at libcore.io.Posix.android_getaddrinfo(Native Method)
10-14 10:45:28.909 25237-25462/com.atimi.sportsapp W/System.err: at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55)
10-14 10:45:28.919 25237-25462/com.atimi.sportsapp W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:438)
10-14 10:45:28.923 25237-25462/com.atimi.sportsapp W/System.err: ... 24 more

Categories

Resources