I have an app that was building fine before I formated my PC. I installed everything flutter needs and what I had in my previous install and tried to build my app after cloning from github. It results in failure.
PS D:\flutter_projects\uni-access> flutter build apk
Running "flutter pub get" in uni-access... 1.849ms
πͺ Building with sound null safety πͺ
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processReleaseMainManifest'.
> Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module #6732aa85
* 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 29s
Running Gradle task 'assembleRelease'... 30,6s
Gradle task assembleRelease failed with exit code 1
My flutter env.
PS D:\flutter_projects\uni-access> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[β] Flutter (Channel stable, 3.3.1, on Microsoft Windows [Version 10.0.22000.978], locale el-GR)
[β] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[β] Chrome - develop for the web
[β] Visual Studio - develop for Windows
β Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[!] Android Studio (not installed)
[β] VS Code (version 1.71.1)
[β] Connected device (3 available)
[β] HTTP Host Availability
! Doctor found issues in 2 categories.
I have java 17 and my build.gradle in android/app is the following.
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: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
// compileSdkVersion flutter.compileSdkVersion
compileSdkVersion 32
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutter_uni_access"
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
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 {
implementation platform('com.google.firebase:firebase-bom:29.2.1')
implementation 'com.google.firebase:firebase-analytics'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// implementation 'com.android.support:multidex:2.0.1'
}
This problem seems bizzare. I have tried flutter clean, gradle clean, deleting the .gradle dir from my user dir. Still nothing.
Related
I tried running my app on android emulator for the first time and this error showed up
Execution failed for task ':location:generateDebugRFile'.
FAILURE: Build failed with an exception
* What went wrong:
Execution failed for task ':location:generateDebugRFile'.
> Could not resolve all files for configuration ':location:debugCompileClasspath'.
> Could not find com.google.android.gms:play-services-location:16..
Required by:
project :location
* 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 19s
Exception: Gradle task assembleDebug failed with exit code 1
my app/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 FileNotFoundException("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'
// START: FlutterFire Configuration
apply plugin: 'com.google.gms.google-services'
// END: FlutterFire Configuration
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 33
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.fun"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 23
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
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 {
implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
implementation 'com.google.android.gms:play-services-auth:20.4.1'
implementation 'com.google.android.gms:play-services-location:21.0.1'
}
apply plugin: 'com.google.gms.google-services'
// Work around for onesignal-gradle-plugin compatibility
googleServices.disableVersionCheck = true
My android/build.grade
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
// START: FlutterFire Configuration
classpath 'com.google.gms:google-services:4.3.15'
// END: FlutterFire Configuration
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
my flutter doctor summary
[β] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[β] Xcode - develop for iOS and macOS (Xcode 14.2)
[β] Chrome - develop for the web
[β] Android Studio (version 2021.2)
[β] VS Code (version 1.71.0)
[β] Connected device (4 available)
[β] HTTP Host Availability
β’ No issues found!
I am just trying to launch the app on an android emulator so It can create a debug.keystore file, I have tried many options from other facing kind of the simillar problem
My app used to run perfectly fine a few days ago, I did NOT do any updates and today it is not building.
My system -
HP 15s eq2144au
AMD Ryzen 3 5300U
Flutter doctor -
Doctor summary (to see all details, run flutter doctor -v):
[β] Flutter (Channel master, 2.13.0-0.0.pre.604, on Microsoft Windows [Version 10.0.22000.613], locale en-IN)
[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[β] Chrome - develop for the web
[β] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.11)
[β] Android Studio (version 2021.1)
[!] Android Studio
X android-studio-dir = /usr/local/android-studio
X Android Studio not found at /usr/local/android-studio
[β] VS Code (version 1.66.2)
[β] Connected device (3 available)
[β] HTTP Host Availability
! Doctor found issues in 2 categories.
The error -
PS C:\Users\my_user_name\Documents\my_project_folder> flutter build apk
Building with sound null safety
Building with Flutter multidex support enabled.
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\my_user_name\Documents\my_project_folder\android\build.gradle' line: 27
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Could not open proj generic class cache for build file 'C:\Users\my_user_name\Documents\my_project_folder\android\app\build.gradle' (C:\Users\my_user_name\.gradle\caches\6.7\scripts\1l5ett1r4oxtcv991nxlv5dyv).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 62
* 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
Running Gradle task 'assembleRelease'... 1,804ms
Gradle task assembleRelease failed with exit code 1
What I have tried -
I have tried setting the compileSdkVersion in the build.gradle file located in project_folder\android\app to 28 and then 30 but that changes nothing.
My build.gradle file located in project_file\android\ -
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.google.gms:google-services:4.3.10'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My build.gradle file located in project_folder/android/app -
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 30
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId myappid
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:29.0.4')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
When I run it on Chrome, it works fine, the problem is only with Android.
Thanks!
I am trying to integrate push notifications into my futter application with firebase, I followed the instructions on how to go about it. But each time I add "com.google.gms:google-services" in my android/app/build.gradle file, I get the following error:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\flutter_project\my_app\android\app\build.gradle' line: 27
* What went wrong:
A problem occurred evaluating project ':app'.
> Plugin with id 'com.google.gms:google-services' not found.
* 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
I have tried other solutions I saw online and none have helped me. Please I need help.
Here is my flutter doctor output:
Doctor summary (to see all details, run flutter doctor -v):
[β] Flutter (Channel stable, 1.20.2, on Microsoft Windows [Version 10.0.18362.1016], locale en-US)
[β] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[β] Android Studio (version 4.0)
[β] VS Code (version 1.48.2)
[β] Connected device (1 available)
β’ No issues found!
here is my android/app/build.gradle file:
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"
apply plugin: 'com.google.gms:google-services' //defaulting code
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID
applicationId "com.myapp.myapp"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
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'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
I have also updated my flutter to the latest version I still get this error. What am I doing wrong?
It should be
apply plugin: 'com.google.gms.google-services'
Dot, not colon.
FirstlyοΌ
you need add classpath 'com.google.gms:google-services:4.3.3' in your project-level build.gradle
Then:
add "com.google.gms:google-services" in android/app/build.gradle file
I guess you missed firset step. Here is the doc https://firebase.google.com/docs/cloud-messaging/android/client
I am trying to implement push notification with firebase_messaging: ^6.0.13,
Flutter: Build errors for firebase_messagingβ
I have looked through all similar cases, Migrated my project to AndroidX but I still cannot resolve my Android build errors:
Followed procedures.
Flutter clean
flutter packages pub cache repair
Restart Android
Remake emulator nothing is working
Migrated project to AndroidX
Tried downgrading the plugin versions
Exception:
Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle... 0.6s
Resolving dependencies... 2.5s
/home/rajeshpatil/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.13/android/src/main/java/io/flutter/plugins/firebasemessaging/FirebaseMessagingPlugin.java:80: error: cannot find symbol
onAttachedToEngine(binding.getApplicationContext(), binding.getBinaryMessenger());
^
symbol: method getBinaryMessenger()
location: variable binding of type FlutterPluginBinding
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_messaging:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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 2s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 3.3s
Gradle task assembleDebug failed with exit code 1
project-level/build.gradle:
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
}
}
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
}
app-level/build.gradle:
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.")
}
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.helloworld"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
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 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
gradle.properties:
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
Flutter Doctor:
Doctor summary (to see all details, run flutter doctor -v):
[β] Flutter (Channel beta, v1.10.7, on Linux, locale en_IN)
[β] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[β] Android Studio (version 3.5)
[β] VS Code (version 1.43.0)
[β] Connected device (1 available)
β’ No issues found!
It looks like you are working on an older flutter project, try a few things and see if these help.
1) Update your flutter SDK. You are currently using a pretty old version of flutter, and a beta build that was never a stable release. Even if this doesnt solve your problem it would be wise to upgrade. You can do so by running flutter upgrade in your terminal.
2) You may be trying to use an older version of certain firebase packages, including messaging. Try changing classpath 'com.google.gms:google-services:4.3.0'
in your project gradle.build to classpath 'com.google.gms:google-services:3.2.1'. Do this only if updating your flutter SDK doesnt fix the issue, and if this doesnt help change it back.
3) Try increasing your minSDKVersion for the project in the app-level/build.gradle, in the past when I have had similar issues this fixed my problems around sdk version 21.
While connect my app with firebase generate SHA key app-level build.gradel shows an error in line 24 after adding google.json file I don't get where I am doing wrong line 24 starts from apply plugin. I upgrade flutter still I am getting this error -
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"
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "mdhv.co.clone_flutter"
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 {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
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'
}
apply plugin: 'com.google.gms.google-services'
After run Flutter doctor don't get any issue then where is the problem?
Doctor summary (to see all details, run flutter doctor -v):
[β] Flutter (Channel master, v1.10.3-pre.54, on Microsoft Windows [Version 10.0.18362.356], locale en-US)
[β] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[β] Android Studio (version 3.5)
[β] Connected device (1 available)
β’ No issues found!
The error you've provided is complete, but build errors are usually caused by the added package not being installed correctly. Running flutter clean then flutter pub get should do the job. Also, depending on the Firebase products that you're using, you only need to use Firebase CLI and flutterfire_cli to setup Firebase in your Flutter project.