我不熟悉应用开发。获得了flutter项目的移交并尝试运行,但是通过终端命令获取Build Failed Exception。
flutter run -t lib/main_prod.dart
在终端中找到这些错误
Using hardware rendering with device Android SDK built for x86. If you notice graphics artifacts,
consider enabling software rendering with "--enable-software-rendering".
Launching lib/main_prod.dart on Android SDK built for x86 in debug mode...
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/ashishsciit/Desktop/Ashish/onfees/edflylearnGit/android/app/build.gradle' line: 62
* What went wrong:
A problem occurred evaluating project ':app'.
> java.net.URISyntaxException: Illegal character in opaque part at index 2: C:\Work\edflylearn\edfly_learn_release_key.jks
* 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 42s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 45.0s
Exception: Gradle task assembleDebug failed with exit code 1
Android应用程序级别的build.gradle代码
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 plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 29
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "easy.tech.innovations.edflylearn"
minSdkVersion 21
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
debug {
debuggable true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
shrinkResources true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-messaging:20.2.0'
}
apply plugin: 'com.google.gms.google-services'
在以上代码中,构建文件'/Users/ashishsciit/Desktop/Ashish/onfees/edflylearnGit/android/app/build.gradle'行:62指向
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
尝试使用iOS和Android模拟器以及物理设备,但未成功 我现在该怎么办 ? 对不起,英语语法错误
答案 0 :(得分:0)
这是 Firebase 配置的项目。
这个错误是因为 firebase firebase 的一些配置错误。错误是由于生成的密钥库造成的。
您应该会看到您的 firebase 控制台项目和应用的配置,并通过运行以下命令重新生成 SHA 指纹:
keytool -genkey -v -keystore c:\Users\USER_NAME\key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key
keytool -list -v -keystore debug.keystore -alias androiddebugkey
查看您的密钥。第二种解决方案是
keytool -list -v -keystore debug.keystore -alias androiddebugkey
以查看您的密钥。flutter clean
pub get
再次获取所有依赖项。您的问题很可能会得到解决。