I have a project where i use Google Cloud Speech, and Firebase RealTime Database, and also as the project evolved i would like to add Google FireStore functionallity. But after I compile the dependency i have a RunTime error:
Error:(458, 21) error: no suitable method found for
intercept(GoogleCredentialsInterceptor)
method zzbc.intercept(List<zzl>) is not applicable
(argument mismatch; GoogleCredentialsInterceptor cannot be converted to List<zzl>)
method zzbc.intercept(zzl...) is not applicable
(varargs mismatch; GoogleCredentialsInterceptor cannot be converted to zzl)
method AbstractManagedChannelImplBuilder.intercept(List<zzl>) is not applicable
(argument mismatch; GoogleCredentialsInterceptor cannot be converted to List<zzl>)
method AbstractManagedChannelImplBuilder.intercept(zzl...) is not applicable
(varargs mismatch; GoogleCredentialsInterceptor cannot be converted to zzl)
This error occurs when i try to get the credentials from GCS.
#Override
protected void onPostExecute(AccessToken accessToken) {
mAccessTokenTask = null;
final ManagedChannel channel = new OkHttpChannelProvider()
.builderForAddress(HOSTNAME, PORT)
.nameResolverFactory(new DnsNameResolverProvider())
.intercept(new GoogleCredentialsInterceptor(new GoogleCredentials(accessToken)
.createScoped(SCOPE)))
.build();
mApi = SpeechGrpc.newStub(channel);
// Schedule access token refresh before it expires
if (mHandler != null) {
mHandler.postDelayed(mFetchAccessTokenRunnable,
Math.max(accessToken.getExpirationTime().getTime()
- System.currentTimeMillis()
- ACCESS_TOKEN_FETCH_MARGIN, ACCESS_TOKEN_EXPIRATION_TOLERANCE));
}
}
}
The code is crashing at this part of code:
.intercept(new GoogleCredentialsInterceptor(new GoogleCredentials(accessToken).createScoped(SCOPE)))
My dependencies:
ext {
//FirebaseUI Version Firebase/Play Services Version
// 3.1.0 11.4.2
supportLibraryVersion = '27.0.0'
grpcVersion = '1.7.0'
googlePlayVersion = '11.4.2'
firebaseVersion = '11.4.2'
fireUIVersion = '3.1.0'
facebookVersion = '4.27.0'
glideVersion = '4.3.0'
}
...
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "io.grpc:grpc-okhttp:$grpcVersion"
compile "io.grpc:grpc-protobuf-lite:$grpcVersion"
compile "io.grpc:grpc-stub:$grpcVersion"
compile('com.google.auth:google-auth-library-oauth2-http:0.7.1') {
exclude module: 'httpclient'
}
// Support Libraries:
compile "com.android.support:appcompat-v7:$supportLibraryVersion"
compile "com.android.support:preference-v7:$supportLibraryVersion"
compile "com.android.support:design:$supportLibraryVersion"
compile "com.android.support:cardview-v7:$supportLibraryVersion"
compile "com.android.support:preference-v7:$supportLibraryVersion"
compile "com.google.android.gms:play-services-auth:$firebaseVersion"
// FirebaseUI for Firebase Auth
compile "com.google.android.gms:play-services-auth:$googlePlayVersion"
compile "com.google.firebase:firebase-database:$firebaseVersion"
compile "com.google.firebase:firebase-auth:$firebaseVersion"
compile "com.google.firebase:firebase-core:$firebaseVersion"
compile "com.google.firebase:firebase-firestore:$firebaseVersion"
compile "com.android.support:recyclerview-v7:$supportLibraryVersion"
compile "com.android.support:support-v4:$supportLibraryVersion"
compile 'com.firebaseui:firebase-ui-auth:3.1.0'
compile 'com.android.support.constraint:constraint-layout-solver:1.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'javax.annotation:javax.annotation-api:1.2'
apply plugin: 'com.google.gms.google-services'
The project level :
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
classpath 'com.android.tools.build:gradle:3.1.0-alpha01'
classpath 'com.google.gms:google-services:3.1.1'
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
maven { url "https://jitpack.io" }
maven {
url "http://dl.bintray.com/ahmedrizwan/maven"
}
maven {
url "http://dl.bintray.com/glomadrian/maven"
}
mavenCentral()
}
}
If i remove the:
// TRYED WITH compile 'com.google.firebase:firebase-firestore:11.4.2'
compile 'com.firebaseui:firebase-ui-auth:3.1.0'
All works great! But i need it for Firestore functionallity.
I have all API enabled, And Google Cloud Data Storage disabled.
Cloud Firestore and App Engine: You can't use both Cloud Firestore and Cloud Datastore in the same project, which might affect apps using App Engine. Try using Cloud Firestore with a different project.
Sorry you're encountering this, but Firestore is not (currently) compatible with an external gRPC, as answered here:
Cloud Firestore with gRPC build error
The 11.8.0 release fixes this.
Related
I wanna use the FolioReader-Android library in my Android Studio.
I implement the library on my Gradle and when I want to run the project there is an unknown error:
*
/Users/hamid/.gradle/caches/transforms-2/files-2.1/1ef74cdf85927d9b084bf9bd34edc7d8/folioreader-0.5.4/res/layout/progress_dialog.xml:13:
AAPT: error: resource android:attr/android:progressBarStyle not found.
What's the problem?
In your gradle dependencies try adding this
implementation "com.folioreader:folioreader:0.5.4"
implementation 'com.android.support:multidex:1.0.3' // ( for androidx)
configurations.matching { it.name == '_internal_aapt2_binary' }.all {
config ->
config.resolutionStrategy.eachDependency {
details -> details.useVersion("3.3.2-5309881")
}
}
`
Yesterday my app was building correctly and today without changing anything I'm not able to build anymore, I'm getting this error:
Android dependency 'com.google.android.gms:play-services-stats' has >different version for the compile (16.0.1) and runtime (17.0.0) >classpath. You should manually set the same version via >DependencyResolution
I tried to bypass this with "com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true" and clean the project many times, but the error is still here.
My app/build.gradle file :
apply plugin: "com.android.application"
apply plugin: "com.android.application"
apply plugin: "io.fabric"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
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 {
applicationId "com.yapero"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled true
versionCode 743
versionName "1.74"
ndk {
abiFilters "armeabi-v7a", "x86"
}
versionNameSuffix '3'
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
packagingOptions {
exclude 'META-INF/main.kotlin_module'
exclude 'META-INF/-no-jdk.kotlin_module'
}
dexOptions {
javaMaxHeapSize "4g"
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3]
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(':#segment_analytics-react-native')
implementation project(':react-native-webview')
implementation project(':react-native-version-check')
implementation project(':react-native-firebase')
implementation(project(':react-native-firebase')) {
transitive = false
}
implementation('com.crashlytics.sdk.android:crashlytics:2.9.5#aar') {transitive = true}
//implementation project(':react-native-version-check')
implementation project(':react-native-maps')
implementation project(':react-native-intercom')
implementation 'io.intercom.android:intercom-sdk-base:5.+'
implementation 'io.intercom.android:intercom-sdk-fcm:5.+'
implementation project(':react-native-fbsdk')
implementation project(':react-native-device-info')
implementation project(':react-native-appsflyer')
implementation project(':react-native-text-input-reset')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-fast-image')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:16.0.8"
implementation "com.google.firebase:firebase-auth:16.2.1"
implementation "com.google.firebase:firebase-firestore:17.1.5"
implementation "com.google.firebase:firebase-messaging:17.5.0"
implementation 'me.leolin:ShortcutBadger:1.1.21#aar'
implementation 'com.android.support:multidex:1.0.0'
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
My build.gradle:
buildscript {
ext {
buildToolsVersion = "28.0.2"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.25.4'
// 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"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.7'
distributionUrl = distributionUrl.replace("bin", "all")
}
Does someone know how to correct or bypass this version check ? Ask me if you need more informations.
This comment on github provides the answer to your question (and mine):
A dependency (react-native-device-info in this case) was using the latest version of one of its dependencies instead of a fixed/pinned version. When a new version of google services was released yesterday, it caused the build to pull in the new version for device-info, thereby causing the conflict with other dependencies that correctly pin the version they need.
The solution is to do what is explained in the linked post in your android/app/build.gradle:
implementation(project(":react-native-device-info"), {
exclude group: "com.google.android.gms"
})
implementation "com.google.android.gms:play-services-gcm:16.0.0"
and possibly replace react-native-device-info with any other dependency that may have the same problem (they would include a line like implementation "com.google.android.gms:play-services-gcm:+" which depends on whatever is the latest version of google gcm).
Add in the file: android/app/build.gradle
android {
...
dependencies {
implementation 'com.google.android.gms:play-services-maps:17.0.0'
}
I'm new to Gradle.
When I run the build, instead of copying specific dependencies to specific directories, the build adds both compile and testCompile dependencies to src/test/resources.
I would like to be able to copy only test compile dependencies to src/test/resources and all other dependencies to main/src/resources.
Thank you
apply plugin: 'java'
apply plugin: 'war'
String spring_version = "3.1.2.RELEASE#jar" ;
String spring_sec_version = "3.1.2.RELEASE#jar" ;
String hibernate_version = "4.1.7.Final#jar" ;
repositories {
mavenCentral()
}
// "org.springframework:spring-oxm:"+spring_version,
List spring = [
"org.springframework:spring-context:"+spring_version,
"org.springframework:spring-beans:"+spring_version,
"org.springframework:spring-core:"+spring_version,
"org.springframework:spring-aop:"+spring_version,
"org.springframework:spring-expression:"+spring_version,
"org.springframework:spring-jdbc:"+spring_version,
"org.springframework:spring-tx:"+spring_version,
"org.springframework:spring-web:"+spring_version,
"org.springframework:spring-webmvc:"+spring_version,
"org.springframework:spring-orm:"+spring_version,
"org.springframework:spring-asm:"+spring_version
]
List spring_security = [
"org.springframework.security:spring-security core:"+spring_sec_version,
"org.springframework.security:spring-security-config:"+spring_sec_version,
"org.springframework.security:spring-security-web:"+spring_sec_version
]
List spring_aop = [
"aopalliance:aopalliance:1.0#jar",
"cglib:cglib-nodep:2.2.2#jar"
]
List validation_lib = [
"org.hibernate:hibernate-validator:4.3.0.Final#jar",
"javax.validation:validation-api:1.0.0.GA#jar"
]
List log_lib = [
"org.jboss.logging:jboss-logging:3.1.2.GA#jar",
"org.slf4j:slf4j-api:1.6.6#jar",
"org.slf4j:slf4j-jdk14:1.6.6#jar",
"org.slf4j:log4j-over-slf4j:1.6.6#jar",
"org.slf4j:jcl-over-slf4j:1.6.6#jar",
"log4j:log4j:1.2.17#jar"
]
List hibernate_api = [
"org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final#jar"
]
List hibernate = [
"org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:1.0.1.Final#jar",
"org.hibernate.common:hibernate-commons-annotations:4.0.1.Final#jar",
"org.javassist:javassist:3.16.1-GA",
"org.hibernate:hibernate-entitymanager:"+hibernate_version,
"org.hibernate:hibernate-core:"+hibernate_version
]
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.10'
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.10.19'
compile hibernate_api
compile hibernate
compile spring
compile spring_security
compile spring_aop
compile "org.codehaus.jackson:jackson-jaxrs:1.9.9" //lib jackson for JSON
compile validation_lib
compile log_lib
runtime "postgresql:postgresql:9.1-901.jdbc4#jar"
compile "rhino:js:1.7R2#jar"
}
task copyDependencies(type: Copy) {
from (configurations.compile)
into "src/main/resources"
}
task copyTestDependencies(type: Copy) {
from (configurations.testCompile)
into "src/test/resources"
}
build.dependsOn(copyDependencies)
build.dependsOn(copyTestDependencies)
Two things before answering:
The Gradle configurations compile and testCompile should be replaced with implementation and testImplementation. See documentation for details. My answer will use these instead.
Gradle has a great work avoidance approach, which is based on inputs / outputs computation. Copying anything into directories that are inputs of tasks, such as the resources directories, will mess that up. You really should avoid doing that and instead create new directories that are properly wired to be used where needed.
The problem you have is that testImplementation extends implementation and thus you will collect both runtime and test dependencies into the location for test dependencies.
The easiest path is to create a custom configuration for your tests dependencies so that you can access them independently of the runtime ones:
configurations {
testDependencies
testImplementations {
extendsFrom testDependencies
}
}
dependencies {
testDependencies group: 'junit', name: 'junit', version: '4.10'
// And others
}
And then you would copy the contents of testDependencies.
The one downside with this approach is that resolution of testDependencies will not be influenced by the runtime dependencies. This could be a problem but is context sensitive.
The other option is to filter runtime dependencies when copying the test ones. That solution is required if you realise that runtime dependencies impact the version of test dependencies.
I am trying to split my ANTLR4 grammar in multiple files so i can test them more easily, i am using gradle as a build tool in a java project.
Both grammar compile correctly by separate but when i add the import to my main grammar i get the next compilation error
error(110): kanekotic/specflow/rider/SpecflowFeature.g4:3:7: can't find or load grammar SpecflowScenario
the inherited grammar looks like:
grammar SpecflowScenario;
#header {
package kanekotic.specflow.rider;
}
scenario
: 'Scenario: ';
and the main grammar looks like:
grammar SpecflowFeature;
import SpecflowScenario;
#header {
package kanekotic.specflow.rider;
}
file returns [List<String> values]
#init { $values = new ArrayList<String>(); }
: 'Feature: ' EOF;
What am i doing wrong? is this not allowed?
edit:
the gradle.build looks like:
plugins {
id "org.jetbrains.intellij" version "0.1.10"
}
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'java'
apply plugin: 'antlr'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
intellij {
version '143.2370.31'
pluginName 'Specflow Rider'
}
group 'kanekotic.specflow.rider'
version '0.1'
repositories {
mavenCentral()
jcenter()
}
dependencies {
antlr "org.antlr:antlr4:4.5"
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:2.+"
}
all the code as it is open sourced is in this next link: https://github.com/kanekotic/Specflow.Rider/tree/antlr4_multiple_grammar
The Antlr plugin uses src/main/antlr as lib directory by default. As the grammar file to include is in kanekotic/specflow/rider, use the following code in your gradle file to include this location:
generateGrammarSource {
arguments << "-lib" << "src/main/antlr/kanekotic/specflow/rider"
}
See also this gradle thread.
I am still trying to get my gradle script work, I have expolered all logs and it seems that there are some classes are missing. Here is message.
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':horizontalrecyclerview'.
Caused by: java.lang.NoClassDefFoundError: org/gradle/api/publication/maven/internal/DefaultMavenFactory
at org.gradle.api.plugins.AndroidMavenPlugin.apply(AndroidMavenPlugin.java:88)
at org.gradle.api.plugins.AndroidMavenPlugin.apply(AndroidMavenPlugin.java:57)
at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(Imper
Caused by: java.lang.ClassNotFoundException: org.gradle.api.publication.maven.internal.DefaultMavenFactory
... 51 more
Here is my build.gradle.
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
version = "1.0.0"
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
def siteUrl = 'https://github.com/CROSP/AndroidHorizontalRecyclerView' // Homepage URL of the library
def gitUrl = 'https://github.com/CROSP/AndroidHorizontalRecyclerView.git' // Git repository URL
group = "com.github.crosp.horizontalrecyclerview" // Maven Group ID for the artifact
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.jsoup:jsoup:1.8.1'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:recyclerview-v7:21.0.3'
}
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
// Add your description here
name 'Android Horizontal Recycler View with Headerr'
description = 'Android Horizontal Recycler View with Header project for displaying horizontal list on Android '
url siteUrl
// Set your license
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'crosp'
name 'Alexandr Crospenko'
email 'crosp#xakep.ru'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
// https://github.com/bintray/gradle-bintray-plugin
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
// it is the name that appears in bintray when logged
name = "crosp"
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
version {
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password") //Optional. The passphrase for GPG signing'
}
// mavenCentralSync {
// sync = true //Optional (true by default). Determines whether to sync the version to Maven Central.
// user = properties.getProperty("bintray.oss.user") //OSS user token
// password = properties.getProperty("bintray.oss.password") //OSS user password
// close = '1' //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
// }
}
}
}
Maybe someone already had such problem or know the way to solve it ? Please help, because I cannot get it work whole day already.
Thx in advance.
I am doing the same thing (upload my aar to bintray) and I have the same problem.
I am aware that it is occurred in gradle library, so I change my gradle verion from 2.4.0 to 2.2.1 by this way
File -> Project Structure (or trigger hotkey command + ;) -> click the Project in the left list in the dialog -> input 2.2.1 in the Gradle textedit box.
I solve this error by this way.Look for the note part in file README.md.
Hope this can help you.
ps:If you want to use gradle 2.4.0, you should config android-maven-plugin version to 1.3 in classpath in the project root build.gradle as :
com.github.dcendents:android-maven-gradle-plugin:1.3