Trying to get up and running with a simple flutter app using the firebase_messaging package. Following the steps as per the instructions I changed the following files:
pubspec.yaml
dependencies:
flutter:
sdk: flutter # This is 1.7.8+hotfix.4
firebase_messaging: ^5.1.5
android/build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.3.0'
}
android/app/build.gradle
apply plugin: 'com.google.gms.google-services' # to the very bottom
Add the google-services.json to android/app/google-services.json and that's it.
Run using flutter run and the following error is returned:
* Error running Gradle:
ProcessException: Process "C:\...\android\gradlew.bat" exited abnormally:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\...\android\app\build.gradle' line: 24
* 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 0s
Command: C:\...\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.
The instructions are pretty vague so perhaps I've missed something but I would've thought that should work. This is on Windows 10, I have a feeling it might be platform related.
Upgraded to 5.1.6 and Flutter 1.9.1+2.
In addition to the online instructions I had to make some additional changes to get it to compile:
android/build.gradle
buildscript {
ext.kotlin_version = '1.3.41'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.2'
}
}
android/app/build.gradle
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'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
}
apply plugin: 'com.google.gms.google-services'
android/gradle/wrapper/gradle-wrapper-properties
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
Related
FAILURE: Build failed with an exception.
* What went wrong:
Could not create an instance of type org.gradle.invocation.DefaultGradle.
> Could not configure services using GradleScopeCompileServices.configure().
* 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
Exception: Gradle task assembleDebug failed with exit code 1
This is my build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I tried so many things I changed flutter and gradle version and looked everywhere but I still get this error. It worked before now it just doesen't. Btw java version is set to 1.8
Faced the same issue.
Solution:
Downgrade flutter version from 2.2.3 to 2.2.2
Delete ~/.android folder.
Restart android studio.
That kind of error has like a hundreds reason no one can know except to remember what you had done before. But anyway for better solution follow the following:
go to tools tab then flutter clean
go to file tab then invalidate cache and restart
follow the steps in this article to have the latest updates from Gradle
finally go to android folder then build gradle then on top right you will see edit file or something similar .. press on it and open new window and let it auto update till the end .. and better if you go to file into that new window then select project structure and manually see what the warning will it show to you and only press update
And don't forget to use the latest Flutter SDK.
[enter image description here][1]I have a problem with two libraries, one shows as this "C:\src\flutter.pub-cache\hosted\pub.dartlang.org\path_provider_macos-2.0.0\lib" and the other one is "C:\src\flutter.pub-cache\hosted\pub.dartlang.org\shared_preferences_macos-2.0.0\lib", they appear in red line like this picture, i've uninstalled and installed back Android Studio, i also copy the config from a "new flutter project" to my actual project, i also managed to upgrade the other libraries by using other tutorials, but i cant install this two libraries yet, on top of that, each time i press the play button on android studio to start installing my app to my phone, this error appears:
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not find com.github.agorabuilder:native-full-sdk:3.4.2.
Required by:
project :app > project :agora_rtc_engine
* 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 23s
Exception: Gradle task assembleDebug failed with exit code 1```
[1]: https://i.stack.imgur.com/wNXhP.png
Try this :
clean project
rebuild project
file/ Invalidate caches / restart
In the project-level build.gradle file of your android project add the following repository "maven { url 'https://jitpack.io' }" It should look similar to this
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
centre()
maven { url 'https://jitpack.io' }
}
}
allprojects {
repositories {
google()
centre()
maven { url 'https://jitpack.io' }
}
}
when i run flutter project i get this error .
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all dependencies for configuration ':app:debugCompileClasspath'.
> Problems reading data from Binary store in
C:\Users\Mohammad\AppData\Local\Temp\gradle3241964870133562548.bin offset 235082 exists? true
* 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 2m 8s
Exception: Gradle task assembleDebug failed with exit code 1
i restart my pc and after clean temp directory , also i run flutter clean but this error yet exist please help me my build.gradle file is
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
maven { url "https://maven.google.com/"}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
I recently added one new library to my flutter app. It started showing me an error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpath. You should manually set the same version via DependencyResolution
* 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
BUİLD FAILED in 14s
try to go to the dependencies and change the compile to 1.0.1
Step 1. Go to gradle.properties under android folder, and add the following piece of code:
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
Step 2. Now go to build.gradle under android and not under the app->build.gradle. While looking into the file make sure it starts with the word builscript (In this way you can ensure you're at the right build.gradle file.)
Step 3. Ctrl+A everything in that file, note that ctrl+A everything you need to erase off all the content and paste this piece of code:
buildscript {
ext.kotlin_version = '1.3.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx') ) {
details.useVersion "1.0.1"
}
}
}
}
}
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
}
A very important point to note is that during the process of compilation, chances are that you will see this warning message in complete red. Please don't get scared of it and let the whole compilation complete, before jumping to any conclusions. Although it comes in red, it won't stop your compilation as you will see in the bottom a turning circle that will show the progress of compilation. Right after that, it will disappear and you will be able to run the App. Here's the warning message:
Note:
C:\flutter.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.11\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java
uses or overrides a deprecated API. Note: Recompile with
-Xlint:deprecation for details. Note: C:\flutter.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.11\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java
uses unchecked or unsafe operations. Note: Recompile with
-Xlint:unchecked for details. ERROR: [TAG] Failed to resolve variable '${animal.sniffer.version}' Note:
C:\flutter.pub-cache\hosted\pub.dartlang.org\mlkit-0.15.0\android\src\main\java\com\azihsoyn\flutter\mlkit\MlkitPlugin.java uses unchecked or unsafe operations. Note: Recompile with
-Xlint:unchecked for details.
And Boom! that's it. Trust me this will definitely solve your problems.
In case you still struggle with any such problems try to implement some of the other solutions mentioned in this link as well.
* Error running Gradle:
ProcessException: Process "C:\Users\aarav\AndroidStudioProjects\flutter_firestoreapp\android\gradlew.bat" exited abnormally:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.android.support:appcompat-v4:27.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v4/27/appcompat-v4-27.pom
- https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v4/27/appcompat-v4-27.jar
- https://jcenter.bintray.com/com/android/support/appcompat-v4/27/appcompat-v4-27.pom
- https://jcenter.bintray.com/com/android/support/appcompat-v4/27/appcompat-v4-27.jar
Required by:
project :
* 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 6s
Command: C:\Users\aarav\AndroidStudioProjects\flutter_firestoreapp\android\gradlew.bat app:properties
Finished with error: Please review your Gradle project setup in the android/ folder.
I tried offline gradles of all versions.
App-gradle :
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-core:16.0.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-firestore:17.1.1'
}
apply plugin: 'com.google.gms.google-services'
Project-gradle :
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.1'
classpath 'com.android.support:appcompat-v4:27'
classpath 'com.android.tools.build:gradle:3.3.1'
}
}
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
}
Migrate to AndroidX (see also Flutter fail to run app on device import androidx.annotation.Nullable) and use the latest plugin versions,
or ensure that you use plugin versions that don't yet depend on AndroidX.
This issue contains more details https://github.com/flutter/flutter/issues/27128