CLEARTEXT communication to 127.0.0.1 not permitted by network security policy

报错信息提示的是明文(CLEARTEXT)通信到192.168.0.103不被网络安全策略所允许。这通常发生在Android应用开发中,当应用尝试进行网络请求但没有使用加密连接时。

解决方法:

  1. 确保你的应用使用的是HTTPS而不是HTTP进行网络通信。

  2. 如果你控制服务器端,确保服务器配置了SSL/TLS证书,以支持HTTPS连接。

  3. 如果你使用的是第三方服务,并且该服务不支持HTTPS,你可能需要寻找替代方案或使用其提供的HTTPS支持。

  4. 在应用的网络请求中明确指定使用安全协议,例如在OkHttp客户端中配置:

    OkHttpClient client = new OkHttpClient.Builder()
        .sslSocketFactory(sslSocketFactory, x509TrustManager)
        .build();

  5. 如果你有权限修改网络安全配置,可以在应用的res/xml目录下添加一个network_security_config.xml文件,并在其中将目标IP添加到允许名单中:

    <network-security-config>
        <domain-config cleartextTrafficPermitted="true">
            <domain includeSubdomains="true">192.168.0.103</domain>
        </domain-config>
    </network-security-config>

    然后在AndroidManifest.xml中引用这个配置:

    <application
        android:networkSecurityConfig="@xml/network_security_config"
        ...>

Preloading /system/fonts/Roboto-Regular.ttf 2025-06-11 15:04:36.823 31822-31822 le.maplibredemo com.example.maplibredemo I type=1400 audit(0.0:45210): avc: denied { read } for name="overlay" dev="sda6" ino=4252 scontext=u:r:untrusted_app:s0:c37,c256,c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=1 app=com.example.maplibredemo 2025-06-11 15:04:36.823 31822-31822 le.maplibredemo com.example.maplibredemo I type=1400 audit(0.0:45211): avc: denied { open } for path="/system/product/overlay" dev="sda6" ino=4252 scontext=u:r:untrusted_app:s0:c37,c256,c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=1 app=com.example.maplibredemo 2025-06-11 15:04:36.997 31822-31822 GraphicsEnvironment com.example.maplibredemo V ANGLE Developer option for 'com.example.maplibredemo' set to: 'default' 2025-06-11 15:04:36.997 31822-31822 GraphicsEnvironment com.example.maplibredemo V ANGLE GameManagerService for com.example.maplibredemo: false 2025-06-11 15:04:36.997 31822-31822 GraphicsEnvironment com.example.maplibredemo V Neither updatable production driver nor prerelease driver is supported. 2025-06-11 15:04:37.001 31822-31822 NetworkSecurityConfig com.example.maplibredemo D No Network Security Config specified, using platform default 2025-06-11 15:04:37.002 31822-31822 NetworkSecurityConfig com.example.maplibredemo D No Network Security Config specified, using platform default 2025-06-11 15:04:37.044 31822-31822 AppCompatDelegate com.example.maplibredemo D Checking for metadata for AppLocalesMetadataHolderService : Service not found 2025-06-11 15:04:37.053 31822-31856 libEGL com.example.maplibredemo D loaded /system/lib64/egl/libEGL_emulation.so 2025-06-11 15:04:37.056 31822-31822 RenderThread com.example.maplibredemo I type=1400 audit(0.0:45213): avc: denied { read write } for name="vaddress" dev="tmpfs" ino=520 scontext=u:r:untrusted_app:s0:c37,c256,c512,c768 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1 app=com.example.maplibredemo 2025-06-11 15:04:37.072 31822-31856 le.maplibredem com.example.maplibredemo D Features: 0 0 0 2025-06-11 15:04:37.072 31822-31856 le.maplibredem com.example.maplibredemo E vulkan version is 4202692 2025-06-11 15:04:37.076 31822-31856 libEGL com.example.maplibredemo D loaded /system/lib64/egl/libGLESv1_CM_emulation.so 2025-06-11 15:04:37.056 31822-31822 RenderThread com.example.maplibredemo I type=1400 audit(0.0:45214): avc: denied { open } for path="/dev/vaddress" dev="tmpfs" ino=520 scontext=u:r:untrusted_app:s0:c37,c256,c512,c768 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1 app=com.example.maplibredemo 2025-06-11 15:04:37.086 31822-31856 libEGL com.example.maplibredemo D loaded /system/lib64/egl/libGLESv2_emulation.so 2025-06-11 15:04:37.103 31822-31856 GraphicsEnv com.example.maplibredemo E Failed to get gpu service 2025-06-11 15:04:37.159 31822-31822 le.maplibredem com.example.maplibredemo W Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed) 2025-06-11 15:04:37.160 31822-31822 le.maplibredem com.example.maplibredemo W Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed) 2025-06-11 15:04:37.178 31822-31822 le.maplibredem com.example.maplibredemo W Accessing hidden field Landroid/graphics/Typeface;->sSystemFontMap:Ljava/util/Map; (unsupported, reflection, allowed) 2025-06-11 15:04:37.196 31822-31835 System com.example.maplibredemo W A resource failed to call close. 2025-06-11 15:04:37.270 31822-31854 le.maplibredem com.example.maplibredemo D Features: 0 0 0 2025-06-11 15:04:37.271 31822-31854 le.maplibredem com.example.maplibredemo E vulkan version is 4202692 2025-06-11 15:04:37.273 31822-31854 hw-ProcessState com.example.maplibredemo D Binder ioctl to enable oneway spam detection failed: Invalid argument 2025-06-11 15:04:37.274 31822-31854 HidlServiceManagement com.example.maplibredemo E getService: Potential race detected, descriptor: android.hardware.configstore@1.0::ISurfaceFlingerConfigs instance: default 2025-06-11 15:04:37.275 31822-31854 OpenGLRenderer com.example.maplibredemo W Failed to initialize 101010-2 format, error = EGL_SUCCESS 2025-06-11 15:04:37.276 31822-31871 Mbgl-EGLConfigChooser com.example.maplibredemo I In emulator: false 2025-06-11 15:04:37.278 31822-31871 le.maplibredem com.example.maplibredemo D Features: 0 0 0 2025-06-11 15:04:37.278 31822-31871 le.maplibredem com.example.maplibredemo E vulkan version is 4202692 2025-06-11 15:04:37.281 31822-31871 HidlServiceManagement com.example.maplibredemo E getService: Potential race detected, descriptor: android.hardware.graphics.mapper@4.0::IMapper instance: default 2025-06-11 15:04:37.282 31822-31871 Gralloc4 com.example.maplibredemo I mapper 4.x is not supported 2025-06-11 15:04:37.286 31822-31871 HidlServiceManagement com.example.maplibredemo E getService: Potential race detected, descriptor: android.hardware.graphics.mapper@3.0::IMapper instance: default 2025-06-11 15:04:37.286 31822-31871 Gralloc3 com.example.maplibredemo W mapper 3.x is not supported 2025-06-11 15:04:37.286 31822-31871 HidlServiceManagement com.example.maplibredemo E getService: Potential race detected, descriptor: android.hardware.graphics.mapper@2.0::IMapper instance: default 2025-06-11 15:04:37.288 31822-31871 HidlServiceManagement com.example.maplibredemo E getService: Potential race detected, descriptor: android.hardware.graphics.allocator@4.0::IAllocator instance: default 2025-06-11 15:04:37.289 31822-31871 Gralloc4 com.example.maplibredemo W allocator 4.x is not supported 2025-06-11 15:04:37.289 31822-31871 HidlServiceManagement com.example.maplibredemo E getService: Potential race detected, descriptor: android.hardware.graphics.allocator@3.0::IAllocator instance: default 2025-06-11 15:04:37.290 31822-31871 Gralloc3 com.example.maplibredemo W allocator 3.x is not supported 2025-06-11 15:04:37.290 31822-31871 HidlServiceManagement com.example.maplibredemo E getService: Potential race detected, descriptor: android.hardware.graphics.allocator@2.0::IAllocator instance: default 2025-06-11 15:04:37.291 31822-31871 gralloc_x86 com.example.maplibredemo D gralloc_alloc: Creating ashmem region of size 4919296 2025-06-11 15:04:37.291 31822-31854 gralloc_x86 com.example.maplibredemo D gralloc_alloc: Creating ashmem region of size 5763072 2025-06-11 15:04:37.313 31822-31871 gralloc_x86 com.example.maplibredemo D gralloc_alloc: Creating ashmem region of size 4919296 2025-06-11 15:04:37.321 31822-31871 gralloc_x86 com.example.maplibredemo D gralloc_alloc: Creating ashmem region of size 4919296 2025-06-11 15:04:37.373 31822-31854 gralloc_x86 com.example.maplibredemo D gralloc_alloc: Creating ashmem region of size 5763072 2025-06-11 15:04:37.379 31822-31890 Mbgl com.example.maplibredemo I {RenderThread 45}[General]: GPU Identifier: Adreno (TM) 640 2025-06-11 15:04:37.380 31822-31822 Mbgl-Conne...tyReceiver com.example.maplibredemo V connected - true 2025-06-11 15:04:37.416 31822-31854 gralloc_x86 com.example.maplibredemo D gralloc_alloc: Creating ashmem region of size 5763072 2025-06-11 15:04:37.919 31822-31893 Mbgl-HttpRequest com.example.maplibredemo W Request failed due to a permanent error: CLEARTEXT communication to 127.0.0.1 not permitted by network security policy 2025-06-11 15:04:37.920 31822-31892 Mbgl-HttpRequest com.example.maplibredemo W Request failed due to a permanent error: CLEARTEXT communication to 127.0.0.1 not permitted by network security policy 2025-06-11 15:04:37.920 31822-31861 Mbgl-HttpRequest com.example.maplibredemo D [HTTP] This request was cancelled (http://127.0.0.1:8081/resources/sprites/v1/sprite@1@2x.png). This is expected for tiles that were being prefetched but are no longer needed for the map to render. 2025-06-11 15:04:37.921 31822-31861 Mbgl-HttpRequest com.example.maplibredemo D [HTTP] This request was cancelled (http://127.0.0.1:8081/resources/sprites/v1/sprite@1@2x.json). This is expected for tiles that were being prefetched but are no longer needed for the map to render. 2025-06-11 15:04:37.921 31822-31822 Mbgl com.example.maplibredemo E {le.maplibredemo}[Style]: Failed to load sprite: CLEARTEXT communication to 127.0.0.1 not permitted by network security policy 2025-06-11 15:04:37.922 31822-31822 Mbgl com.example.maplibredemo E {le.maplibredemo}[Style]: Failed to load sprite: CLEARTEXT communication to 127.0.0.1 not permitted by network security policy 2025-06-11 15:04:39.134 31822-31893 Mbgl-HttpRequest com.example.maplibredemo W Request failed due to a permanent error: CLEARTEXT communication to 127.0.0.1 not permitted by network security policy 2025-06-11 15:04:39.134 31822-31892 Mbgl-HttpRequest com.example.maplibredemo W Request failed due to a permanent error: CLEARTEXT communication to 127.0.0.1 not permitted by network security policy 2025-06-11 15:04:39.135 31822-31861 Mbgl-HttpRequest com.example.maplibredemo D [HTTP] This request was cancelled (http://127.0.0.1:8082/tiles/natural_earth/0/0/0.pbf). This is expected for tiles that were being prefetched but are no longer needed for the map to render. 2025-06-11 15:04:39.136 31822-31861 Mbgl-HttpRequest com.example.maplibredemo D [HTTP] This request was cancelled (http://127.0.0.1:8082/tiles/natural_earth/0/0/0.pbf). This is expected for tiles that were being prefetched but are no longer needed for the map to render. 2025-06-11 15:04:39.136 31822-31894 Mbgl-HttpRequest com.example.maplibredemo W Request failed due to a permanent error: CLEARTEXT communication to 127.0.0.1 not permitted by network security policy 2025-06-11 15:04:39.136 31822-31861 Mbgl-HttpRequest com.example.maplibredemo D [HTTP] This request was cancelled (http://127.0.0.1:8082/tiles/natural_earth/0/0/0.pbf). This is expected for tiles that were being prefetched but are no longer needed for the map to render. 2025-06-11 15:04:39.151 31822-31871 Mbgl com.example.maplibredemo E {RenderThread 45}[Style]: Failed to load tile 0/0/0=>0 for source earth: CLEARTEXT communication to 127.0.0.1 not permitted by network security policy 2025-06-11 15:04:39.152 31822-31871 Mbgl com.example.maplibredemo E {RenderThread 45}[Style]: Failed to load tile 0/0/0=>0 for source earth: CLEARTEXT communication to 127.0.0.1 not permitted by network security policy 2025-06-11 15:04:39.152 31822-31871 Mbgl com.example.maplibredemo E {RenderThread 45}[Style]: Failed to load tile 0/0/0=>0 for source earth: CLEARTEXT communication to 127.0.0.1 not permitted by network security policy 2025-06-11 15:04:42.712 31822-31895 ProfileInstaller com.example.maplibredemo D Installing profile for com.example.maplibredemo
06-12
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值