0

I am new to flutter app development. Got handover of the flutter project and tried to run, but getting Build Failed Exception by terminal command.

flutter run -t lib/main_prod.dart

Got these errors in terminal

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 app level build.gradle code

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'

In above code Build file '/Users/ashishsciit/Desktop/Ashish/onfees/edflylearnGit/android/app/build.gradle' line: 62 points to

storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null

Tried with both iOS and Android emulators as well as physical devices but no success What should i do now ? Sorry for any english grammatical mistakes

1 Answer 1

1

It is Firebase configured project.

This error is because of some configuration error of firebase firebase. The error is due to the generated key store.

You should see the configuration of your firebase console project and your app and regenerate the SHA fingerprints by running:

  • keytool -genkey -v -keystore c:\Users\USER_NAME\key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key
  • Then run keytool -list -v -keystore debug.keystore -alias androiddebugkey to view your keys.
  • Copy and paste those keys in firebase project app.

And the second solution would be

  • See if key.properties file is present in android/key.properties.
  • Check if the generated key is matching with key mentioned in this file by running below command in command prompt.
  • Run keytool -list -v -keystore debug.keystore -alias androiddebugkey to view your keys.
  • Copy the same key to your firebase project and download "google-services.json" file and paste it your app folder in project at "C:\Users\USERNAME\AndroidStudioProjects\PROJECT_NAME\android\app\google-services.json".
  • run flutter clean
  • Get all the dependencies again by running pub get.

Your problem will be solved most probably.

Sign up to request clarification or add additional context in comments.

1 Comment

look for the key.properties file in your project and correct the matching key

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.