Jump to content

Android studio app development - Need some help

So first of all I never programmed an Android app from scratch, I just have some basic java knowledge, know how to compile in android studio (I think?), and know of the existence of gradle and maven, so this post may be stupid? 

Basically I just needed to fix some issues for a discontinued open source android app I needed, no problems with the "java" part of the app.
Testing the changes into the Android 9 and Android 8 android studio emulators worked fine, but the main problem I'm making this post is:

- Doesn't work on my Android 9 phone, for an Android API change reason. Basically I'm trying to use DownloadManager to an unsecure HTTP domain, which currently doesn't have a certificate because of a domain change, the whole reason I needed to fix this program.
 

To workaround this I found on the internet that you need to make a network_security_config.xml, and make it parse from the AndroidManifest.xml and so I did, and I put every combination possible of "cleartextTrafficPermitted="true" on it.

From the logcat I can see clearly it is being parsed, but it still gives me that "cleartext http traffic is not permitted" image.png.48e877bae059858cfc288c6e5169a423.png

Am I doing that wrong? I can tell you for sure the problem is not in my .xml file

Another thing

- Why does it work on the Android studio Android 9 emulator? That is really strange, because this is not permitted by default on Android 9 due to an API change as I said before, so what the hell is happening in there? 

Obviously this is going to be a temporary solution but still I can't figure out why this is not working

 

Link to post
Share on other sites

Just now, Dat Guy said:

Why do you torment yourself with Java? Android Studio natively supports Kotlin which is arguably a syntactically less horrible language, but there are also Delphi and .NET for Android if you feel like it.

It will still use a java vm to run that code anyway, but I'm not making a project from scratch, just fixing an old discontinued open source project 

Link to post
Share on other sites

6 hours ago, Dat Guy said:

Why do you torment yourself with Java? Android Studio natively supports Kotlin which is arguably a syntactically less horrible language, but there are also Delphi and .NET for Android if you feel like it.

Why do you torment yourself with a computer? You should write codes with pencil and paper. 

 

My philosophy: use official tools for the job. 

Sudo make me a sandwich 

Link to post
Share on other sites

Yeah, Android SDK 27 and 28 change a lot of things regarding permissions. To this day, I am still having problem getting my app to access sd card storage.

 

What are you trying to do? Download something from the web?

Sudo make me a sandwich 

Link to post
Share on other sites

8 minutes ago, wasab said:

Yeah, Android SDK 27 and 28 change a lot of things regarding permissions. To this day, I am still having problem getting my app to access sd card storage.

 

What are you trying to do? Download something from the web?

Yeah using DowloadManager from an HTTP non S domain, any workaround listed on developer.android.com doesn't work in my OnePlus 6.

I "solved" that by just waiting for that domain to have an SSL certificate, then I changed the http from https in my java code, now everything works. 
Still don't know why in the Android 9 emulator worked anyway but whatever...It just works so okay

https://developer.android.com/training/articles/security-config
https://android-developers.googleblog.com/2018/04/protecting-users-with-tls-by-default-in.html

Funny thing: doing the opposite, blocking every HTTP connection in the android emulator where it was working, was not being applied anyway

Link to post
Share on other sites

1 hour ago, Lukyp said:

Yeah using DowloadManager from an HTTP non S domain, any workaround listed on developer.android.com doesn't work in my OnePlus 6.

I "solved" that by just waiting for that domain to have an SSL certificate, then I changed the http from https in my java code, now everything works. 
Still don't know why in the Android 9 emulator worked anyway but whatever...It just works so okay

https://developer.android.com/training/articles/security-config
https://android-developers.googleblog.com/2018/04/protecting-users-with-tls-by-default-in.html

Funny thing: doing the opposite, blocking every HTTP connection in the android emulator where it was working, was not being applied anyway

It is OnePlus 6 being funny if emulator worked. 

Stick to https for your OnePlus 6 then... I guess?

Sudo make me a sandwich 

Link to post
Share on other sites

1 hour ago, wasab said:

It is OnePlus 6 being funny if emulator worked. 

Stick to https for your OnePlus 6 then... I guess?

After the http to https change it just won't work on Lollipop and Marshmallow, I'm done with this. I don't know why.
Thanks god I have to use that app just on my phone. 

Link to post
Share on other sites

2 hours ago, Lukyp said:

After the http to https change it just won't work on Lollipop and Marshmallow, I'm done with this. I don't know why.
Thanks god I have to use that app just on my phone. 

Just hardcode into your app to do one thing if API is lower than marshmarrow and another if API is Oreo or pie. In this case, use http in marshmarrow and https on Android pie. 

 

API will change. Google will usually start nagging the developers about targeting a specific API to ensure device compatibility if the apps do not meet specific Android versions. 

Sudo make me a sandwich 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×