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.
Related
I just checked out the spatial anchors demo from GitHub, changed the keys and deployed it to my Samsung S8 successfully.
But when I try to save an anchor I get an IllegalStateException:
05-18 12:17:32.667 5536-6285/com.microsoft.sampleandroid E/CBindingAutoGen: exception causing failure: std::exception
05-18 12:17:32.670 5536-6286/com.microsoft.sampleandroid W/System.err: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: std::exception.Request CV: . Response CV: .
05-18 12:17:32.674 5536-6286/com.microsoft.sampleandroid W/System.err: at java.util.concurrent.FutureTask.report(FutureTask.java:123)
05-18 12:17:32.675 5536-6286/com.microsoft.sampleandroid W/System.err: at java.util.concurrent.FutureTask.get(FutureTask.java:193)
05-18 12:17:32.677 5536-6286/com.microsoft.sampleandroid W/System.err: at com.microsoft.sampleandroid.AzureSpatialAnchorsManager.lambda$toEmptyCompletableFuture$2(AzureSpatialAnchorsManager.java:147)
05-18 12:17:32.680 5536-6286/com.microsoft.sampleandroid W/System.err: at com.microsoft.sampleandroid.-$$Lambda$AzureSpatialAnchorsManager$8SSZbzB3fyFTuS1Rv6e_KEvy8B8.run(Unknown Source:2)
05-18 12:17:32.682 5536-6286/com.microsoft.sampleandroid W/System.err: at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1661)
05-18 12:17:32.684 5536-6286/com.microsoft.sampleandroid W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
05-18 12:17:32.686 5536-6286/com.microsoft.sampleandroid W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
05-18 12:17:32.687 5536-6286/com.microsoft.sampleandroid W/System.err: at java.lang.Thread.run(Thread.java:764)
05-18 12:17:32.690 5536-6286/com.microsoft.sampleandroid W/System.err: Caused by: java.lang.IllegalStateException: std::exception.Request CV: . Response CV: .
05-18 12:17:32.692 5536-6286/com.microsoft.sampleandroid W/System.err: at com.microsoft.azure.spatialanchors.NativeLibraryHelpers.checkStatus(NativeLibraryHelpers.java:65)
05-18 12:17:32.693 5536-6286/com.microsoft.sampleandroid W/System.err: at com.microsoft.azure.spatialanchors.CloudSpatialAnchorSession$3.call(CloudSpatialAnchorSession.java:393)
05-18 12:17:32.695 5536-6286/com.microsoft.sampleandroid W/System.err: at com.microsoft.azure.spatialanchors.CloudSpatialAnchorSession$3.call(CloudSpatialAnchorSession.java:390)
05-18 12:17:32.696 5536-6286/com.microsoft.sampleandroid W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
05-18 12:17:32.697 5536-6286/com.microsoft.sampleandroid W/System.err: ... 3 more
05-18 12:17:32.700 5536-6286/com.microsoft.sampleandroid W/System.err: java.util.concurrent.CompletionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: std::exception.Request CV: . Response CV: .
05-18 12:17:32.701 5536-6286/com.microsoft.sampleandroid W/System.err: at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:276)
05-18 12:17:32.701 5536-6286/com.microsoft.sampleandroid W/System.err: at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:282)
05-18 12:17:32.702 5536-6286/com.microsoft.sampleandroid W/System.err: at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1664)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
05-18 12:17:32.703 5536-6286/com.microsoft.sampleandroid W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
05-18 12:17:32.703 5536-6286/com.microsoft.sampleandroid W/System.err: at java.lang.Thread.run(Thread.java:764)
05-18 12:17:32.704 5536-6286/com.microsoft.sampleandroid W/System.err: Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: std::exception.Request CV: . Response CV: .
05-18 12:17:32.705 5536-6286/com.microsoft.sampleandroid W/System.err: at com.microsoft.sampleandroid.AzureSpatialAnchorsManager.lambda$toEmptyCompletableFuture$2(AzureSpatialAnchorsManager.java:150)
05-18 12:17:32.705 5536-6286/com.microsoft.sampleandroid W/System.err: at com.microsoft.sampleandroid.-$$Lambda$AzureSpatialAnchorsManager$8SSZbzB3fyFTuS1Rv6e_KEvy8B8.run(Unknown Source:2)
05-18 12:17:32.706 5536-6286/com.microsoft.sampleandroid W/System.err: at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1661)
... 3 more
05-18 12:17:32.707 5536-6286/com.microsoft.sampleandroid W/System.err: Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: std::exception.Request CV: . Response CV: .
at java.util.concurrent.FutureTask.report(FutureTask.java:123)
05-18 12:17:32.708 5536-6286/com.microsoft.sampleandroid W/System.err: at java.util.concurrent.FutureTask.get(FutureTask.java:193)
at com.microsoft.sampleandroid.AzureSpatialAnchorsManager.lambda$toEmptyCompletableFuture$2(AzureSpatialAnchorsManager.java:147)
05-18 12:17:32.709 5536-6286/com.microsoft.sampleandroid W/System.err: ... 5 more
05-18 12:17:32.710 5536-6286/com.microsoft.sampleandroid W/System.err: Caused by: java.lang.IllegalStateException: std::exception.Request CV: . Response CV: .
05-18 12:17:32.711 5536-6286/com.microsoft.sampleandroid W/System.err: at com.microsoft.azure.spatialanchors.NativeLibraryHelpers.checkStatus(NativeLibraryHelpers.java:65)
at com.microsoft.azure.spatialanchors.CloudSpatialAnchorSession$3.call(CloudSpatialAnchorSession.java:393)
05-18 12:17:32.713 5536-6286/com.microsoft.sampleandroid W/System.err: at com.microsoft.azure.spatialanchors.CloudSpatialAnchorSession$3.call(CloudSpatialAnchorSession.java:390)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
... 3 more
I just used the normal code and did nothing else
Check the credentials… Error occurs if trying to access with wrong credentials.
while updating app from playstore I'm getting the error..
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available 09-02 17:10:03.586 11866-12008/? W/System.err: java.lang.ClassNotFoundException: android.net.ZeroBalanceHelper 09-02 17:10:03.586 11866-12008/? W/System.err: at java.lang.Class.classForName(Native Method) 09-02 17:10:03.587 11866-12008/? W/System.err: at java.lang.Class.forName(Class.java:324) 09-02 17:10:03.587 11866-12008/? W/System.err: at java.lang.Class.forName(Class.java:285) 09-02 17:10:03.587 11866-12008/? W/System.err: at
com.android.okhttp.internal.http.ZeroBalanceHelperClass.getFeatureFlagValue(ZeroBalanceHelperClass.java:39)
09-02 17:10:03.587 11866-12008/? W/System.err: at
com.android.okhttp.internal.http.HttpEngine.followUpRequest(HttpEngine.java:1090)
09-02 17:10:03.588 11866-12008/? W/System.err: at
com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:393)
09-02 17:10:03.588 11866-12008/? W/System.err: at
com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:501)
09-02 17:10:03.588 11866-12008/? W/System.err: at
com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
09-02 17:10:03.588 11866-12008/? W/System.err: at
com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
09-02 17:10:03.588 11866-12008/? W/System.err: at la.a(:com.google.android.gms.DynamiteModulesA:193) 09-02 17:10:03.588 11866-12008/? W/System.err: at lb.a(:com.google.android.gms.DynamiteModulesA:151) 09-02 17:10:03.588 11866-12008/? W/System.err: at jt.c(:com.google.android.gms.DynamiteModulesA:608) 09-02 17:10:03.588 11866-12008/? W/System.err: at lm.run(:com.google.android.gms.DynamiteModulesA:242) 09-02 17:10:03.588 11866-12008/? W/System.err: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) 09-02 17:10:03.588 11866-12008/? W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237) 09-02 17:10:03.588 11866-12008/? W/System.err: at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
09-02 17:10:03.588 11866-12008/? W/System.err: at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
09-02 17:10:03.588 11866-12008/? W/System.err: at java.lang.Thread.run(Thread.java:818) 09-02 17:10:03.588 11866-12008/? W/System.err: Caused by: java.lang.ClassNotFoundException: android.net.ZeroBalanceHelper 09-02 17:10:03.592 11866-12008/? W/System.err: at java.lang.Class.classForName(Native Method) 09-02 17:10:03.592 11866-12008/? W/System.err: at java.lang.BootClassLoader.findClass(ClassLoader.java:781) 09-02 17:10:03.592 11866-12008/? W/System.err: at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) 09-02 17:10:03.592 11866-12008/? W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:469) 09-02 17:10:03.592 11866-12008/? W/System.err: ... 18 more
app doesn't run after this error, any help will be highly appreciated.
In my application i use a self signed certificate to connect over https. The application works perfectly fine when the compilesdk is set to < 24, however when the compilesdk is set to 24 my application fails to connect to the server over https and throws the following exception:
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:361)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:192)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:149)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.io.RealConnection.connect(RealConnection.java:112)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:184)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.Call.getResponse(Call.java:286)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.worklight.wlclient.CertificatePinningInterceptor.intercept(CertificatePinningInterceptor.java:20)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:232)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.worklight.wlclient.OkHttpInterceptor.intercept(OkHttpInterceptor.java:145)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:232)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.Call.execute(Call.java:80)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.worklight.wlclient.WLRequestSender.run(WLRequestSender.java:49)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at java.lang.Thread.run(Thread.java:761)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:549)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:401)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:375)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:304)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java:94)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:178)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:596)
07-27 14:35:52.929 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
07-27 14:35:52.929 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357)
07-27 14:35:52.929 11424-11956/com.test.Push W/System.err: ... 20 more
07-27 14:35:52.929 11424-11956/com.test.Push W/System.err: Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
07-27 14:35:52.929 11424-11956/com.test.Push W/System.err: ... 30 more
I followed the steps mentioned here https://developer.android.com/preview/features/security-config.html, however my app still fails to connect to the server over https. My network_security_config.xml is as below:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config>
<domain includeSubdomains="true">test.abc.com</domain>
<trust-anchors>
<certificates src="#raw/ca_norton"/>
</trust-anchors>
</domain-config>
</network-security-config>
In my AndroidManifest.xml included the following under the application tag
<meta-data android:name="android.security.net.config"
android:resource="#xml/network_security_config" />
ca_norton.crt is also copied into the raw folder. Am i missing something here? Thanks in advance.
The correct way to specify a Network Security Config in your manifest is:
<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
<application android:networkSecurityConfig="#xml/network_security_config"
... >
...
</application>
</manifest>
See https://developer.android.com/preview/features/security-config.html#manifest. The meta-data approach was only present in the early N previews and is no longer supported.
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)
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.