I would like to use Cloud Text-To-Speech.
On the documentation page I see that I have to install the client library. On that page you see the code for Maven but in my Android Studio, I am using Gradle and I have no idea how to install it with Gradle.
On MVNRepository I have noticed that I have to use compile group: 'com.google.cloud', name: 'google-cloud-texttospeech', version: '1.2.1'. So on on my application (app -> build.gradle), I have inserted that line to the dependencies. So it looks like this:
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
compile group: 'com.google.cloud', name: 'google-cloud-texttospeech', version: '1.2.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
But that gives me the error: More than one file was found with OS independent path 'META-INF/INDEX.LIST'.
Also, Android Studio tells me "compile is deprecated; replace with implementation". If I replace it, I'll get the error: Cannot fit requested classes in a single dex file (# methods: 151443 > 65536)
I also tried to use:
packagingOptions {
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/DEPENDENCIES'
}
I cleaned my project and restarted the app but then I get the error: Cannot fit requested classes in a single dex file (# methods: 147675 > 65536)
This is too annoying! How can I simply install that library??
Instead of compile group: 'com.google.cloud', name: 'google-cloud-texttospeech', version: '1.2.1', I needed to use implementation 'com.google.cloud:libraries-bom:4.3.0'.
Related
I need to use dialogFlow sdk along with firestore sdk. In separate projects I can use normally, but when I join them, a dependency failure occurs
I have tried to use several different versions of them but to no avail
android {
/* Code */
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/INDEX.LIST'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.firebase:firebase-auth:19.0.0'
implementation 'com.google.firebase:firebase-firestore:21.0.0'
//erro aqui
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
//implementation 'com.google.firebase:firebase-inappmessaging-display:19.0.0'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'ai.api:sdk:2.0.5#aar'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'commons-io:commons-io:2.4'
implementation('ai.api:libai:1.4.8') {
exclude module: 'log4j-core'
}
implementation 'com.google.dagger:dagger:2.22'
kapt 'com.google.dagger:dagger-compiler:2.16'
implementation 'io.github.dreierf:material-intro-screen:0.0.6'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.android.billingclient:billing:2.0.3'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'//rede
implementation 'com.squareup.retrofit2:converter-jackson:2.4.0'
implementation 'com.github.pchmn:MaterialChipsInput:1.0.8'
implementation 'com.github.clans:fab:1.6.4'//floatingActionMenu
implementation 'com.github.ialokim:android-phone-field:0.2.3'
implementation 'com.google.cloud:google-cloud-dialogflow:0.108.0-alpha'
//erro aqui
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.stepstone.apprating:app-rating:2.3.1'
}
apply plugin: 'com.google.gms.google-services'
googleServices { disableVersionCheck = false }
The error that is displayed in the attempt to compile:
Dependency resolved to an incompatible version:
Dependency(fromArtifactVersion=ArtifactVersion(groupId=io.grpc, artifactId=grpc-okhttp, version=1.21.0), toArtifact=Artifact(groupId=io.grpc, artifactId=grpc-core), toArtifactVersionString=[1.21.0])
FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[1.21.0]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
Dependency failing: io.grpc:grpc-okhttp:1.21.0 -> io.grpc:grpc-core#[1.21.0], but grpc-core version was 1.23.0.
The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the artifact with the issue.
-- Project 'app' depends onto com.google.firebase:firebase-firestore#21.0.0
-- Project 'app' depends onto com.google.cloud:google-cloud-dialogflow#0.108.0-alpha
For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dependency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your build.gradle file.
I was able to solve by adding this to build.gradle
android {
//
configurations.all {
exclude group:'com.google.api.grpc',module:'proto-google-common-protos'
exclude group: 'com.google.protobuf', module: 'protobuf-java'
exclude group: 'com.google.guava',module: 'guava-jdk5'
}
}
The solution and explanation of the problem comes from here
I have 2 modules in my android app. Core module and one feature module. Currently I have 3 dependencies common for these 2 modules and I am adding it in both modules gradle file (Which leads to more app size and redundancy). How to share these dependencies with multiple modules in android.
core module dependencies
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
api 'com.github.bumptech.glide:glide:4.9.0'
}
feature module dependencies
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
//implementation project(':testmodule')
api project(path:':coreModule',configuration: 'default')
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'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}
Used api in core module and used it in feature module using api project(path:':coreModule',configuration: 'default')
If you are writing
implementation 'com.xxx.android.x:1.2342'
which means that the current module requires this dependency to work. There by you need to declare it explicitly in both modules
One in core
One in other module
You can remove these kind of reduntant duplicate dependencies by using
api other than implementation
because api is used for sharing a dependency in one module with the others.
So replace impementation with api for the duplicated dependencies.
For Example: Library uses androidx.core:core-ktx:1.0.2
Then inside library build.gradle add
api 'androidx.core:core-ktx:1.0.2'
here by you don't need to define it again in app module.
Android studio always warns about the duplicate dependencies and those duplicate dependencies create a time-consuming over head while building the release-apk file.
You can first identify the duplicate dependencies using the following command:
gradle -q dependencies yourProject:dependencies --configuration compile
The command result will show you human-readable tree hierarchy of all dependencies as mentioned below.
compile - Classpath for compiling the main sources.
...
+--- project :yourProject
| +--- com.loopj.android:android-async-http:1.4.6
| +--- org.apache.httpcomponents:httpmime:4.2.5
| | \--- org.apache.httpcomponents:httpcore:4.2.4
| \--- com.google.code.gson:gson:2.3.1
...
Once you have identified the duplicate dependencies, you can exclude them from the specified library using the following syntax in your build.gradle file.
//OneSignal
api ('com.onesignal:OneSignal:[3.6.2, 3.99.99]') {
exclude group: 'android.arch.lifecycle', module: 'extensions'
exclude group: 'com.android.support', module: 'design'
}
I hope this helps.
I found a error problem in build.gradle. Have a message to me "All com.android.support libraries must use the exact same version specification (mixing version can lead to runtime crashes). And there is a red line on the bottom of "implementation 'com.android.support:appcompat-v7:28.0.0'".I don't know where I went wrong.
Thank you
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "com.android.support:appcompat-v7:28.0.0"
implementation "com.android.support:design:28.0.0"
implementation "com.android.support:design:28.0.0"
implementation 'com.android.support:palette-v7:28.0.0'
implementation "com.android.support:cardview-v7:28.0.0"
implementation "com.android.support:recyclerview-v7:28.0.0"
//Firebase Dependencies
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-firestore:18.0.1'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-ads:17.1.3'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-appindexing:17.1.0'
implementation 'com.google.firebase:firebase-ads:17.2.0'
implementation 'com.google.android.gms:play-services-ads:17.2.0'
implementation 'com.artjimlop:altex-image-downloader:0.0.4'
implementation 'com.yalantis:ucrop:2.2.0'
implementation 'com.github.danimahardhika:cafebar:1.3.1'
implementation 'com.github.qiugang:EditTag:v1.2.4-beta2'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.airbnb.android:lottie:2.6.0'
implementation 'com.github.chyrta:AndroidOnboarder:0.7'
//Error Fixer
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:support-vector-drawable:28.0.0'
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'
Your gradle dependencies require rework:
Clean the duplicate dependencies and add each line only once!
Lines:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "com.android.support:design:28.0.0"
are twice. Keep each one only once!
Use only one version definition of each library. Firebase core has import of two different versions:
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.7'
Select one of the two lines.
Depenencies of your dependencies should not have different versions. You have many libraries that use other versions of com.android.support components, which can cause this error.
For example:
'com.artjimlop:altex-image-downloader:0.0.4' use com.android.support:appcompat-v7:23.1.0 see here
'com.yalantis:ucrop:2.2.0' use com.android.support:appcompat-v7:24.2.0 see here
'com.github.danimahardhika:cafebar:1.3.1' use com.android.support:design and com.android.support:cardview-v7 see here
'com.github.qiugang:EditTag:v1.2.4-beta2' use com.android.support:recyclerview-v7 and com.android.support:appcompat-v7 see here
etc the list goes on for almost all 3rd party github libraries.
You can use the following configuration in order to exclude all that dependencies.
configurations {
all*.exclude module: "appcompat-v7"
all*.exclude module: "recyclerview-v7"
all*.exclude module: "design"
all*.exclude module: "cardview-v7"
// ... etc in case there are extra dependencies
}
or even better you can get through each dependency and exclude the exact libraries that cause the duplication:
ie. for 'com.artjimlop:altex-image-downloader:0.0.4' you should change the implementation 'com.artjimlop:altex-image-downloader:0.0.4' with:
implementation ('com.artjimlop:altex-image-downloader:0.0.4') {
exclude group: 'com.android.support', module: 'appcompat-v7'
// for more than one just add it in a new line ie.
// exclude group: '<first part till : symbol>', module: '<second part between : symbol and version>'
}
Read this article here if you want to dig further regarding dependencies of dependencies issue.
You must be seeing red line like this right? hover your mouse pointer on red line and you will see dialog like this. find which libraries are still old (in my case it was cardview) add that library's latest version in gradle and your issue may be solved.
If still it doesn't then I am seeing that you are using old Firebase libraries, update them to latest too.
The error message is pretty clear, "All com.android.support libraries must use the exact same version specification". For example, you have this:
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.7'
You are trying to build 2 different versions, 16.0.1 and 16.0.7, of the same library. This can lead to runtime crashes. Choose which version you want to keep and delete the other. For example, if you want the version 16.0.7, replace these two lines with:
implementation 'com.google.firebase:firebase-core:16.0.7'
I've been told by Google that "Your app (com.package.name) includes a ZIP file which contains ELF files." I have searched my project. I haven't used a zip file or ELF file anywhere in my project. Thus, it must be in one of my dependencies, but I don't know which one.
I used the following dependencies:
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.google.code.gson:gson:2.4'
implementation 'io.appsfly.android.utils:micro-app:1.2.22'
implementation 'com.android.support:design:28.0.0-beta01'
implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
implementation 'com.android.support:cardview-v7:28.0.0-beta01'
implementation 'com.squareup.okhttp:okhttp:2.5.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.google.android.gms:play-services-auth:11.+'
implementation 'com.roughike:bottom-bar:2.3.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'com.android.support:multidex:1.0.2'
implementation 'com.twitter.sdk.android:twitter-core:3.1.1'
testImplementation 'junit:junit:4.12'
implementation('com.crashlytics.sdk.android:crashlytics:2.8.0#aar') {
transitive = true;
exclude group: 'com.android.support', module: 'support-annotations'
}
Which of these dependencies "includes a ZIP file which contains ELF files"?
I don't know for sure. But looking at your dependencies, when I google for AppsFly it seems like a platform which delivers dynamic code to apps. And Google Play policy says (as you quote)
An app distributed on Google Play may not modify, replace, or update itself using any method other than Google Play's update mechanism.
So using AppsFly might be against the Policy. To clarify, I know nothing about AppsFly as their website doesn't have much information, but it sure sounds like it breaks the Google Play policy.
I cannot create a signed apk if proguard is active. If not it works.
The error is:
Warning:Exception while processing task java.io.IOException:
Can't write [C:\Users....\AndroidStudioProjects\BStats\app\build\intermediates\transforms\proguard\release\0.jar]
(Can't read [C:\Users.....gradle\caches\transforms-1\files-1.1\play-services-auth-base-11.0.1.aar\37c6010cc8e9c38e6022a124120862be\jars\classes.jar(;;;;;;**.class)]
(Duplicate zip entry [com/google/android/gms/b/ju.class == classes.jar:com/google/android/gms/internal/zzei.class]))
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
my gradle file:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:animated-vector-drawable:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:customtabs:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
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'
// Facebook stuff
// Android SDK
implementation 'com.facebook.android:facebook-android-sdk:4.+'
// Audience Network SDK. Only versions 4.6.0 and above are available
implementation 'com.facebook.android:audience-network-sdk:4.+'
// Account Kit
implementation 'com.facebook.android:account-kit-sdk:4.+'
Why is it complaining about play-services-auth-base-11.0.1.aar if I don't even use it?
Why does it work if not using proguard?
Apreciate your help. Other similar cases use the libs that are being nominated, and the fix is just a matter of having the right versions. This is not the case.
My proguard:
-keepattributes Signature
-dontwarn com.google.android.gms.** - if not I have lots of warnings - and I don't even use com.google.android.gms in my app.
Thanks.
Delete build folder from app and run if not work than try Invalidate Caches/Restart.
Happy coding!!
Very strange...
I made this change:
// Android SDK
implementation( 'com.facebook.android:facebook-android-sdk:4.+' ){
exclude group: 'com.google.android.gms'
}
// Audience Network SDK. Only versions 4.6.0 and above are available
implementation( 'com.facebook.android:audience-network-sdk:4.+'){
exclude group: 'com.google.android.gms'
}
// Account Kit
implementation( 'com.facebook.android:account-kit-sdk:4.+'){
exclude group: 'com.google.android.gms'
}
And now the APK is being generated with Proguard. I didn't test it yet to see if the Facebook integration works properly. In case it does, I think this should be better explanined in the documentation.