Flutter 常见错误

1、引入‘package:http/http.dart’报错

Target of URI doesn't exist: 'package:http/http.dart'.
Try creating the file referenced by the URI, or Try using a URI for a file that does exist.dart(uri_does_not_exist)

解决方法:

/pubspec.yaml

dependencies:
    http: ^0.11.0
    flutter:
        sdk: flutter

2、sdk不一致

E:\Android\flutter_jdshop\android\app\src\debug\AndroidManifest.xml Error:
        uses-sdk:minSdkVersion 16 cannot be smaller than version 17 declared in library [:flutter_inappbrowser] E:\Android\flutter_jdshop\build\flutter_inappbrowser\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml as the library might be using APIs not available in 16
        Suggestion: use a compatible library with a minSdk of at most 16,
                or increase this project's minSdk version to at least 17,
                or use tools:overrideLibrary="com.pichillilorenzo.flutter_inappbrowser" to force usage (may lead to runtime failures)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 17 declared in library [:flutter_inappbrowser] E:\Android\flutter_jdshop\build\flutter_inappbrowser\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml as the library might be using APIs not available in 16
        Suggestion: use a compatible library with a minSdk of at most 16,
                or increase this project's minSdk version to at least 17,
                or use tools:overrideLibrary="com.pichillilorenzo.flutter_inappbrowser" to force usage (may lead to runtime failures)

* 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 14s

解决方法:蓝色部分和上面提示的红色数字一致

/android/app/build.gradle

    defaultConfig {
        applicationId "com.example.flutter_jdshop"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

3、

* Error running Gradle:
ProcessException: Process "E:\flutter\flutter_jdshop\android\gradlew.bat" exited abnormally:

> Configure project :city_pickers
WARNING: The option setting 'android.enableR8=true' is experimental and unsupported.
The current default is 'false'
Consider disabling R8 by removing 'android.enableR8=true' from your gradle.properties before publishingyour app.

> Configure project :flutter_inappbrowser

Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of 
the afterEvaluate {} error.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':flutter_inappbrowser'.
> Could not resolve all artifacts for configuration ':flutter_inappbrowser:classpath'.
   > Could not download guava.jar (com.google.guava:guava:26.0-jre)
      > Could not get resource
      'https://jcenter.bintray.com/com/google/guava/guava/26.0-jre/guava-26.0-jre.jar'.
         > Could not GET
         'https://jcenter.bintray.com/com/google/guava/guava/26.0-jre/guava-26.0-jre.jar'.
            > Received close_notify during handshake
   > Could not download kotlin-reflect.jar (org.jetbrains.kotlin:kotlin-reflect:1.3.21)
      > Could not get resource
      'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.3.21/kotlin-reflect-1.3.21.jar      '.
         > Could not GET
         'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.3.21/kotlin-reflect-1.3.21.         jar'.
            > Received close_notify during handshake
   > Could not download kotlin-stdlib.jar (org.jetbrains.kotlin:kotlin-stdlib:1.3.21)
      > Could not get resource
      'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.3.21/kotlin-stdlib-1.3.21.jar'.         > Could not GET
         'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.3.21/kotlin-stdlib-1.3.21.ja         r'.
            > Received close_notify during handshake
   > Could not download jsr305.jar (com.google.code.findbugs:jsr305:3.0.2)
      > Could not get resource
      'https://jcenter.bintray.com/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar'.
         > Read timed out

* 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 2m 8s
  Command: E:\flutter\flutter_jdshop\android\gradlew.bat app:properties


Please review your Gradle project setup in the android/ folder.

解决方法:

进入 /android/app/build.gradle 文件

约63行,注释掉即可

//    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

 

 

 

 

 

 

你可能感兴趣的:(Flutter)