Start a new topic

Problems with Kinvey Libraries in combinaton with Google Play Services Library

Dear Team,


I ran into an issue, which I can not solve for some time now.


I did your Getting Started Guide, downloaded kinvey-android-2.10.5.zip and followed the steps in the guide.

I had to remove a library file that you provided to fix a "duplicate entry" error when building the project, as shown here: https://support.kinvey.com/support/discussions/topics/12000001038


Everything works, I can ping Kinvey, Log in, Log out and even successfully call an Endpoint.


As soon as I add the Library com.google.android.gms:play-services:8.4.0 to my project, I run into an exception, when calling

oKinveyClient = new Client.Builder("personal", "personal", oContext.getApplicationContext()).build();


FATAL EXCEPTION: main

                                                                             Process: com.example.sunny.elektroskop, PID: 2526

                                                                             java.lang.IllegalStateException: Could not execute method for android:onClick

                                                                                 at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)

                                                                                 at android.view.View.performClick(View.java:4438)

                                                                                 at android.view.View$PerformClick.run(View.java:18422)

                                                                                 at android.os.Handler.handleCallback(Handler.java:733)

                                                                                 at android.os.Handler.dispatchMessage(Handler.java:95)

                                                                                 at android.os.Looper.loop(Looper.java:136)

                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5001)

                                                                                 at java.lang.reflect.Method.invokeNative(Native Method)

                                                                                 at java.lang.reflect.Method.invoke(Method.java:515)

                                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)

                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)

                                                                                 at dalvik.system.NativeStart.main(Native Method)

                                                                              Caused by: java.lang.reflect.InvocationTargetException

                                                                                 at java.lang.reflect.Method.invokeNative(Native Method)

                                                                                 at java.lang.reflect.Method.invoke(Method.java:515)

                                                                                 at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)

                                                                                 at android.view.View.performClick(View.java:4438) 

                                                                                 at android.view.View$PerformClick.run(View.java:18422) 

                                                                                 at android.os.Handler.handleCallback(Handler.java:733) 

                                                                                 at android.os.Handler.dispatchMessage(Handler.java:95) 

                                                                                 at android.os.Looper.loop(Looper.java:136) 

                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5001) 

                                                                                 at java.lang.reflect.Method.invokeNative(Native Method) 

                                                                                 at java.lang.reflect.Method.invoke(Method.java:515) 

                                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 

                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 

                                                                                 at dalvik.system.NativeStart.main(Native Method) 

                                                                              Caused by: java.lang.NoClassDefFoundError: com.kinvey.android.Client$Builder

                                                                                 at com.example.sunny.elektroskop.KinveyBackend.mCreateKinveyClient(KinveyBackend.java:30)

                                                                                 at com.example.sunny.elektroskop.KinveyBackend.<init>(KinveyBackend.java:115)

                                                                                 at com.example.sunny.elektroskop.MainActivity.onClick(MainActivity.java:69)

                                                                                 at java.lang.reflect.Method.invokeNative(Native Method) 

                                                                                 at java.lang.reflect.Method.invoke(Method.java:515) 

                                                                                 at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 

                                                                                 at android.view.View.performClick(View.java:4438) 

                                                                                 at android.view.View$PerformClick.run(View.java:18422) 

                                                                                 at android.os.Handler.handleCallback(Handler.java:733) 

                                                                                 at android.os.Handler.dispatchMessage(Handler.java:95) 

                                                                                 at android.os.Looper.loop(Looper.java:136) 

                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5001) 

                                                                                 at java.lang.reflect.Method.invokeNative(Native Method) 

                                                                                 at java.lang.reflect.Method.invoke(Method.java:515) 

                                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 

                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 

                                                                                 at dalvik.system.NativeStart.main(Native Method)


As soon as I remove

compile 'com.google.android.gms:play-services:8.4.0'

from my project, the error is fixed. How can the Google Play Services Library interfere with the libraries that Kinvey provided?


Hope you can help.


Greetings from Austria,


Simon


1 person has this question

I figured it out I added

@Override

 protected void attachBaseContext(Context base) {

  super.attachBaseContext(base);

  MultiDex.install(base);

 }

to my launcher class


1 person likes this

Hi,


Can you check if you face the same issue if you use Kinvey SDK 2.10.4 available here: http://download.kinvey.com/Android/kinvey-android-2.10.4.zip


Also, can you tell me if this issue occurs only with this particular version of play-services library(8.4.0)?



Regards,

Wani

Kinvey Support


1 person likes this

I am having a similar issue with google play services with kinvey


Kinvey runs fine by itself but when I include


compile 'com.google.android.gms:play-services-ads:8.4.0'

compile 'com.google.android.gms:play-services-appindexing:8.4.0'


in the gradle under dependencies


I get the following error


Error:Execution failed for task ':android:transformClassesWithDexForDebug'.

> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_31\bin\java.exe'' finished with non-zero exit value 2


Now I have tried researching this problem and tried multidexing and increasing the max heapsize which resulted in the following error 


java.lang.NoClassDefFoundError: com.kinvey.java.core.KinveyClientRequestInitializer

                                                                                 at com.kinvey.android.Client$Builder.<init>(Client.java:574)


Oddly enough the issue only comes up when I include the ads api(WHICH MUST BE INCLUDED ALONG WITH KINVEY)


I am not sure how to resolve this problem or if this problem is related to the size of the dex file or if it is a redundant package I would appreciate help in this matter and thank you in advance for your response.  

Hi Wani,


Combination Kinvey SDK 2.10.4 with play-services library(8.4.0), does NOT fix the problem


Combination Kinvey SDK 2.10.4 with play-services library(7.0.0), FIXES the problem


Combination Kinvey SDK 2.10.5 with play-services library(7.0.0), FIXES the problem


Unfornuately I wan to to use play-services 8.4.0


Regards,


Simon

Hi Simon/Ming Chan,


I was trying this out with Kinvey's latest Android SDK (2.10.6), and I faced the same issue related to transformClassesWithDexForDebug.


As it turns out, the solution to this is to add multiDexEnabled true to your app build.gradle file.

 defaultConfig {

    multiDexEnabled true

}


Can you guys try this out and let me know if the issue still persists?



Regards,

Wani

Kinvey Support

I tried that and got the error


java.lang.NoClassDefFoundError: com.kinvey.java.core.KinveyClientRequestInitializer

                                                                                 at com.kinvey.android.Client$Builder.<init>(Client.java:573)


When I try to build the client.  I also tried max heap size it did not work either.  


I think using multidexing is not allowing the all the kinvey methods to be together so it can't function.  


Is their somthing I'm doing wroung or is their a way to fix this?  

Okay guys, what i do wrong?



 

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
      MultiDex.install(this);

  

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.google.android.gms:play-services-fitness:8.4.0'
    compile 'com.google.android.gms:play-services-wearable:8.4.0'
    compile 'com.google.android.gms:play-services-location:8.4.0'
    compile(name:'kinvey-android-2.10.8', ext:'aar')
}

  

 defaultConfig {
        applicationId "com.mycompany.testsavedata"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true


    }

 
And after i have this error 

 

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

 


Sorry ro disappoint you Wani,


Had

multiDexEnabled true

set for the whole time as well as

dexOptions {
// To solve java.exe'' finished with non-zero exit value 3
javaMaxHeapSize "2g"
}

Also I now tried with Kinvey 2.10.6.

Still got the same stack trace as seen in my first post. As soon as I add com.google.android.gms:play-services:8.4.0G I run into an error when creating a Kinvey Client. I do not understand, why the error does not show up when compiling, but only after the code is compiled and called on an android devicce.


Greetings


Simon

@Ming Chan:

Thanks, also fixed it for me. Although you need some special error handling for this within your code.

super.attachBaseContext(base); caused an exception because a base already was attached.


It also seems to be a one time thing: After using these 2 lines of code I can remove them and the app still works.


Thanks!


Login or Signup to post a comment