How to use YouTube Analytics API in Android - android

I need to get some statistics about a certain youtube channel searched by user, and YouTube Data API doesn't provide me enough data. So how can I use YouTube Analytics API to get more data abou an youtube channel?
I can't use their lib:
compile 'com.google.apis:google-api-services-youtubeAnalytics:v1-rev73-1.22.0'
because it gives me error, and I don't want to enable multidex:
Error:Execution failed for task
':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException:
com.android.dex.DexIndexOverflowException: method ID not in [0,
0xffff]: 65536
all my dependences are:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.3.+'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'com.google.android.gms:play-services-ads:10.0.1'
compile "com.google.android.gms:play-services-gcm:10.0.1"
compile ('com.google.apis:google-api-services-youtubeAnalytics:v1-rev73-1.22.0'){
exclude module: 'httpclient' //by artifact name
exclude group: 'org.apache.httpcomponents' //by group
exclude group: 'org.apache.httpcomponents', module: 'httpclient' //by both name and group
}}

Check this documentation for the different types of reports you can retrieve using the API. Most of the workarounds I have read is to add multiDexEnabled true to your app build.gradle file.
com.android.build.transform.api.TransformException
Android Studio TransformException : Error:Execution failed for task ':app:transformClassesWithDexForDebug'
Since you don't want to enable it, I can suggest to remove unused code with ProGuard. You should enable code shrinking to run ProGuard for your release builds. Enabling shrinking ensures you are not shipping unused code with your APKs.
You can refer with this another SO answer on how to get both statistics and snippet printed to the console with single api call.

Related

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug' in android + volley libraries

I've read article this in backendless and this and this in StackOverflow. But there isn't any help for me. I searched everywhere but there isn't any solution.The error is bellow
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/android/volley/VolleyError;
In build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
androidTestCompile 'com.mcxiaoke.volley:library:1.0.18'
compile project(":volley")
compile 'com.mcxiaoke.volley:library:1.0.18'
}
This error will disappear when removing compile 'com.mcxiaoke.volley:library:1.0.18' in build.gradle.
What I need to be done is pass the data within app and server(localhost). To pass the string I'm using JSON. In android app using Volley libraries.
What would be I missed? Thank you
I'm searching everywhere but there aren't any references
The documentation shows that Google's official Volley artifact is available via:
compile 'com.android.volley:volley:1.0.0'
Use that instead of com.mcxiaoke.volley:library:1.0.18, which was published two years ago.
Now, you also have compile project(":volley"). I do not know why. Use either com.android.volley:volley:1.0.0 or compile project(":volley"), not both. Unless you have some specific reason for using the library module (e.g., you are forking Volley), I would recommend using the com.android.volley:volley:1.0.0 artifact.

Cannot resolve error in Firebase Chat application

Im trying chat application using firebase. Im getting following error which could nit resolve myself,
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzble.class
I have mentioned below my gradle file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.firebase:firebase-core:10.2.4'
compile 'com.android.support:design:25.3.1'
compile 'com.firebaseui:firebase-ui:1.1.1'
compile 'com.google.firebase:firebase-auth:10.2.4'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
FirebaseUI has transitive dependencies on a number of the Firebase libraries. You must specify a version of FirebaseUI that is compatible with the Firebase libraries you are using. The table of compatible versions is listed in the FirebaseUI documentation. The most recent FirebaseUI version is 1.2.0, which works with library version 10.2.0. A version of FirebaseUI for Firebase libs 10.2.4 and 10.2.6 has not been released.
The safe change is:
compile 'com.firebaseui:firebase-ui:1.2.0'
compile 'com.google.firebase:firebase-auth:10.2.0'
You could try 1.2.0 with 10.2.4 or 10.2.6, but may encounter the same problem you are seeing now.

generate signed APK error : java.util.zip.ZipException

I use my samsung A5 for testing app and the project is working correctly on my phone, but not working on other phones. so I want to Generate signed APK from my project. but there was an exception error:
Error:Execution failed for task '::transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/daimajia/androidanimations/library/BaseViewAnimator;
I googled the error and these code remove that error:
multiDexEnabled true
and
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
but now there is another exception:
Error:Execution failed for task ':transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/daimajia/androidanimations/library/BaseViewAnimator.class
I think this might be because of libraries that I use, but have no idea how to handle it. below is all libraries in build.gradle :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
//for compiling card view
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
//for sticky header
compile 'com.github.carlonzo.stikkyheader:core:0.0.3-SNAPSHOT'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.melnykov:floatingactionbutton:1.0.7'
compile 'com.ogaclejapan.smarttablayout:library:1.6.1#aar'
compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1#aar'
compile 'me.drakeet.materialdialog:library:1.3.1'
compile files('libs/volley.jar')
compile 'com.daimajia.easing:library:1.0.1#aar'
compile 'com.daimajia.androidanimations:library:1.1.3#aar'
//Sweet Alert Dialog
compile 'cn.pedant.sweetalert:library:1.3'
compile 'org.apmem.tools:layouts:1.10#aar'
}
A few things...
First of all, I'd remove most of the 3rd party libraries you are including. For example,
//for sticky header
compile 'com.github.carlonzo.stikkyheader:core:0.0.3-SNAPSHOT'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.melnykov:floatingactionbutton:1.0.7'
all of those are covered by the Design Support Library from Google
From the names I think you can also remove
compile 'com.ogaclejapan.smarttablayout:library:1.6.1#aar'
compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1#aar'
compile files('libs/volley.jar') should be replaced with compile 'com.android.volley:volley:1.0.0'
and I'd also remove
//Sweet Alert Dialog
compile 'cn.pedant.sweetalert:library:1.3'
compile 'org.apmem.tools:layouts:1.10#aar'
Many of those projects you are including haven't been worked on in over 2 years.
Try to still with the support libraries from Google. You'll get most of this from the Design support library.
Last point. You are getting the Dex errors because the app is including all of these libraries and passing the 64k method limit. I suggest enabling proguard to remove un-used code and reduce the method count of your project.

app:dexDebug error in build.gradle Android Studio

I am receiving the app:dexDebug error when trying to run my project on Android Studio. I believe it's got to do with my dependencies but I am not sure where I am going wrong.
The error is:
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_17\bin\java.exe'' finished with non-zero exit value 2
My dependencies in the build.gradle file are as follows:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.2'
}
Can anyone point me in the correct direction here, please.
Thank you.
UPDATE
Problem solved by adding the following to my build.gradle
packagingOptions {
exclude 'META-INF/license.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/notice.txt'
exclude 'META-INF/NOTICE'
}
Android Studio Error:Execution failed for task ':app:dexDebug' to solve it setting multiDexEnabled to true in your gradle file.
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
The problem is most likely caused by adding all play services dependencies. You should not compile the entire package of APIs into your app, it increases the number of methods in your app. app:dexDebug error indicates you have exceeded the 65k method limit. Remove this line in your build.gradle: compile 'com.google.android.gms:play-services:8.3.0'
then choose from these seperate dependencies, the ones to add based on what your app needs. E.g to use Gcm, you only need to add compile 'com.google.android.gms:play-services-gcm:8.4.0'

Google Map V2 and GCM in a project

i have a project that uses Google Map API v2, and now i want to add GCM to this project, when i add GCM dependency to my gradle file i face with this error:
Error:Execution failed for task ':app:processDebugResources'.
Error: more than one library with package name 'com.google.android.gms'
You can temporarily disable this error with android.enforceUniquePackageName=false
However, this is temporary and will be enforced in 1.0
my dependencies are:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.github.rey5137:material:1.2.1'
compile ('com.google.android.gms:play-services:4.1.32')
compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile 'com.jpardogo.materialtabstrip:library:1.1.0'
compile('com.balysv.materialmenu:material-menu:1.5.4') {
exclude group: 'com.nineoldandroids', module: 'library'
}
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:appcompat-v7:21.0.3'
}
what can i do?
compile ('com.google.android.gms:play-services:4.1.32')
compile 'com.google.android.gms:play-services-gcm:7.8.0'
Please DO NOT use two different version of Google Play Service.
Also, most importantly try using those gradle dependencies which required by your application instead of all dependencies. Check here

Categories

Resources