gpt4 book ai didi

android - 无法在android studio中运行flutter项目

转载 作者:行者123 更新时间:2023-11-29 00:51:36 28 4
gpt4 key购买 nike

我已经下载了一个提醒 flutter 项目并在 android studio 中打开它并进行了运行它所需的更改但是在 app/gradle.build 中有一个无法解决的错误我已经将 flutter 升级到最新版本以及 android studio

出错的gradle.build文件

   def localProperties = new 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.")
}

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 27

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
// TODO: Specify your own unique Application ID
(https://developer.android.com/studio/build/application-id.html).
applicationId "me.tuannguyen.fluttertodo"
minSdkVersion 16
targetSdkVersion 27
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'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-firestore:21.3.0'
}

我认为这里的错误

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

以及向我显示的错误

Launching lib\main.dart on Redmi Note 7 in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "C:\Users\user1\AndroidStudioProjects\tuannguyendotme-flutter_todo-
6261e20\android\gradlew.bat" exited abnormally:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\user1\AndroidStudioProjects\tuannguyendotme-flutter_todo-
6261e20\android\app\build.gradle' line: 23

* What went wrong:
A problem occurred evaluating project ':app'.
> ASCII

* 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 1s
Command: C:\Users\user1\AndroidStudioProjects\tuannguyendotme-flutter_todo-
6261e20\android\gradlew.bat app:properties

Finished with error: Please review your Gradle project setup in the android/ folder.

Gradle.build

buildscript {
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}

allprojects {
repositories {
google()
jcenter()
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
delete rootProject.buildDir
}

gradle-wrapper.properties

 #Wed Sep 26 21:25:02 ICT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

最佳答案

您对源/项目文件的语言和导航有疑问。我认为构建脚本无法加载所有资源。

* Where:
Build file 'C:\Users\user1\AndroidStudioProjects\tuannguyendotme-flutter_todo-
6261e20\android\app\build.gradle' line: 23

* What went wrong:
A problem occurred evaluating project ':app'.
> ASCII

从下一行开始您的调查。如您所见,6261e20 应该是某个名称,但由于解码而被省略。

Build file 'C:\Users\user1\AndroidStudioProjects\tuannguyendotme-flutter_todo- 
6261e20\android\app\build.gradle' line: 23

关于android - 无法在android studio中运行flutter项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59060793/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com