weixin_39777540
weixin_39777540
2020-12-08 22:32

ERR_CLEARTEXT_NOT_PERMITTED

Testing the demo app on the emulator and on my Android device, I get the same error: Webpage not available. The webpage at http:/127.0.0.1:46085/ could not be loaded because: net::ERR_CLEARTEXT_NOT_PERMITTED

Console output:


Launching lib\main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Waiting for sdk gphone x86 arm to report its views...
Debug service listening on ws://127.0.0.1:53029/vpU2zKITaHg=/ws
Syncing files to device sdk gphone x86 arm...
I/WebViewFactory(10684): Loading com.google.android.webview version 83.0.4103.101 (code 410410181)
I/hreed_view_tes(10684): The ClassLoaderContext is a special shared library.
W/Gralloc4(10684): allocator 3.x is not supported
I/hreed_view_tes(10684): The ClassLoaderContext is a special shared library.
I/cr_LibraryLoader(10684): Loaded native library version number "83.0.4103.101"
I/cr_CachingUmaRecorder(10684): Flushed 3 samples from 3 histograms.
I/TetheringManager(10684): registerTetheringEventCallback:com.example.threed_view_test
W/chromium(10684): [WARNING:dns_config_service_posix.cc(341)] Failed to read DnsConfig.
I/flutter (10684): >>>> ModelViewer initializing... <http:></http:>
D/EGL_emulation(10684): eglCreateContext: 0xe82662d0: maj 3 min 0 rcv 3
D/EGL_emulation(10684): eglMakeCurrent: 0xe82662d0: ver 3 0 (tinfo 0xe85badb0) (first time)
W/hreed_view_tes(10684): Accessing hidden method Landroid/media/AudioManager;->getOutputLatency(I)I (greylist, reflection, allowed)
D/HostConnection(10684): HostConnection::get() New Host Connection established 0xe8467010, tid 10810
V/InputMethodManager(10684): b/117267690: Failed to get fallback IMM with expected displayId=6 actual IMM#displayId=0 view=io.flutter.plugins.webviewflutter.InputAwareWebView{b86f4dc VFEDHVC.. ........ 0,0-768,1024}
D/HostConnection(10684): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_0 
W/cr_media(10684): Requires BLUETOOTH permission
I/VideoCapabilities(10684): Unsupported profile 4 for video/mp4v-es
W/cr_MediaCodecUtil(10684): HW encoder for video/avc is not available on this device.
I/flutter (10684): >>>> ModelViewer failed to load: net::ERR_CLEARTEXT_NOT_PERMITTED (WebResourceErrorType.unknown -1)
D/EGL_emulation(10684): eglCreateContext: 0xe8266f80: maj 3 min 0 rcv 3
D/EGL_emulation(10684): eglMakeCurrent: 0xe8266f80: ver 3 0 (tinfo 0xb552af90) (first time)

Main file:

dart
import 'package:flutter/material.dart';
import 'package:model_viewer/model_viewer.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(),
        body: ModelViewer(
          src: 'https://modelviewer.dev/shared-assets/models/Astronaut.glb',
          alt: "A 3D model of an astronaut",
          ar: true,
          autoRotate: true,
          cameraControls: true,
        ),
      ),
    );
  }
}

该提问来源于开源项目:drydart/model_viewer.dart

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • weixin_39830205 weixin_39830205 5月前

    Potential workaround: https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted

    Thanks for reporting. Could you give me more details on your Android emulator configuration, in particular the Android version, so that I can figure out how to reproduce this?

    点赞 评论 复制链接分享
  • weixin_39777540 weixin_39777540 5月前

    Thanks, going to try the fixes now. The emulator Android version is 11 and the physical device (same behavior) Android version 10.

    点赞 评论 复制链接分享
  • weixin_39777540 weixin_39777540 5月前

    Fixed! Edit AndroidManifest.xml, has to be done for target API level 28 and higher apparently.

    
     <application android:usescleartexttraffic="true"></application>

    Also, I had an error running the demo, because of background being null, so I added

    
    backgroundColor: Colors.white,
    

    and that got it working!

    I don't know what the FAB is supposed to do, it throws this error when i click on it:

    
    b/117267690: Failed to get fallback IMM with expected displayId=14 actual IMM#displayId=0 view=io.flutter.plugins.webviewflutter.InputAwareWebView{3728db1 VFEDHVC.. .F...... 0,0-768,1024}
    

    Thanks for this package, it's an awesome 3D viewer.

    点赞 评论 复制链接分享
  • weixin_39830205 weixin_39830205 5月前

    I've released 0.8.1 just now that addresses these issues.

    I don't know what the FAB is supposed to do, it throws this error when i click on it:

    Do you mean the "launch AR" button in the lower right corner? That only works on physical devices, so on an emulator you'd get that error logged.

    点赞 评论 复制链接分享

相关推荐