Firebase Firestore prevents Gradle from completing build - android

It shows this error whenever I try to sync the Gradle. Program type already present: com.google.protobuf.AbstractMessageLite$Builder$LimitedInputStream
I'm using AndroidStudio 3.1.3. I also followed the documentation on Firebase on how to get started but it dosen't work. I have tried to search and I couldn't get much information. I read about excluding the protobuf but it dosen't really work too.Thanks in advance for the help.
Also apparently commenting out the line with Firestore works so the issue is something with the Firestore dependency.
Below is my build.gradle for app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
//on laptop
//buildToolsVersion "26.0.2"
defaultConfig {
applicationId "application_id_name(sanitized)"
minSdkVersion 19
targetSdkVersion 26
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '27.0.3'
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'project.properties'
exclude 'META-INF/INDEX.LIST'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.firebaseui:firebase-ui-auth:4.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
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'
api 'com.google.android.gms:play-services-vision:15.0.0'
api 'com.android.support:multidex:1.0.3'
api 'com.google.cloud:google-cloud-storage:1.27.0'
implementation 'com.google.firebase:firebase-firestore:17.0.2'
implementation 'com.jjoe64:graphview:4.2.2'
}
apply plugin: 'com.google.gms.google-services'
And here is my build.gradle for the project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
//classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Got this error when trying to exclude protobuf.Could not find method com.google.firebase:firebase-firestore:17.0.2() for arguments [build_60vj88gllutj4zz7i0ca1ojkd$_run_closure2$_closure7#3b52fa7d] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
implementation 'com.google.firebase:firebase-firestore:17.0.2'{
exclude group: 'com.google.protobuf', module: 'protobuf-java'
}

Upgrade this:
classpath 'com.google.gms:google-services:3.2.1'
to this:
classpath 'com.google.gms:google-services:4.0.1'
to be able to use the latest version of firebase libraries.
After executing the ./gradlew :app:dependencies , you can see that both 'com.google.firebase:firebase-firestore:17.0.2' and 'com.google.cloud:google-cloud-storage:1.27.0' are depending on protobuf, thus leading to this problem.
Since Op is not using google-cloud-storage then removing 'com.google.cloud:google-cloud-storage:1.27.0' fixed this issue.

Related

Could not find method implementation() for arguments [com.google.android:support-v4:r7]

I'm a total Android / Java newbie, and came across a project I want to compile below:
https://github.com/maxamillion32/Android-Firebase-mapping
It is a bit old and maybe that's why it's causing me issues.
First error I got about Build Tools 24.0.1, which I downloaded. Now I get the following error which I cannot resolve:
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method implementation() for arguments [com.google.android:support-v4:r7] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I've checked my Dependencies in File>Project Structure and com.google.android:support-v4:r7 is there.
build.gradle (Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (app)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.mimming.hacks.starter"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:23.4.0'
implementation 'com.google.android.gms:play-services:9.6.1'
testImplementation 'junit:junit:4.12'
// compile 'com.firebase:firebase-client-android:2.5.2+'
apply plugin: 'com.google.gms.google-services'
implementation 'com.google.firebase:firebase-database:9.6.1'
}
Any ideas?
Thank you!
The gradle version used seems to be of lower version, in-order to use implementation gradle version should be above 3
You should replace your dependencies in build.gradle to latest version.
classpath 'com.android.tools.build:gradle:3.6.3'
Also you will have to upgrade the distributionUrl also
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
As you already mentioned you have updated the buildToolsVersion, this should work fine and also make sure all the dependencies are using implementation and not compileas compile is deprecated.

How to correctly apply the google services plugin?

I am working on a project, and I need to apply the google services plugin to my code. I have done so in the build.gradle project and module, but I keep receiving the following warning every time I run my app.
Please apply google-services plugin at the bottom of the build file.
Any help would be great!
Also, I am a beginner to coding, and it may be important to note that my app doesn't work. I get a runtime error in the emulator when I try to run it:
________ keeps stopping
app info
close app
Here is my build.gradle Module:app
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "edmt.dev.androidgeofire"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation
('com.android.support.test.espresso:espresso-core:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.h6ah4i.android.widget.verticalseekbar:verticalseekbar:0.7.2'
implementation 'com.firebase:geofire-android:2.3.1'
implementation 'com.google.firebase:firebase-database:16.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
}
apply plugin: 'com.google.gms.google-services'
I'm not sure what else I would need to include to help anyone understand, so if anyone needs anything else I would be happy to add it.
Try changing your build.gradle(project) like this
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.2.0'
}
}
Don't forget to change
classpath 'com.android.tools.build:gradle:3.3.2'
to your actual classpath of gradle

after upgrading, my project could not find resource file R but still running app showing no error. how to solve

I am facing a peculiar problem. i have upgraded my project from 23 api to 28. after upgrading, from my activity there showing cannot resolve R but while i run its building apk successfully and app running well without any showing any error. 2 more UI name also not recognizing in "setContentView" i have check that UIs no problem there. how to check for more specifically for UI error if exist.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
minSdkVersion 18
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
}
configurations {
compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
all*.exclude group: 'xpp3', module: 'xpp3'
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
repositories {
jcenter()
maven { url "https://dl.bintray.com/hani-momanii/maven" }
}
aaptOptions {
cruncherEnabled = false
}
lintOptions {
checkReleaseBuilds false
//If you want to continue even if errors found use following line
abortOnError false
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.0'
implementation 'com.github.delight-im:Android-AdvancedWebView:v3.0.0'
implementation 'com.google.gdata:core:1.47.1'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-v13:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.google.android.gms:play-services-nearby:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-places:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.github.markomilos:paginate:0.5.1'
implementation 'com.github.lovetuzitong:MultiImageSelector:1.2'
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.iarcuschin:simpleratingbar:0.1.5'
implementation 'com.droidninja:filepicker:2.1.1'
implementation 'com.google.android:flexbox:1.0.0'
implementation 'com.felipecsl.asymmetricgridview:library:2.0.1'
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'
build.gradle:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
can anyone please help me.
There are a few reasons for this problem and also a few solutions:
First thing to try is to Invalidate caches and restart, usually it's just an Android Studio caching problem
If that doesn't work you might have a Gradle/Android Studio version problem. Usually when you upgrade your compile SDK, also the gradle version needs to be updated, but Android Studio complains with the error you are getting (already happened to me). Also update your Android Studio to the latest stable version (my guess goes to this solution to your problem)
After Rebuild Project click Tools -> Android -> Sync Project with Gradle Files
I had a similar problem that occurred when pulling updates from my master Github branch. The resource files were there and named correctly, the app still worked fine but all of the resource identifiers in one of my classes were highlighted red. I solved this by restarting Android Studio and the errors went away.

Unable to merge dex, Android project build failed

I have updated an outdated project and made changes to build gradle, basically upgraded some gradle dependencies and changed gradle version. Project build successfully when I do clean and rebuild. But, when I try to run it on device or emulator it fails to build with transformDexArchiveWithExternalLibsDexMergerForDebug error.
I have tried almost every solution from these two SO threads but still unable to make it work.
Unable to Merge Dex - Android Studio 3.0
Unable to merge dex
Below is my project level gradle.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.google.gms:google-services:3.2.1'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
dependencies {
}
ext {
libraryVersion = "1.0.8"
}
This is app module gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.dapp.myapp"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
aaptOptions {
cruncherEnabled = false
useNewCruncher = false
}
lintOptions {
disable 'MissingTranslation'
}
dexOptions {
jumboMode true
javaMaxHeapSize "4g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':maskedEditText')
implementation project(':aPV')
//implementation files('libs/libGoogleAnalyticsServices.jar')
//compile 'com.android.support:appcompat-v7:19.1.0'
implementation files('libs/simple-xml-2.7.1.jar')
implementation project(':segmentControl')
implementation files('libs/gcm.jar')
implementation project(':UpPlatformSdk')
implementation files('libs/scribe-1.3.7.jar')
implementation files('libs/signpost-commonshttp4-1.2.1.2.jar')
implementation files('libs/signpost-core-1.2.1.2.jar')
// compile 'com.github.PhilJay:MPAndroidChart:v2.1.0'
implementation files('libs/joda-time-2.0.jar')
implementation project(':MPChartLib')
implementation files('libs/apache-httpcomponents-httpclient.jar')
implementation files('libs/apache-httpcomponents-httpcore.jar')
/*compile 'com.google.android.gms:play-services:8.4.0'*/
implementation files('libs/libphonenumber-3.8.jar')
implementation files('libs/ebizcharge-sdk.jar')
//compile project(':slicepaymentlibrary')
//compile project(':camerafragment')
implementation project(':camerafragment')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.loopj.android:android-async-http:1.4.5'
implementation 'com.android.support:customtabs:28.0.0'
//implementation 'com.google.android.gms:play-services-identity:16.0.0'
implementation 'com.google.android.gms:play-services-gcm:16.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
}
Build log
Full error stacktrace as pasting here is exceeding character limit
https://pastebin.com/Zukca8FM
Any help appreciated. Thanks.
Update your Google Services dependency:
classpath 'com.google.gms:google-services:3.3.0'
Firebase versioning style has changed, which can cause issues caused by conflicting libraries.
Try this project level gradle, I faced the same issue in my app, but this resolve my issue
buildscript {
repositories {
maven {
url 'http://jcenter.bintray.com'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:3.2.1'
classpath 'de.mobilej.unmock:UnMockPlugin:0.1.0'
classpath 'org.aspectj:aspectjtools:1.8.9'
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:1.0.10'
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5"
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1'
classpath "com.archinamon:android-gradle-aspectj:3.2.0"
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.6.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

How to fix Failed to resolve: support-compat

Why not help me?
In my application I want use ButterKnife library and I add this library dependencies. But when add this library and when click on Sync button.
Not sync project and show me error.
gradle.Build (project) :
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle.build (app) :
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.mohammad.ncistutorial"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
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.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
Error message :
Failed to resolve: support-compat
How can I fix it?
Please try to add depedency line with exclude group of support of app compact.
implementation 'com.jakewharton:butterknife:8.8.1',{
exclude group: 'com.android.support'
})
use this code
implementation 'com.jakewharton:butterknife:9.0.0-rc2',{
exclude group: 'com.android.support'
}
check your .gradle file version. Update or change latest gradle version.

Categories

Resources