sar*_*r47 5 android kotlin flutter
我正在尝试 flutter 的 hello world 代码。我从这里关注官方文档。
\n颤振版本:flutter_linux_1.20.1-stable
\n我已经创建了 flutter 项目并点击运行:
\nflutter create myapp\ncd myapp\nflutter run\nRun Code Online (Sandbox Code Playgroud)\n但它抛出了这个错误消息:
\nLaunching lib/main.dart on R40 in debug mode...\n \nFAILURE: Build failed with an exception. \n \n* Where: \nBuild file \'/home/sjs/flutter-projects/myapp/android/app/build.gradle\' line: 25\n \n* What went wrong: \nA problem occurred evaluating project \':app\'. \n> Failed to apply plugin [id \'kotlin-android\'] \n > Could not create an instance of type org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension.\n > Could not generate a decorated class for class org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension.\n > org/jetbrains/kotlin/gradle/plugin/KotlinTarget \n \n* Try: \nRun 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.\n \n* Get more help at https://help.gradle.org \n \nBUILD FAILED in 18s \nRunning Gradle task \'assembleDebug\'... \nRunning Gradle task \'assembleDebug\'... Done 22.1s\nException: Gradle task assembleDebug failed with exit code 1\nRun Code Online (Sandbox Code Playgroud)\n这是位于 \'/home/sjs/flutter-projects/myapp/android/app/\' 的 build.gradle 文件:
\ndef localProperties = new Properties()\ndef localPropertiesFile = rootProject.file(\'local.properties\')\nif (localPropertiesFile.exists()) {\n localPropertiesFile.withReader(\'UTF-8\') { reader ->\n localProperties.load(reader)\n }\n}\n\ndef flutterRoot = localProperties.getProperty(\'flutter.sdk\')\nif (flutterRoot == null) {\n throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")\n}\n\ndef flutterVersionCode = localProperties.getProperty(\'flutter.versionCode\')\nif (flutterVersionCode == null) {\n flutterVersionCode = \'1\'\n}\n\ndef flutterVersionName = localProperties.getProperty(\'flutter.versionName\')\nif (flutterVersionName == null) {\n flutterVersionName = \'1.0\'\n}\n\napply plugin: \'com.android.application\'\napply plugin: \'kotlin-android\'\napply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"\n\nandroid {\n compileSdkVersion 28\n\n sourceSets {\n main.java.srcDirs += \'src/main/kotlin\'\n }\n\n lintOptions {\n disable \'InvalidPackage\'\n }\n\n defaultConfig {\n // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).\n applicationId "com.example.myapp"\n minSdkVersion 16\n targetSdkVersion 28\n versionCode flutterVersionCode.toInteger()\n versionName flutterVersionName\n }\n\n buildTypes {\n release {\n // TODO: Add your own signing config for the release build.\n // Signing with the debug keys for now, so `flutter run --release` works.\n signingConfig signingConfigs.debug\n }\n }\n}\n\nflutter {\n source \'../..\'\n}\n\ndependencies {\n implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"\n}\nRun Code Online (Sandbox Code Playgroud)\n这是flutter doctor -v输出:
[\xe2\x9c\x93] Flutter (Channel stable, 1.20.1, on Linux, locale en_US.UTF-8)\n \xe2\x80\xa2 Flutter version 1.20.1 at /home/sjs/flutter\n \xe2\x80\xa2 Framework revision 2ae34518b8 (2 days ago), 2020-08-05 19:53:19 -0700\n \xe2\x80\xa2 Engine revision c8e3b94853\n \xe2\x80\xa2 Dart version 2.9.0\n\n[\xe2\x9c\x93] Android toolchain - develop for Android devices (Android SDK version 30.0.1)\n \xe2\x80\xa2 Android SDK at /home/sjs/Android/Sdk\n \xe2\x80\xa2 Platform android-30, build-tools 30.0.1\n \xe2\x80\xa2 Java binary at: /home/sjs/android-studio/jre/bin/java\n \xe2\x80\xa2 Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)\n \xe2\x80\xa2 All Android licenses accepted.\n\n[\xe2\x9c\x93] Android Studio (version 4.0)\n \xe2\x80\xa2 Android Studio at /home/sjs/android-studio\n \xe2\x80\xa2 Flutter plugin version 48.0.2\n \xe2\x80\xa2 Dart plugin version 193.7361\n \xe2\x80\xa2 Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)\n\n[\xe2\x9c\x93] Connected device (1 available)\n \xe2\x80\xa2 R40 (mobile) \xe2\x80\xa2 00114604032517 \xe2\x80\xa2 android-arm \xe2\x80\xa2 Android 9 (API 28)\n\n\xe2\x80\xa2 No issues found!\nRun Code Online (Sandbox Code Playgroud)\n
好的,在这里找到解决方案:https://github.com/react-native-community/react-native-webview/issues/1407#issuecomment-634436481
我必须编辑该<project-folder>/android/app/build.gradle文件。我已经更换了线
ext.kotlin_version = '1.3.50'
Run Code Online (Sandbox Code Playgroud)
有了这个
ext.kotlin_version = '1.3.72'
Run Code Online (Sandbox Code Playgroud)
然后就跑了flutter run。
| 归档时间: |
|
| 查看次数: |
18045 次 |
| 最近记录: |