The gradle build completes successfully , but while running the application or trying to build the apk I am getting an error:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't write [F:\TravEz\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\hp.gradle\caches\transforms-1\files-1.1\support-core-ui-27.1.0.aar\51b8cdc0bcfc98652d9ae95f70697b30\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/design/widget/CoordinatorLayout$Behavior.class]))
I have tried all the methods mentioned here
Here is my project level gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io"}
//Glomadrian maven for animated switch
maven { url "https://dl.bintray.com/glomadrian/maven"}
maven { url "http://dl.bintray.com/lukaville/maven"}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is my app level gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.travez.travez"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
compile 'com.github.florent37:materialtextfield:1.0.7'
//library for cardview
implementation 'com.android.support:cardview-v7:26.1.0'
//library for dialog box
implementation 'com.github.d-max:spots-dialog:0.7#aar'
//library for animated switch
implementation 'com.github.glomadrian:MaterialAnimatedSwitch:1.1#aar'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
//Firebase authentication library
implementation 'com.google.firebase:firebase-auth:11.0.4'
//Firebase database library
implementation 'com.google.firebase:firebase-database:11.0.4'
//Google play services and maps libraries
implementation 'com.google.android.gms:play-services-maps:11.0.4'
implementation 'com.google.android.gms:play-services:11.0.4'
implementation 'com.google.android.gms:play-services-location:11.0.4'
//Geofire library
compile 'com.firebase:geofire-android:2.3.0'
//Runtime perission library
compile 'com.github.karanchuri:PermissionManager:0.1.0'
//Material Edit Text library
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
//Calligraphy library
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
// CircleView library
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'id.zelory:compressor:2.1.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
compile 'com.android.support:multidex:1.0.0'
compile 'com.nbsp:library:1.8'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
Is written twice, remove one of them.
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
Replace the + with the current version of the library
The problem is because you have duplicated support library in your dependencies.
android-image-cropper is using support library 27+, you can check its build.gradle. MaterialEditText is using support library 22.2.0. Material Animated Switch is using support library 22.2.0. You need to exlude the support libraries from them.
So, instead using the following:
compile 'com.github.florent37:materialtextfield:1.0.7'
implementation 'com.github.glomadrian:MaterialAnimatedSwitch:1.1#aar'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
use the following:
implementation 'com.android.support:support-annotations:26.1.0'
implementation ('com.github.florent37:materialtextfield:1.0.7') {
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
exclude module: 'support-annotations'
}
implementation ('com.github.glomadrian:MaterialAnimatedSwitch:1.1#aar') {
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
}
implementation ('com.theartofdev.edmodo:android-image-cropper:2.6.0') {
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
}
You can check the dependencies tree if you still found the conflicted libraries with:
./gradlew app:dependencies
Related
I am attempting to install the Google Maps SDK and decided to use the current beta version. I have followed all the installation instructions, but am getting the following error when rebuilding the project.
Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find :places-maps-sdk-3.1.0-beta:.
Required by:
project :app
The installation downloaded file places-maps-sdk-3.1.0-beta.aar has been placed in the projects app\libs folder.
[![enter image description here][1]][1]
Attached is my project level gradle build
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.grgapps.checkingin"
minSdkVersion 26
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
customDebugType {
debuggable true
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment:2.3.1'
implementation 'androidx.navigation:navigation-ui:2.3.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.gms:play-services-ads:19.5.0'
implementation 'com.google.firebase:firebase-ads:19.5.0'
implementation 'androidx.work:work-runtime:2.5.0-beta01'
implementation 'androidx.preference:preference:1.1.1'
//implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "androidx.viewpager2:viewpager2:1.0.0"
implementation 'com.google.firebase:firebase-analytics:18.0.0'
implementation "com.google.firebase:firebase-messaging:21.0.0"
implementation 'com.google.android.libraries.maps:maps:3.1.0-beta'
// If you are using Places, add all of the dependencies below
implementation name:'places-maps-sdk-3.1.0-beta', ext:'aar'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
implementation 'com.google.auto.value:auto-value-annotations:1.6.5'
implementation 'com.google.maps.android:android-maps-utils-v3:2.2.0'
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation('com.mikepenz:materialdrawer:5.9.5#aar') {
transitive = true
exclude group: 'com.android.support'
}
// Room components
implementation "androidx.room:room-runtime:2.2.5"
annotationProcessor "androidx.room:room-compiler:2.2.5"
androidTestImplementation "androidx.room:room-testing:2.2.5"
// Lifecycle components
implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.archLifecycleVersion"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$rootProject.archLifecycleVersion"
// UI
implementation "com.google.android.material:material:1.2.1"
// Testing
androidTestImplementation "androidx.arch.core:core-testing:$rootProject.coreTestingVersion"
}
The following is my top level build gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
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
}
ext {
roomVersion = '2.2.5'
archLifecycleVersion = '2.2.0-rc03'
coreTestingVersion = '2.1.0'
materialVersion = '1.2.1'
}
I found that instead of using the line they have in their documentation for the build.gradle file:
implementation name:'places-maps-sdk-3.1.0-beta', ext:'aar'
If I use this line, it syncs up fine:
implementation group: 'com.google.android.libraries.maps', name: 'maps', version: '3.1.0-beta'
I am FAR from a Gradle expert, so I am not quite sure what the differences here are - but after changing over imports and all, my app built and seemed to operate fine.
I have an Android (Java) project and after migrating to AndroidX I have received the following error (d8 errors):
Program type already present: com.enterprisedt.BaseIOException
Note that gradle synchronization occurs normally. This error appears only at compile time for the device. And the weirdest thing, it only happens when I'm compiling for an Android 4 device.
When trying to compile for Android 5+, the compilation succeeds and the app runs smoothly.
build.gradle
[...]
compileSdkVersion 28
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0.0"
applicationId "br.com.example"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
}
dependencies {
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.android.support', module: 'support-annotations'
all*.exclude group: 'com.android.support', module: 'appcompat-v7'
all*.exclude group: 'com.android.support', module: 'support-v13'
}
implementation project(':mylib')
// These 3 libraries are required for the project.
implementation files("libs/activation.jar")
implementation files("libs/mail.jar")
implementation files("libs/edtftpj.jar")
implementation files("libs/commons-net-3.0.1.jar")
implementation files("libs/commons-validator-1.4.0.jar")
implementation files("libs/itextpdf-5.4.0.jar")
implementation('com.appsee:appsee-android:2.3.3#aar') {
transitive = true
}
implementation('com.optimizely:optimizely:1.4.2#aar') {
transitive = true
}
implementation('io.fabric.sdk.android:fabric:1.4.8#aar') {
transitive = true
}
implementation('com.crashlytics.sdk.android:crashlytics:2.10.1#aar') {
transitive = true
}
implementation "com.onesignal:OneSignal:$oneSignalVersion"
implementation "androidx.percentlayout:percentlayout:$percentLayoutVersion"
implementation "androidx.legacy:legacy-support-v4:$legacyVersion"
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation "androidx.recyclerview:recyclerview:$recyclerViewVersion"
implementation "androidx.annotation:annotation:$androidxAppCompatVersion"
implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.guava:guava-collections:r03'
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation "com.google.android.material:material:$materialVersion"
implementation "com.google.android.gms:play-services-maps:$gmsVersion"
implementation "com.google.android.gms:play-services-analytics:$gmsVersion"
implementation 'com.google.dagger:dagger:2.24'
annotationProcessor 'com.google.dagger:dagger-compiler:2.24'
implementation 'com.squareup:otto:1.3.8'
implementation 'org.jetbrains:annotations:17.0.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'com.squareup.picasso:picasso:2.71828', {
exclude group: 'com.android.support', module: 'support-annotations'
}
implementation 'com.lapism:searchview:4.0'
implementation 'com.sromku:simple-storage:1.2.0'
implementation 'me.dm7.barcodescanner:zxing:1.9.8', {
exclude group: 'com.android.support', module: 'appcompat-v7'
}
implementation 'com.nononsenseapps:filepicker:2.5.2'
implementation 'io.github.yavski:fab-speed-dial:1.0.6'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.1'
implementation 'com.github.arimorty:floatingsearchview:2.1.1'
implementation 'net.i2p.android.ext:floatingactionbutton:1.10.1'
implementation 'org.zakariya.stickyheaders:stickyheaders:0.7.11'
implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'
implementation 'com.prolificinteractive:material-calendarview:1.4.3'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0', {
exclude group: 'com.android.support', module: 'appcompat-v7'
}
// debug
debugImplementation 'com.facebook.stetho:stetho:1.5.1'
debugImplementation 'com.gu.android:toolargetool:0.1.5#aar'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-all:1.10.19'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02', {
exclude group: 'com.android.support', module: 'support-annotations'
}
}
[...]
build.gradle (project)
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://maven.google.com' }
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.5'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
classpath 'io.fabric.tools:gradle:1.31.1'
classpath 'com.google.gms:google-services:4.3.2'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://www.jitpack.io" }
maven { url 'http://dl.bintray.com/optimizely/optimizely' }
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://maven.google.com' }
maven { url "https://oss.sonatype.org/content/repositories/snapshots"}
maven { url 'https://dl.bintray.com/guardian/android' }
}
}
build.gradle (local lib: "mylib")
[...]
compileSdkVersion 28
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
}
[...]
dependencies {
// here, I repeat those 3 libraries mentioned (activation, mail, edtftpj)
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.browser:browser:1.0.0'
implementation "com.google.android.gms:play-services-location:17.0.0"
implementation "com.google.android.gms:play-services-maps:17.0.0"
implementation "com.google.android.gms:play-services-analytics:17.0.0"
implementation "com.google.android.material:material:1.0.0"
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "androidx.annotation:annotation:1.1.0"
implementation "androidx.cardview:cardview:1.0.0"
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
api 'br.com.concretesolutions:canarinho:1.1.0'
api 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
}
gradle.properties
org.gradle.jvmargs=-Xmx2048M
org.gradle.configureondemand=false
android.enableJetifier=true
android.useAndroidX=true
The 3 libraries I mentioned (activation, mail, edtftpj) need to be in both lib and project, because it is actually used.
This I already tried:
./gradlew clean
Android Studio -> File -> invalidate cache and restart
Android Studio -> Build -> Clean Project
Remove one of the duplicate libraries (this generated another error because I use the library tools in both modules)
Add the following code to build.gradle:
packagingOptions {
exclude 'com/sun/mail/dsn/mailcap'
exclude 'dsn.mf'
exclude 'javamail.charset.map'
exclude 'javamail.default.address.map'
exclude 'javamail.default.providers'
exclude 'javamail.imap.provider'
exclude 'javamail.pop3.provider'
exclude 'javamail.smtp.address.map'
exclude 'javamail.smtp.provider'
exclude 'mailcap'
exclude 'mimetypes.default'
exclude 'mailcap.default'
exclude 'com.enterprisedt.BaseIOException'
exclude 'javax.activation.*'
}
Can anybody help me ?
After Updating my gradle-version to 3.3.1 and my google-services-version to 4.2.0, I'm getting the following error while building:
Error:Internal error:
org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.10.1-all.zip'.
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:51)
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:41)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
My build-gradle-project-file looks like this:
buildscript {
repositories {
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.2.0'
// 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
}
My build-module-gradle-file looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
aaptOptions {
additionalParameters '--utf16'
}
defaultConfig {
applicationId "XXX.XXXX.XXX"
minSdkVersion 15
targetSdkVersion 26
versionCode 140
versionName "14.5"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
jumboMode = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation files('libs/amazon-mobile-associates-1.0.73.0.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:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation "com.android.support:customtabs:28.0.0"
implementation 'com.androidadvance:topsnackbar:1.1.1'
implementation 'com.yuyakaido.android:card-stack-view:1.0.0-beta5'
implementation 'com.roughike:bottom-bar:2.3.1'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.android.gms:play-services-ads:17.1.3'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.android.gms:play-services-places:16.0.0'
implementation 'com.google.android.gms:play-services-plus:16.0.0'
implementation 'com.google.android.gms:play-services-basement:16.2.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
//
implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
implementation 'com.facebook.android:facebook-share:4.38.1'
implementation 'com.facebook.android:audience-network-sdk:5.0.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.commit451:PhotoView:1.2.4'
implementation 'com.crystal:crystalrangeseekbar:1.1.1'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.3.+'
//compile 'com.appnext.sdk:native-ads2:2.+' // New Native Ads
implementation 'com.android.support:multidex:1.0.2'
androidTestImplementation 'com.android.support:multidex:1.0.2'
androidTestImplementation 'com.android.support:multidex-instrumentation:1.0.2'
testImplementation 'junit:junit:4.12'
apply plugin: 'com.google.gms.google-services'
}
I tried to delete the user-gradle-directory and the project-gradle-directory and relaunch android studio without any help. I tried to invalidate cache / restart, as well, but nothing helped.
I also can't fix the issue (all gms/firebase libraries must be exact the same...). And I realize that in all of my files the "package.R" is not recognized any more.
I have no clue to fix these problems.
It would be great if someone could help me or give me an idea.
I'm getting the following error when building my android project :
Program type already present:
com.google.common.annotations.GwtCompatible Message{kind=ERROR,
text=Program type already present:
com.google.common.annotations.GwtCompatible, sources=[Unknown source
file], tool name=Optional.of(D8)}
gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.www.www"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// multi-dex support (When your app and the libraries it references exceed 65,536 methods)
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/INDEX.LIST'
}
}
dependencies {
// multi-dex support (When your app and the libraries it references exceed 65,536 methods)
implementation 'com.android.support:multidex:1.0.3'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:design:27.1.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'
//this is for the google "text recognizer"
implementation 'com.google.android.gms:play-services-vision:15.0.2'
implementation 'com.google.apis:google-api-services-customsearch:v1-rev63-1.23.0'
//for firebase database connection
implementation 'com.google.firebase:firebase-database:16.0.1'
//implementation 'com.google.firebase:firebase-core:16.0.0'
// for firebase authentication
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
// for Google Natural Language Processing (part of google cloud services)
implementation ('com.google.cloud:google-cloud-language:1.31.0')
// {
// exclude group: 'com.google.guava'
// }
}
apply plugin: 'com.google.gms.google-services'
The following resolves THAT issue :
implementation ('com.google.cloud:google-cloud-language:1.31.0') {
exclude group: 'com.google.guava'
}
But then I am missing guava functions, because the following error will be thrown at runtime :
Didn't find class "com.google.common.base.MoreObjects"
Caused by: java.lang.NoClassDefFoundError: Failed resolution of:
Lcom/google/common/base/MoreObjects;
When I run the following code :
public void testSomething(View view){
// Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
try {
InputStream inputStream = getAssets().open("www.json");
GoogleCredentials googleCredential = GoogleCredentials.fromStream(inputStream);
}
catch (Exception e){
Log.e(TAG,e.getMessage());
e.printStackTrace();
}
I'm going in circles here. I'm desperate to find the answer.
I have checked other questions/topics, no answers that help me.
I solved same problem by making below changes:
implementation ('com.google.apis:google-api-services-drive:v2-rev105-1.17.0-rc'){
exclude module: 'guava-jdk5'
}
implementation ('com.google.api-client:google-api-client-android:1.20.0'){
exclude module: 'guava-jdk5'
}
Change Gradles To This :
implementation 'com.google.apis:google-api-services-vision:v1-rev369-1.23.0' exclude module: 'guava-jdk5'
implementation 'com.google.api-client:google-api-client-android:1.23.0' exclude module: 'guava-jdk5' exclude module: 'httpclient'
implementation 'com.google.http-client:google-http-client-gson:1.23.0' exclude module: 'httpclient'
This Worked For Me
I'm developing an Android library, and want to use the new Android Room persistence library inside it. However, when launching I got this error :
Caused by: java.lang.RuntimeException: cannot find implementation for
MyLibraryName.Database.QSDatabase. QSDatabase_Impl does not exist
at android.arch.persistence.room.Room.getGeneratedImplementation(Room.java:90)
which means that the annotationProcessor is not generating the extra code during compilation.
Btw, everything is working fine when I put my #Database code inside the app module.
My gradle file (library module) :
apply plugin: 'com.android.library'
apply plugin: 'groovyx.android'
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'org.codehaus.groovy:groovy-android-gradle-plugin:1.1.0'
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { java.srcDirs = ['src/main/java', 'src/main/groovy'] } }
}
dependencies {
// google Room persistence library
compile "android.arch.persistence.room:runtime:1.0.0-alpha1"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0-alpha1"
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'
})
// google location service
compile 'com.google.android.gms:play-services-location:10.2.4'
androidTestCompile 'junit:junit:4.12'
// Http
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
compile 'com.squareup.retrofit2:converter-scalars:2.1.0'
// groovy
compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.4'
}
This can happen when you use annotationProcessor in a kotlin project.
if so, do these
apply plugin: 'kotlin-kapt'
and use kapt instead of annotationProcessor
#stevenwood It seems you're right about groovy/
I had the same project structure. But in my case, I had no real Groovy code inside groovy/. Only plain old Java code. Hence, perhaps it was easier for me to get the project working again by making the following changes
Removing / commenting-out classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.8' from the project's build.gradle
Removing / commenting-out apply plugin: 'groovyx.grooid.groovy-android' from the module's build.gradle
git mv groovy/ java/
Thereafter at least, I stopped getting the missing Database_Impl message from Room.