android / tuningfork

Android Performance Tuner is a library to help developers measure frame rendering time across different devices and game stages. This plugin will help developers integrate Android Performance Tuner into their game.
https://developer.android.com/games/sdk/performance-tuner/unity
Other
52 stars 30 forks source link

Monitoring App doesn't work due to "Cleartext HTTP traffic to localhost not permitted" error #12

Open bilck opened 2 years ago

bilck commented 2 years ago

I'm having issues using the monitoring app, I'm getting the following error: java.io.IOException: Cleartext HTTP traffic to localhost not permitted

I have already added android:usesCleartextTraffic="true" to the main AndroidManifest.xml file. I have also added android:networkSecurityConfig="@xml/network_security_config" to it.

Assets/Plugins/Android/res/xml/network_security_config.xml file content is:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <!-- Reference: https://forum.unity.com/threads/android-9-cleartext-http-traffic-to-my_ip-not-permitted.594298/#post-7215685 -->          
    <domain-config cleartextTrafficPermitted="true">
        <!-- For Android Performance Tuner data monitoring application https://developer.android.com/codelabs/android-performance-tuner-unity?hl=pt-br#7 -->
        <domain includeSubdomains="false">localhost</domain>
    </domain-config>
</network-security-config>

What am I doing wrong? Even though I performed all these steps, I still get the following error:

2021/10/01 11:25:37.125 26048 30167 Info Unity [PlotAndroidPerformanceTunerStarter] Telemetry uploaded with request name: applications/com.explot.gouda/apks/32
2021/10/01 11:25:37.524 26048 30167 Info Unity [AndroidNotificationsPlatform.OnLocalNotificationReceived] Received notification with null AndroidNotificationIntentData, skipping this.
2021/10/01 11:25:38.070 26048 1288 Info TuningFork:Web Connecting to: http://localhost:9000/applications/com.explot.gouda/apks/32:uploadTelemetry
2021/10/01 11:25:38.074 26048 1288 Info System.out (HTTPLog)-Static: isSBSettingEnabled false
2021/10/01 11:25:38.074 26048 1288 Warn TuningFork:Web java.io.IOException: Cleartext HTTP traffic to localhost not permitted
2021/10/01 11:25:38.075 26048 1288 Warn TuningFork.GE Error 15 when sending UPLOAD request
2021/10/01 11:25:38.075 26048 1288 Warn TuningFork.GE {"name": "applications/com.explot.gouda/apks/32", "session_context": {"device": {"brand": "samsung", "build_version": "30", "cpu_core_freqs_hz": [2210000000, 2210000000, 2210000000, 2210000000, 2808000000, 2808000000, 2808000000, 2912000000], "device": "t2s", "fingerprint": "samsung/t2sxxx/t2s:11/RP1A.200720.012/G996BXXU3AUHB:user/release-keys", "gles_version": {"major": 3, "minor": 2}, "model": "SM-G996B", "product": "t2sxxx", "total_memory_bytes": 7536852992}, "game_sdk_info": {"session_id": "3258a3df-f798-46a0-b8bb-201ad3e01a79", "swappy_version": "1.3.0", "version": "1.3.11"}, "time_period": {"end_time": "2021-10-01T14:25:36.983966Z", "start_time": "2021-10-01T14:22:38.222980Z"}}, "telemetry": [{"context": {"annotations": "", "duration": "298.397631671s", "tuning_parameters": {"experiment_id": "", "serialized_fidelity_parameters": ""}}, "report": {"battery": {"battery_event": [{"app_on_foreground": false, "charging": true, "current_charge_microampere_hours": 4156025, 
eristella commented 2 years ago

Hello @bilck, can I ask you whether you have Internet Access set to Require under Player Settings > Other Settings? Also, could you please post the parts of your manifest in which you specify the permissions? Please remove any personal/sensitive info from those parts :)

Thanks!

ikws4 commented 1 year ago

It worked after I replace network_security_config.xml to this:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config xmlns:android="http://schemas.android.com/apk/res/android">
    <base-config cleartextTrafficPermitted="true"></base-config>
</network-security-config>

ref: https://stackoverflow.com/a/67539006/14108377

mendozaarjay commented 1 month ago

having the same issue, i tried network_security_config.xml and the manifest but still no luck. please help