RNfirebase installation issue with firebase-functions 11.6 - react-native-firebase

I keep getting the following error when I am trying to run the build after completing all the RNFIREBASE steps to install Firebase for my react-native project.
RN version: 0.55.3
Using appcenter for builds
The build was working fine on appcenter when I did not add firebase. The build on iOS is working on the phone and appcenter.
Error
> - Trying to run build on Appcenter. Using configuration: release
>
> Resolved com.facebook.react:react-native:0.55.3 in :react-native-firebase:releaseCompileClasspath
Resolved com.android.support:support-v4:27.0.2 in :react-native-firebase:releaseCompileClasspath
Resolved com.crashlytics.sdk.android:crashlytics:2.9.3 in :react-native-firebase:releaseCompileClasspath
Resolved com.google.android.gms:play-services-base:11.6.0 in :react-native-firebase:releaseCompileClasspath
Resolved com.google.firebase:firebase-ads:11.6.0 in :react-native-firebase:releaseCompileClasspath
Resolved com.google.firebase:firebase-auth:11.6.0 in :react-native-firebase:releaseCompileClasspath
Resolved com.google.firebase:firebase-config:11.6.0 in :react-native-firebase:releaseCompileClasspath
Resolved com.google.firebase:firebase-core:11.6.0 in :react-native-firebase:releaseCompileClasspath
Resolved com.google.firebase:firebase-crash:11.6.0 in :react-native-firebase:releaseCompileClasspath
Resolved com.google.firebase:firebase-database:11.6.0 in :react-native-firebase:releaseCompileClasspath
Resolved com.google.firebase:firebase-firestore:11.6.0 in :react-native-firebase:releaseCompileClasspath
Resolved com.google.firebase:firebase-invites:11.6.0 in :react-native-firebase:releaseCompileClasspath
Resolved com.google.firebase:firebase-storage:11.6.0 in :react-native-firebase:releaseCompileClasspath
Resolved com.google.firebase:firebase-messaging:11.6.0 in :react-native-firebase:releaseCompileClasspath
Resolved com.google.firebase:firebase-perf:11.6.0 in :react-native-firebase:releaseCompileClasspath
Resolved me.leolin:ShortcutBadger:1.1.21 in :react-native-firebase:releaseCompileClasspath
Resolved com.android.support:multidex:1.0.2 in :react-native-firebase:releaseCompileClasspath
:react-native-firebase:compileReleaseAidl FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':react-native-firebase:releaseCompileClasspath'.
> Could not find com.google.firebase:firebase-functions:11.6.0.
Searched in the following locations:
file:/Users/vsts/Library/Android/sdk/extras/m2repository/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.pom
file:/Users/vsts/Library/Android/sdk/extras/m2repository/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.jar
file:/Users/vsts/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.pom
file:/Users/vsts/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.jar
file:/Users/vsts/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.pom
file:/Users/vsts/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.jar
file:/Users/vsts/.m2/repository/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.pom
file:/Users/vsts/.m2/repository/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.jar
https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.pom
https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.jar
https://jcenter.bintray.com/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.pom
https://jcenter.bintray.com/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.jar
file:/Users/vsts/agent/2.140.0/work/1/s/node_modules/react-native/android/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.pom
file:/Users/vsts/agent/2.140.0/work/1/s/node_modules/react-native/android/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.jar
https://maven.google.com/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.pom
https://maven.google.com/com/google/firebase/firebase-functions/11.6.0/firebase-functions-11.6.0.jar
Required by:
project :react-native-firebase
android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1'
classpath 'io.fabric.tools:gradle:1.25.4'
classpath 'com.google.firebase:firebase-plugins:1.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.google.android.gms') {
details.useVersion '11.6.0'
}
if (requested.group == 'com.google.firebase') {
details.useVersion '11.6.0'
}
}
}
}
}
ext {
compileSdkVersion = 27
buildToolsVersion = '27.0.3'
}
subprojects { subproject ->
afterEvaluate{
if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion
// buildToolsVersion rootProject.ext.buildToolsVersion
lintOptions {
checkReleaseBuilds false
}
}
}
}
}
app/build.gradle
apply plugin: "com.android.application"
apply plugin: "io.fabric"
apply plugin: "com.google.firebase.firebase-perf"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
project.ext.envConfigFiles = [
debug : ".env",
staging: ".env",
release: ".env",
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
// buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
resValue "string", "build_config_package", "in.app"
applicationId "in.app"
minSdkVersion 19
targetSdkVersion 27
versionCode 5
versionName "2.1.5"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
if (project.hasProperty('RELEASE_STORE_FILE')) {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
debug {
buildConfigField "String", "CODE_PUSH_KEY", '""'
applicationIdSuffix ".debug"
versionNameSuffix '-DEBUG'
}
releaseStaging {
// initWith(buildTypes.release)
buildConfigField "String", "CODE_PUSH_KEY", ''
signingConfig signingConfigs.release
applicationIdSuffix ".staging"
}
release {
buildConfigField "String", "CODE_PUSH_KEY", ''
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def versionCodes = ["armeabi-v7a": 1, "x86": 2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation project(':react-native-firebase')
implementation 'com.google.firebase:firebase-functions:16.0.1'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.4#aar') { transitive = true }
implementation('com.crashlytics.sdk.android:crashlytics:2.9.4#aar') { transitive = true }
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-crash:11.8.0'
implementation 'com.google.firebase:firebase-perf:16.0.0'
api project(':react-native-vector-icons')
api project(':react-native-svg')
api project(':react-native-paytm')
api project(':react-native-image-resizer')
api project(':react-native-image-picker')
api project(':react-native-google-fit')
api project(':react-native-device-info')
api project(':react-native-config')
api project(':react-native-code-push')
api project(':react-native-razorpay')
api fileTree(include: ['*.jar'], dir: 'libs')
api 'com.android.support:appcompat-v7:26.0.1'
api 'com.facebook.react:react-native:+'
// From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all api dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.api
into 'libs'
}
apply plugin: 'com.google.gms.google-services'

Related

Error while Dexing when building Flutter project

I am currently trying to integrate Firebase Messaging into my project, I have set up a firebase project and successfully imported all of the other dependencies I need (crashlytics, firestore etc...)
however when I add the firebase messaging dependency to my pubspec.yaml I get an error when building. I am using the newest version of firebase_messaging and also the newest version of google services.
The Error:
Plugin project: firebase_core_web not found. Please update settings.gradle.
Invalid depfile: C:\Users\Owner\AndroidStudioProjects\switcheroo_ios\.dart_tool\flutter_build\d71b8b11f916190e0bd095c78ccf0a69\kernel_snapshot.d
Invalid depfile: C:\Users\Owner\AndroidStudioProjects\switcheroo_ios\.dart_tool\flutter_build\d71b8b11f916190e0bd095c78ccf0a69\kernel_snapshot.d
AGPBI: {"kind":"error","text":"Type com.google.firebase.iid.zzbb is referenced as an interface from `com.google.firebase.messaging.zzf`.","sources":[{}],"tool":"D8"}
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform artifact 'firebase-messaging.aar (com.google.firebase:firebase-messaging:20.0.1)' to match attributes {artifactType=android-dex, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=21}.
> Execution failed for DexingWithClasspathTransform: C:\Users\Owner\.gradle\caches\transforms-2\files-2.1\ac2c922e894bed89371853ed7d90bb4e\jetified-firebase-messaging-20.0.1\jars\classes.jar.
> Error while dexing.
App 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"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
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 "com.barbecu.switcherooIOS"
minSdkVersion 21
targetSdkVersion 28
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-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-crashlytics:17.0.1'
}
Project Gradle:
buildscript {
ext.kotlin_version = '1.3.50'
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.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.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
}
Try adding
implementation 'com.google.firebase:firebase-messaging:20.0.1'
inside dependencies
just try adding dependencies that r related to each platform explicitly like in android as above
for ios (im not sure about ios ecosystem) but adding this might help
pod 'Firebase/Messaging'
1.- In build.gradle (project level) use:
classpath 'com.google.gms:google-services:4.3.3' // Google Services plugin
2.- In build.gradle (app level) use:
minSdkVersion 21
3.- Replace settings.gradle content with the solution provided here:
Plugin project :firebase_core_web not found

Could not resolve com.google.firebase:firebase-messaging:[10.2.1, 12.1.0)

I want to share a problem that become a nightmare for me:
ERROR: Unable to resolve dependency for ':OnlineHeadBall2#debug/compileClasspath': Could not resolve com.google.firebase:firebase-messaging:[10.2.1, 12.1.0).
When I try to build my project, I get an error on console:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':appName:transformClassesAndResourcesWithR8ForRelease'.
> Could not resolve all task dependencies for configuration ':appName:releaseCompileClasspath'.
> Could not resolve com.google.firebase:firebase-messaging:[10.2.1, 12.1.0).
Required by:
project :appName > com.onesignal:OneSignal:3.10.9
> Failed to list versions for com.google.firebase:firebase-messaging.
> Could not list versions using M2 pattern 'https://raw.githubusercontent.com/HyprMXMobile/Android-SDKs/master/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://raw.githubusercontent.com/HyprMXMobile/Android-SDKs/master/com/google/firebase/firebase-messaging/'.
> Could not GET 'https://raw.githubusercontent.com/HyprMXMobile/Android-SDKs/master/com/google/firebase/firebase-messaging/'. Received status code 400 from server: Bad Request
> Failed to list versions for com.google.firebase:firebase-messaging.
> Unable to load Maven meta-data from https://s3.amazonaws.com/moat-sdk-builds/com/google/firebase/firebase-messaging/maven-metadata.xml.
> Could not get resource 'https://s3.amazonaws.com/moat-sdk-builds/com/google/firebase/firebase-messaging/maven-metadata.xml'.
> Could not GET 'https://s3.amazonaws.com/moat-sdk-builds/com/google/firebase/firebase-messaging/maven-metadata.xml'. Received status code 403 from server: Forbidden
> Could not resolve com.google.android.gms:play-services-location:[10.2.1, 12.1.0).
Required by:
project :appName > com.onesignal:OneSignal:3.10.9
> Failed to list versions for com.google.android.gms:play-services-location.
> Could not list versions using M2 pattern 'https://raw.githubusercontent.com/HyprMXMobile/Android-SDKs/master/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://raw.githubusercontent.com/HyprMXMobile/Android-SDKs/master/com/google/android/gms/play-services-location/'.
> Could not GET 'https://raw.githubusercontent.com/HyprMXMobile/Android-SDKs/master/com/google/android/gms/play-services-location/'. Received status code 400 from server: Bad Request
> Failed to list versions for com.google.android.gms:play-services-location.
> Unable to load Maven meta-data from https://s3.amazonaws.com/moat-sdk-builds/com/google/android/gms/play-services-location/maven-metadata.xml.
> Could not get resource 'https://s3.amazonaws.com/moat-sdk-builds/com/google/android/gms/play-services-location/maven-metadata.xml'.
> Could not GET 'https://s3.amazonaws.com/moat-sdk-builds/com/google/android/gms/play-services-location/maven-metadata.xml'. Received status code 403 from server: Forbidden
> Could not resolve com.google.android.gms:play-services-base:[10.2.1, 12.1.0).
Required by:
project :appName > com.onesignal:OneSignal:3.10.9
> Failed to list versions for com.google.android.gms:play-services-base.
> Could not list versions using M2 pattern 'https://raw.githubusercontent.com/HyprMXMobile/Android-SDKs/master/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://raw.githubusercontent.com/HyprMXMobile/Android-SDKs/master/com/google/android/gms/play-services-base/'.
> Could not GET 'https://raw.githubusercontent.com/HyprMXMobile/Android-SDKs/master/com/google/android/gms/play-services-base/'. Received status code 400 from server: Bad Request
> Failed to list versions for com.google.android.gms:play-services-base.
> Unable to load Maven meta-data from https://s3.amazonaws.com/moat-sdk-builds/com/google/android/gms/play-services-base/maven-metadata.xml.
> Could not get resource 'https://s3.amazonaws.com/moat-sdk-builds/com/google/android/gms/play-services-base/maven-metadata.xml'.
> Could not GET 'https://s3.amazonaws.com/moat-sdk-builds/com/google/android/gms/play-services-base/maven-metadata.xml'. Received status code 403 from server: Forbidden
* Try:
Run with --stacktrace option to get the stack trace. Run with --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
Error running command, return code: 1.
I feel that the suspicious in here is OneSignal. Therefore I apply the workaround in here to OneSignal, but my apk that I recently build is crash on starting. So the workaround does not work for me.
My general gradle file is below:
buildscript {
repositories {
google()
jcenter()
maven { url "https://maven.google.com" }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.31.2'
}
}
allprojects {
repositories {
google()
mavenLocal()
mavenCentral()
jcenter()
}
}
This is my app gradle file:
/** GENERATE CMAKEFILES.TXT FOR GAME CLASSES **/
file("../../Classes/cmake/CMakeLists.txt").withWriter("utf-8") { writer ->
writer.writeLine("\n# APP NAME AUTOGENERATED CMAKELISTS FILE, DO NOT DELETE #\n")
writer.writeLine("set(GAME_SOURCE")
project.fileTree("../../Classes").matching {
include "**/**.cpp"
include "**/**.c"
}.sort().forEach { file ->
writer.writeLine("\t${file.path}")
}
writer.writeLine(")\n\n")
writer.write("set(GAME_HEADER\n")
project.fileTree("../../Classes").matching {
include "**/**.hpp"
include "**/**.h"
}.sort().forEach { file ->
writer.writeLine("\t${file.path}")
}
writer.writeLine(")\n\n")
}
/*********************************************/
buildscript {
repositories {
google()
jcenter()
maven { url "https://maven.google.com" }
maven { url 'https://plugins.gradle.org/m2/'}//onesignal
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
//noinspection GradleDynamicVersion
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.company.appName"
minSdkVersion 15
targetSdkVersion 28
versionCode 111908
versionName "1.119"
multiDexEnabled true
manifestPlaceholders = [onesignal_app_id : "*****************************",
onesignal_google_project_number: "REMOTE"]
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
}
externalNativeBuild {
if(PROP_BUILD_TYPE == 'ndk-build') {
ndkBuild {
targets 'appName'
def module_paths = [project.file("../../cocos2d").absolutePath,
project.file("../../cocos2d/cocos").absolutePath,
project.file("../../cocos2d/external").absolutePath]
arguments 'NDK_TOOLCHAIN_VERSION=clang'
arguments 'APP_PLATFORM=android-' + PROP_TARGET_SDK_VERSION
arguments '-j' + Runtime.runtime.availableProcessors()
if (OperatingSystem.current().isWindows()) {
module_paths = module_paths.collect {it.replaceAll('\\\\', '/')}
arguments 'NDK_MODULE_PATH=' + module_paths.join(";")
} else {
arguments 'NDK_MODULE_PATH=' + module_paths.join(':')
}
}
} else if(PROP_BUILD_TYPE == 'cmake') {
cmake {
targets 'appName'
arguments "-DCMAKE_FIND_ROOT_PATH=", "-DANDROID_STL=c++_static", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_ARM_NEON=TRUE"
cppFlags "-frtti -fexceptions -fsigned-char"
}
}
}
}
dexOptions {
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
sourceSets.main {
java.srcDir "src"
res.srcDir "res"
jniLibs.srcDirs = ['jniLibs']
jni.srcDirs = []
manifest.srcFile "AndroidManifest.xml"
assets.srcDir "../../Resources"
}
externalNativeBuild {
if(PROP_BUILD_TYPE == 'ndk-build') {
ndkBuild {
path "jni/Android.mk"
}
} else if (PROP_BUILD_TYPE == 'cmake') {
cmake {
path "../../CMakeLists.txt"
}
}
}
signingConfigs {
release {
def userHomePath = System.properties['user.home']
def propertyFile = new File(userHomePath, ".gradle/gradle.properties") // Can be signing.properties as well
if (propertyFile.canRead()){
Properties props = new Properties()
props.load(new FileInputStream(propertyFile))
// Loading credentials from props
storeFile file(props['RELEASE_STORE_FILE'])
storePassword props['RELEASE_STORE_PASSWORD']
keyAlias props['RELEASE_KEY_ALIAS']
keyPassword props['RELEASE_KEY_PASSWORD']
}
}
}
useLibrary 'org.apache.http.legacy'
buildTypes {
release {
ext.alwaysUpdateBuildId = true
zipAlignEnabled false
debuggable false
jniDebuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
externalNativeBuild {
ndkBuild {
arguments 'NDK_DEBUG=0'
}
}
}
debug {
ext.alwaysUpdateBuildId = false // prevent fabric.io to generate id
debuggable true
jniDebuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
externalNativeBuild {
ndkBuild {
arguments 'NDK_DEBUG=1'
}
}
}
}
/*
// This is required for the gradle automation.
// Source https://medium.com/mindorks/how-did-i-automate-the-generation-of-release-apk-3e42b6540a4a
TLDR;
Also notice that I have added lintOptions which ignores errors at build time. This is needed for our automate script to work.
If lintOptions are not disabled, it gives the error belov
▸ org.xmlpull.v1.XmlPullParserException: expected: /meta read: HEAD (position:END_TAG </HEAD>#2:32 in java.io.InputStreamReader#4b80c948)
*/
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
repositories {
google()
jcenter()
mavenCentral()
flatDir {
dirs 'libs'
}
maven { url 'https://maven.google.com' }
maven { url 'https://maven.fabric.io/public' }
maven { url 'http://repo.admost.com:8081/artifactory/admost' }
//maven { url 'http://repo.admost.com:8081/artifactory/test-before-publish' }
maven { url 'https://raw.githubusercontent.com/HyprMXMobile/Android-SDKs/master' }
maven { url 'https://vungle.bintray.com/vungle-android-beta' }
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
maven { url "http://dl.appnext.com/" }
maven { url 'https://jitpack.io' }
maven { url 'https://dl.bintray.com/pubnative/maven' }
}
crashlytics {
enableNdk true
}
rootProject.allprojects.each(){
it.repositories {
flatDir dirs: (projectDir.absolutePath+'/libs')
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':libcocos2dx')
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.core:core:1.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.browser:browser:1.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.gms:play-services-plus:17.0.0'
implementation 'com.google.android.gms:play-services-games:17.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.android.gms:play-services-basement:17.1.1'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.firebase:firebase-analytics:17.2.3'
implementation 'com.google.firebase:firebase-messaging:20.1.0'
//'com.onesignal:OneSignal:[3.11.2, 3.99.99]'
implementation 'com.google.firebase:firebase-ads:19.0.0'
implementation 'com.google.firebase:firebase-config:19.1.1'
implementation 'com.adjust.sdk:adjust-android:4.16.0'
//noinspection GradleDynamicVersion
implementation 'com.facebook.android:facebook-android-sdk:5.+'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.onesignal:OneSignal:3.11.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.crashlytics.sdk.android:crashlytics-ndk:2.1.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.android.exoplayer:exoplayer:2.8.3'
implementation 'com.android.volley:volley:1.1.0'
implementation 'io.branch.sdk.android:library:2.19.5'
// AMR
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.admost.sdk:amr:2.0.7'
implementation 'com.admost.sdk:admost:0.0.6.a16'
implementation 'com.google.android.gms:play-services-base:17.1.0'
implementation 'com.google.android.gms:play-services-ads:17.2.1'
implementation 'com.admost.sdk:admob-gt-17.2.0-adapter:1.0.2.a16'
implementation 'com.admost.sdk:adcolony:4.1.2.a16'
implementation 'com.admost.sdk:chartboost:7.5.0.a16'
implementation 'com.admost.sdk:facebook:5.6.1.a16'
implementation 'com.admost.sdk:hyprmx-adapter:5.0.1.a16'
implementation 'com.hyprmx.android:HyprMX-SDK:5.0.1'
implementation 'com.admost.sdk:ironsource:6.13.0.1.a16'
implementation 'com.admost.sdk:mintegral:10.2.1.a16'
implementation 'com.admost.sdk:ogury:4.3.7.a16'
implementation 'net.pubnative:hybid.sdk:0.7.1'
implementation 'com.admost.sdk:pubnative-adapter:0.7.1.a16'
implementation 'com.admost.sdk:qumpara:0.3.3.a16'
implementation 'com.admost.sdk:tapjoy:12.4.2.a16'
implementation 'com.admost.sdk:unity:3.4.0.a16'
implementation 'com.vungle:publisher-sdk-android:6.5.1'
implementation 'com.admost.sdk:vungle-adapter:6.5.1.a16'
implementation name: 'mcprime', ext: 'aar'
implementation name: 'mcgoliath', ext: 'aar'
implementation (name:'ADTUnityAdsAdapter3.0.1',ext:'aar')
}
apply plugin: 'com.google.gms.google-services'
Gradle Wrapper Properties File:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
Do you have any idea to solve this issue? Please help me. Thank you for your time.
My teammate Erman solve this issue. I want to share with you the solution. I am going to share the gradle files that can be successfully build app. You should analyze differences between old and new ones.
main gradle
buildscript {
repositories {
google()
mavenLocal()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.31.2'
}
}
**app module gradle**
/** GENERATE CMAKEFILES.TXT FOR GAME CLASSES **/
file("../../Classes/cmake/CMakeLists.txt").withWriter("utf-8") { writer ->
writer.writeLine("\n# APP NAME AUTOGENERATED CMAKELISTS FILE, DO NOT DELETE #\n")
writer.writeLine("set(GAME_SOURCE")
project.fileTree("../../Classes").matching {
include "**/**.cpp"
include "**/**.c"
}.sort().forEach { file ->
writer.writeLine("\t${file.path}")
}
writer.writeLine(")\n\n")
writer.write("set(GAME_HEADER\n")
project.fileTree("../../Classes").matching {
include "**/**.hpp"
include "**/**.h"
}.sort().forEach { file ->
writer.writeLine("\t${file.path}")
}
writer.writeLine(")\n\n")
}
/*********************************************/
allprojects {
repositories {
google()
mavenLocal()
jcenter()
}
}
buildscript {
repositories {
google()
mavenLocal()
jcenter()
maven { url 'https://plugins.gradle.org/m2/'}//onesignal
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
//noinspection GradleDynamicVersion
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.4, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.company.appName"
minSdkVersion 16
targetSdkVersion 29
versionCode 111908
versionName "1.119"
multiDexEnabled true
manifestPlaceholders = [onesignal_app_id : "*************************",
onesignal_google_project_number: "REMOTE"]
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
}
externalNativeBuild {
if(PROP_BUILD_TYPE == 'ndk-build') {
ndkBuild {
targets 'appName'
def module_paths = [project.file("../../cocos2d").absolutePath,
project.file("../../cocos2d/cocos").absolutePath,
project.file("../../cocos2d/external").absolutePath]
arguments 'NDK_TOOLCHAIN_VERSION=clang'
arguments 'APP_PLATFORM=android-' + PROP_TARGET_SDK_VERSION
arguments '-j' + Runtime.runtime.availableProcessors()
if (OperatingSystem.current().isWindows()) {
module_paths = module_paths.collect {it.replaceAll('\\\\', '/')}
arguments 'NDK_MODULE_PATH=' + module_paths.join(";")
} else {
arguments 'NDK_MODULE_PATH=' + module_paths.join(':')
}
}
} else if(PROP_BUILD_TYPE == 'cmake') {
cmake {
targets 'appName'
arguments "-DCMAKE_FIND_ROOT_PATH=", "-DANDROID_STL=c++_static", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_ARM_NEON=TRUE"
cppFlags "-frtti -fexceptions -fsigned-char"
}
}
}
}
dexOptions {
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
sourceSets.main {
java.srcDir "src"
res.srcDir "res"
jniLibs.srcDirs = ['jniLibs']
jni.srcDirs = []
manifest.srcFile "AndroidManifest.xml"
assets.srcDir "../../Resources"
}
externalNativeBuild {
if(PROP_BUILD_TYPE == 'ndk-build') {
ndkBuild {
path "jni/Android.mk"
}
} else if (PROP_BUILD_TYPE == 'cmake') {
cmake {
path "../../CMakeLists.txt"
}
}
}
signingConfigs {
release {
def userHomePath = System.properties['user.home']
def propertyFile = new File(userHomePath, ".gradle/gradle.properties") // Can be signing.properties as well
if (propertyFile.canRead()){
Properties props = new Properties()
props.load(new FileInputStream(propertyFile))
// Loading credentials from props
storeFile file(props['RELEASE_STORE_FILE'])
storePassword props['RELEASE_STORE_PASSWORD']
keyAlias props['RELEASE_KEY_ALIAS']
keyPassword props['RELEASE_KEY_PASSWORD']
}
}
}
useLibrary 'org.apache.http.legacy'
buildTypes {
release {
ext.alwaysUpdateBuildId = true
zipAlignEnabled false
debuggable false
jniDebuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
externalNativeBuild {
ndkBuild {
arguments 'NDK_DEBUG=0'
}
}
}
debug {
ext.alwaysUpdateBuildId = false // prevent fabric.io to generate id
debuggable true
jniDebuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
externalNativeBuild {
ndkBuild {
arguments 'NDK_DEBUG=1'
}
}
}
}
/*
// This is required for the gradle automation.
// Source https://medium.com/mindorks/how-did-i-automate-the-generation-of-release-apk-3e42b6540a4a
TLDR;
Also notice that I have added lintOptions which ignores errors at build time. This is needed for our automate script to work.
If lintOptions are not disabled, it gives the error belov
▸ org.xmlpull.v1.XmlPullParserException: expected: /meta read: HEAD (position:END_TAG </HEAD>#2:32 in java.io.InputStreamReader#4b80c948)
*/
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
repositories {
google()
mavenLocal()
jcenter()
flatDir {
dirs 'libs'
}
maven { url 'https://maven.fabric.io/public' }
maven { url 'http://repo.admost.com:8081/artifactory/admost' }
//maven { url 'http://repo.admost.com:8081/artifactory/test-before-publish' }
//maven { url 'https://raw.githubusercontent.com/HyprMXMobile/Android-SDKs/master' }
maven { url 'https://vungle.bintray.com/vungle-android-beta' }
//maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
maven { url "http://dl.appnext.com/" }
maven { url 'https://jitpack.io' }
maven { url 'https://dl.bintray.com/pubnative/maven' }
}
crashlytics {
enableNdk true
}
rootProject.allprojects.each(){
it.repositories {
flatDir dirs: (projectDir.absolutePath+'/libs')
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':libcocos2dx')
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.core:core:1.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.browser:browser:1.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.gms:play-services-plus:17.0.0'
implementation 'com.google.android.gms:play-services-games:19.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.android.gms:play-services-basement:17.1.1'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-base:17.1.0'
implementation 'com.google.android.gms:play-services-ads:19.0.0'
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
implementation 'com.google.firebase:firebase-analytics:17.2.3'
implementation 'com.google.firebase:firebase-messaging:20.1.3'
//'com.onesignal:OneSignal:[3.11.2, 3.99.99]'
implementation 'com.google.firebase:firebase-ads:19.0.0'
implementation 'com.google.firebase:firebase-config:19.1.3'
implementation 'com.adjust.sdk:adjust-android:4.16.0'
//noinspection GradleDynamicVersion
implementation 'com.facebook.android:facebook-android-sdk:5.+'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.onesignal:OneSignal:[3.11.2, 3.99.99]'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.crashlytics.sdk.android:crashlytics-ndk:2.1.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.android.exoplayer:exoplayer:2.8.3'
implementation 'com.android.volley:volley:1.1.0'
implementation 'io.branch.sdk.android:library:2.19.5'
// AMR
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.admost.sdk:amr:2.0.7'
implementation 'com.admost.sdk:admost:0.0.6.a16'
implementation 'com.admost.sdk:admob-gt-17.2.0-adapter:1.0.2.a16'
implementation 'com.admost.sdk:adcolony:4.1.2.a16'
implementation 'com.admost.sdk:chartboost:7.5.0.a16'
implementation 'com.admost.sdk:facebook:5.6.1.a16'
//implementation 'com.admost.sdk:hyprmx-adapter:5.0.1.a16'
//implementation 'com.hyprmx.android:HyprMX-SDK:5.0.1'
implementation 'com.admost.sdk:ironsource:6.13.0.1.a16'
implementation 'com.admost.sdk:mintegral:10.2.1.a16'
implementation 'com.admost.sdk:ogury:4.3.7.a16'
implementation 'net.pubnative:hybid.sdk:0.7.1'
implementation 'com.admost.sdk:pubnative-adapter:0.7.1.a16'
implementation 'com.admost.sdk:qumpara:0.3.3.a16'
implementation 'com.admost.sdk:tapjoy:12.4.2.a16'
implementation 'com.admost.sdk:unity:3.4.0.a16'
implementation 'com.vungle:publisher-sdk-android:6.5.1'
implementation 'com.admost.sdk:vungle-adapter:6.5.1.a16'
implementation name: 'mcprime', ext: 'aar'
implementation name: 'mcgoliath', ext: 'aar'
implementation (name:'ADTUnityAdsAdapter3.0.1',ext:'aar')
}
apply plugin: 'com.google.gms.google-services'

Couldn't build my application with realm. throws error saying realm's constructor is not found in iOS and can't configure realm in android

Recently I changed my system and when I try to build my application in my new MacBook it doesn't builds with realm.
Two errors in android.
1) A problem occurred configuring project ':realm'.
compileSdkVersion is not specified.
2) A problem occurred evaluating project ':realm'.
Extension not initialized yet, couldn't access compileSdkVersion.
and in iOS it says it couldn't find the realm constructor.
I've already checked the compilesdk versions on the main gradle file and in the realm module's gradle file. they look fine.
{
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$projectDir/../../react-native/android"
}
}
}
apply plugin: 'com.android.library'
task forwardDebugPort(type: Exec) {
def adb = android.getAdbExe()?.toString() ?: 'false'
commandLine adb, 'forward', 'tcp:8083', 'tcp:8083'
ignoreExitValue true
doLast {
if (execResult.getExitValue() != 0) {
logger.error(
'===========================================================================\n' +
'WARNING: Failed to automatically forward port 8083.\n' +
'In order to use Realm in Chrome debugging mode, port 8083 must be forwarded\n' +
'from localhost to the device or emulator being used to run the application.\n' +
'You may need to add the appropriate flags to the command that failed:\n' +
' adb forward tcp:8083 tcp:8083\n' +
'===========================================================================\n'
)
}
}
}
android {
compileSdkVersion rootProject.hasProperty("compileSdkVersion") ? rootProject.compileSdkVersion : 28
buildToolsVersion rootProject.hasProperty("buildToolsVersion") ? rootProject.buildToolsVersion : "28.0.3"
defaultConfig {
minSdkVersion rootProject.hasProperty("minSdkVersion") ? rootProject.minSdkVersion : 16
targetSdkVersion rootProject.hasProperty("targetSdkVersion") ? rootProject.targetSdkVersion : 28
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn forwardDebugPort
}
}
def dependencyType = "implementation"
try {
project.getConfigurations().getByName("implementation")
} catch (UnknownConfigurationException e) {
dependencyType = "compile" // Pre 3.0 Android Gradle Plugin
}
project.dependencies {
add(dependencyType, fileTree(dir: 'libs', include: ['*.jar']))
add(dependencyType, 'org.nanohttpd:nanohttpd:2.2.0')
add(dependencyType, 'com.facebook.react:react-native:+')
}
}

Firebase Admin in backend module triggers "All firebase libraries must be either above or below 14.0.0

I have an android studio project that includes one module for my app and one module for my backend.
According to the documentation I can use the following code to bring all the build endpoint libraries to my app module:
endpointsServer project(path: ':backend', configuration: 'endpoints')
In my backend module gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.3'
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.5'
}
}
repositories {
jcenter(); }
apply plugin: 'java' apply plugin: 'war'
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
dependencies {
implementation 'com.google.endpoints:endpoints-framework:2.0.14'
implementation 'javax.servlet:servlet-api:2.5'
implementation 'javax.inject:javax.inject:1'
implementation 'com.google.firebase:firebase-admin:5.11.0'
}
appengine {
deploy {
stopPreviousVersion = false
promote = false
version = '1'
project = 'project-name'
} }
In my app module gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.cloud.tools.endpoints-framework-client'
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
jcenter()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
}
}
apply plugin: 'io.fabric'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "appID"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1"
multiDexEnabled = true
resConfigs "en", "fr"
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
debuggable false
}
debug {
signingConfig null
}
}
}
repositories {
flatDir {
dirs 'libs'
}
mavenCentral()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
implementation('com.crashlytics.sdk.android:crashlytics:2.9.2#aar') {
transitive = true;
}
implementation('com.firebaseui:firebase-ui-auth:3.3.1')
implementation 'com.google.firebase:firebase-core:15.0.2'
endpointsServer project(path: ':backend', configuration: 'endpoints')
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.api-client:google-api-client-android:1.23.0'
implementation 'com.google.http-client:google-http-client-android:1.23.0'
implementation 'com.google.http-client:google-http-client-gson:1.23.0'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.google.android.gms:play-services-gcm:15.0.0'
implementation 'com.google.firebase:firebase-auth:15.1.0'
implementation 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.8.5'
testImplementation 'junit:junit:4.12'
}
configurations {
all {
exclude module: 'httpclient'
}
}
apply plugin: 'com.google.gms.google-services'
The problem is that when gradle is executing is causing the following error:
All firebase libraries must be either above or below 14.0.0
I have already looked at:
How to add firebase-admin to my android project?
and
android firebase admin sdk error 'All firebase libraries must be either above or below 14.0.0' [duplicate]
But both of them are trying to add the admin sdk on client side. Which is not why I am trying to do.
So how can I tell gradle that this are two different modules or how can I exclude the admin sdk from coming to my app module when I am using:
endpointsServer project(path: ':backend', configuration: 'endpoints')

java.lang.NoSuchFieldError: No static field zzakj of type Lcom/google/android/gms/common/ConnectionResult

I follow the steps in the google developers, and I can run the sign-in demo.
Add the dependency to your project-level build.gradle
classpath 'com.google.gms:google-services:3.0.0'
Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
In your app-level build.gradle file, declare Google Play Services as a dependency:
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.google.android.gms:play-services-auth:9.8.0'
}
Here's my project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here's my app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "net.kdapp.partygor"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
jniDebuggable false
//signingConfig signingConfigs.cic
renderscriptDebuggable false
}
debug {
debuggable true
jniDebuggable true
renderscriptDebuggable true
//signingConfig signingConfigs.cic
minifyEnabled true
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// 日曆視圖自定義 view
// 雙向 seekBar
// 輪播圖
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.ashokvarma.android:bottom-navigation-bar:1.3.0'
compile 'com.daimajia.slider:library:1.1.5#aar'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.zhy:okhttputils:2.6.2'
compile 'com.prolificinteractive:material-calendarview:1.4.3'
compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'
compile 'com.youth.banner:banner:1.4.9'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
// Dependency for Google Sign-In
compile 'com.google.android.gms:play-services-auth:11.0.1'
testCompile 'junit:junit:4.12'
compile project(':redpacketlibrary')
compile project(':easeui')
compile project(path: ':pickerview')
compile files('libs/parse-android-1.13.0.jar')
compile files('libs/android-support-multidex.jar')
}
apply plugin: 'com.google.gms.google-services'
But when I run my project, I get this error.
08-04 09:34:45.420 22456-22456/net.kdapp.partygor E/AndroidRuntime: FATAL EXCEPTION: main
Process: net.kdapp.partygor, PID: 22456
java.lang.NoSuchFieldError: No static field zzazX of type Lcom/google/android/gms/common/ConnectionResult; in class Lcom/google/android/gms/common/ConnectionResult; or its superclasses (declaration of 'com.google.android.gms.common.ConnectionResult' appears in /data/data/net.kdapp.partygor/files/instant-run/dex/slice-google-play-services_78c2c5fe145c1c95c9696f0679d986433b0c2b89-classes.dex)
at com.google.android.gms.common.internal.zzo.zzrj(Unknown Source)
at com.google.android.gms.common.internal.zze.zzs(Unknown Source)
at com.google.android.gms.common.internal.zzi.zzrk(Unknown Source)
at com.google.android.gms.common.internal.zzh.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5877)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1019)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:814)
I search in google many times and change the google-services api version, but it still didn't work.

Resources