I have taken over an outdated Android App written in Java
I have progressively upgraded dependencies without issue until I changed the targetSdkVersion from 27 to 30.
This is for a feature that:
Allows user to pick an from the gallery or capture from camera
Saves a value to an application folder
Sends the picture to an API
I know that pre-Android 10, I could add android:requestLegacyExternalStorage="true" in the Manifest file and it would work, but that feature was from Android 10+.
If I downgrade the targetSdkVersion, it works.
Otherwise it throws the following errors:
E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/emulated/0/xxxxx/1380402_672833029402941_703996746_n.jpg: open failed: EACCES (Permission denied)
I have narrowed it down to a permissions issue, due to scoped storage restrictions
I understand the concept behind it but I cannot get it to work.
What do I need to do to fix this in Java code, as I don't know how to apply the examples in Kotlin for Java?
I have tried following some of the answers from below:
Sample app: https://github.com/tinonetic/android-questions-scoped-storages
Write permissions not working - scoped storage Android SDK 30 (aka Android 11)
Scoped Storage android 10.0
Add image to Media Gallery - Android
Related
We recently migrated my apps target SDK to 33, from that app links are not working fine in emulator but not working in real device
I googled about it and manually opted for web address in my device and links are working fine, but I cant ask app users to do that every time
I have read android documentation
https://developer.android.com/training/app-links/verify-android-applinks#manual-verification
Here they mentioned process of manually verifying the domines for the Android above 12
but when I run adb shell am compat enable 175408749 com.myapp.package
terminal is throwing message says
Cannot override 175408749 for com.modere.global because the app's targetSdk (33) is above the change's targetSdk threshold (30)
How can I verify the domain please help me
You can use firebase dynamic link instead of deep link in android target SDK 33
I am developing a small App which downloads a website using HttpUrlConnection by using ASyncTask and saves it to a string and then displays the content on a TextView on a press of a button. If needed the user can press another button and transfer the content to another activity and use WebView to display said content on it.
The problem I am running into is that the App is able to download the content on the emulator but not on a real handheld device. I have put the internet usage permission in the manifest.
AVD API level: 26
Real device API level: 28
App development/target API: 21
As of API 28 HTTP clear text is no longer supported by default.
You are likely interacting with HTTP content and it is good enough for the AVD level 26.
Therefore to fix this, you must add the following to your manifest:
<application
...
android:usesCleartextTraffic="true"
This will allow you to continue to support HTTP traffic.
However, if you go this route, you should be aware of the security risks and potentially use a network config file to limit the destination domains that you are interacting with less than ideal security.
In the lower Android version, /sdcard/Download can be read and written, but from Android6 when I use code File file = new File("/sdcard/Download/TestResults.xls"); it will throw exception permission denied, I want to find are there a path in emulator that jave code can directly use to create File without asking permission?
Android-M ie, API 23 introduced Runtime Permissions for reducing security flaws in android device, where users can now directly manage app permissions at runtime.
You should to use permission API version above 23.
Refer this Android marshmallow request permission?
I have an app that observes a public directory on external storage with FileObserver.
It works fine on Lollipop devices. I want to add support for Marshmallow, so I set up a Nexus 9 tablet with it.
On the Marshmallow device, it fails, on Lollipop device it's OK.
On Marshmallow device, the FileObserver does not react to file system events that are caused by other processes. E.g. taking a screenshot, creating files via adb shell.
It works fine if the files are created by my app.
On Marshmallow, I ask for WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE permissions from Manifest.xml.
When I compile with API 23, I also make sure that I call ActivityCompat.requestPermissions().
When I compile with API 22, I just rely on Manifest.xml.
It works if I observe stuff on /data/data/my-package-name.
It fails if I observe stuff on /storage/emulated/0/Pictures/Screenshots.
Did anybody test FileObserver considreing all of the following? :
Marshmallow device
API 23 and API 22?
external storage
files created by some other process than the observing app (e.g. adb or taking screenshot).
This appears to be a bug in Marshmallow, see this link.
This is not fixed even in Nougat, you could get rid of the API this whole FileObserver, as it makes completely useless the fact that on most of the devices, it will not work.
I have an app which makes calls to a web service over https. When I run the apk on my phone, it works great. However, in the emulator, all of the POST requests over SSL fail with:
Read error: ssl=0xb402be00: Failure in SSL library, usually a protocol
error
error:100c50bf:SSL routines:ssl3_read_bytes:NO_RENEGOTIATION (external/boringssl/src/ssl/s3_pkt.c:852 0xabf7fcd7:0x00000000)
In the access logs on our server, it reports a 403 (Forbidden) whenever the emulator tries to hit the webservice, apparantly because the emulator is not
hand-shaking properly with our server. There a bunch of lines like this in apache's error log
[Thu Aug 20 12:21:21 2015] [error] [client xxx.xxx.xxx.xxx]
Re-negotiation handshake failed: Not accepted by client!?
Apache actually added the "!?" so it looks like a seriously unexpected error.
In my IDE, I have ticked the option for "Accept non-trusted certificates automatically" but that doesn't make a difference.
I have seen solutions on the web for fixing various SSL issues in android, however, they all seem to be the phone itself having an issue, and require code modification. Since it works fine on the phone, it seems like this is an Android Studio problem, and I should be able to correct this with a configuration setting. Or maybe I have to do something in a apache?
Bottom line: How can I get my app to talk to an SSL webservice in the emulator in Android Studio?
Using Studio 1.3.1, Java 1.7.0_65,
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.bla.bla"
minSdkVersion 14
targetSdkVersion 19
multiDexEnabled true
versionCode 12
versionName '1.2.0.8'
I believe this is because the emulator will reset your CA Certificates each time it runs.
Checkout out this post on Setting up a persistent trusted CA in an Android emulator
Please be aware that the location of the CA Certs have changed in Marshmallow, I'll update with some additional information ASAP
I suggest you to trust the certificate from SSL protected server in runtime.
This approach is independent of the device configuration and works fine for phone and emulator as well.
I wrote small library to do so.
Read more about this topic on my blog post:
https://mklimek.github.io/trust-specific-certificate-on-jvm/