Ошибка первого приложения флаттера: не удается разрешить символ «Свойства» - PullRequest
1 голос
/ 08 июля 2019

Я выполнил действия, описанные в документе Flutter, и попытался создать свое первое приложение Flutter в Intellij IDEA.И когда я пытался запустить его, произошла ошибка в моей переменной JAVA_HOME.И ошибка о не может разрешить символ «Свойства» в файле build.gradle.Я действительно не знаю, что делать.

Это моя информация об ошибке, отображаемая в окне консоли.

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Finished with error: ProcessException: Process 
"F:\untitled\android\gradlew.bat" exited abnormally:

ERROR: JAVA_HOME is set to an invalid directory: F:\Google download\jdk- 
10.0.1_windows-x64_bin.exe

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
  Command: F:\untitled\android\gradlew.bat -v

На самом деле в моей переменной JAVA_HOME нет ничего плохого, я установил ее направильный каталог: C: \ Program Files (x86) \ Java \ jdk1.8.0_131.

И я запускаю команду, показанную выше "F: \ untitled \ android \ gradlew.bat -v", этоПохоже, что обновилась версия Gradle, но ошибка не устранилась.

И это код в файле build.gradle.

def localProperties = new Properties() 
//there will be a highlight on Properties indicates that 'cannot resolve symbol "Properties" '

def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
//the same as the Properties on GradleException
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.untitled"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...