Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR_CLEARTEXT_NOT_PERMITTED #7

Closed
louisdeveseleer opened this issue Aug 20, 2020 · 4 comments
Closed

ERR_CLEARTEXT_NOT_PERMITTED #7

louisdeveseleer opened this issue Aug 20, 2020 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@louisdeveseleer
Copy link

louisdeveseleer commented Aug 20, 2020

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://127.0.0.1:46085/>
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:

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.
  @override
  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,
        ),
      ),
    );
  }
}
@louisdeveseleer louisdeveseleer added the bug Something isn't working label Aug 20, 2020
@artob artob self-assigned this Aug 20, 2020
@artob
Copy link
Member

artob commented Aug 20, 2020

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

@louisdeveseleer 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?

@louisdeveseleer
Copy link
Author

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

@louisdeveseleer
Copy link
Author

louisdeveseleer commented Aug 20, 2020

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

 <application
        android:usesCleartextTraffic="true" 

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.

@artob
Copy link
Member

artob commented Aug 21, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants