安卓模拟器为啥显示没有网络

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安卓模拟器为啥显示没有网络相关的知识,希望对你有一定的参考价值。

我也是刚刚解决这个问题,你家里的路由器是不是多级的?如果你的电脑连接在次级路由器上,那么网关会被模拟器认为是次级路由器,所以没有网络,应该手动设定IP地址,子网掩码,网关设置为主路由器的网关。这样就能上网啦 参考技术A 飞行模式 参考技术B 既然是模拟的那是肯定有很多的缺点了 参考技术C 模拟器,电脑上又没插手机卡,怎么会有网络?

为啥我的应用没有在安卓模拟器上运行?

【中文标题】为啥我的应用没有在安卓模拟器上运行?【英文标题】:Why isn't my app running on an android emulator?为什么我的应用没有在安卓模拟器上运行? 【发布时间】:2021-06-22 15:13:49 【问题描述】:

我正在创建一个颤振应用程序,并且正在尝试针对 Android 进行测试。当我打开模拟器时,它运行正常,但是当我尝试运行我的应用程序时,我得到了这个错误......谁能帮忙解决?它在我的 iPhone 上的 Xcode 中完美运行,但似乎无法在 Android 上运行...

Launching lib/main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... FAILURE: Build failed with an exception.
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... * What went wrong:
Running Gradle task 'assembleDebug'... Execution failed for task ':app:processDebugResources'.
Running Gradle task 'assembleDebug'... > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Running Gradle task 'assembleDebug'... > Android resource linking failed
Running Gradle task 'assembleDebug'... /Users/ragz/.gradle/caches/transforms-2/files-2.1/554200784d0157df45da8212b6e09519/play-services-ads-lite-19.7.0/AndroidManifest.xml:27:5-43:15: AAPT: error: unexpected element found in .
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... * Try:
Running Gradle task 'assembleDebug'... Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... * Get more help at https://help.gradle.org
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... BUILD FAILED in 4m 29s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 305.2s
The build failed likely due to AndroidX incompatibilities in a plugin.
The tool is about to try using Jetifier to solve the incompatibility.
Building plugin flutter_tts...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 87.4s
*********************************************************
WARNING: This version of flutter_tts will break your Android build if it or its dependencies aren't compatible with AndroidX.
See  for more information on the problem and how to fix it.
This warning prints for all Android build failures. The real root cause of the error may be unrelated.
*********************************************************

FAILURE: Build failed with an exception.

What went wrong:
A problem occurred configuring root project 'flutter_tts'.
SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/ragz/.pub-cache/hosted/pub.dartlang.org/flutter_tts-3.0.0/android/local.properties'.

Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Get more help at https://help.gradle.org

BUILD FAILED in 1m 24s

Exception: The plugin flutter_tts could not be built due to the issue
above.

【问题讨论】:

你能提供你的 Flutter 医生吗? 运行 flutter doctor 并粘贴输出。看起来没有定义 ANDROID_SDK_ROOT 变量。 当然,发送颤振医生的输出。 @Doc,没有 ANDROID_SDK_ROOT 变量是什么意思?我该怎么做才能改变它???到目前为止,这是问题的根源吗? 对我来说看起来不错。问题似乎与 androidX 兼容性有关。你的 gradle 文件中需要 android.useAndroidX=true android.enableJetifier=true。搜索如何修复 androidX 问题。 【参考方案1】:

检查您的 minSDKVersion 21 是否在 build.gradle 中。

【讨论】:

【参考方案2】:

这是我的颤振医生运行(我似乎没有什么问题,也许有?我不确定)-

[✓] Flutter (Channel stable, 2.0.2, on macOS 11.2 20D64 darwin-x64, locale en-GB)
    • Flutter version 2.0.2 at /Users/ragz/flutter
    • Framework revision 8962f6dc68 (2 weeks ago), 2021-03-11 13:22:20 -0800
    • Engine revision 5d8bf811b3
    • Dart version 2.12.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/ragz/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      ? https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      ? https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.54.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.20.0

[✓] Connected device (2 available)
    • sdk gphone x86 arm (mobile) • emulator-5554 • android-x86    • Android 11 (API
      30) (emulator)
    • Chrome (web)                • chrome        • web-javascript • Google Chrome
      

【讨论】:

您可以稍后将问题发布为编辑而不是答案。

以上是关于安卓模拟器为啥显示没有网络的主要内容,如果未能解决你的问题,请参考以下文章

为啥我的应用没有在安卓模拟器上运行?

手机端 安卓终端模拟器 root账户下 chown chmod 命令都没有效果 为啥手机里面文件

BurpSuite 抓安卓app包

为啥win10不能用安卓模拟器

为啥安卓模拟器屏幕是空白的?

ios模拟器使用百度地图为啥总定位失败