artberri / cordova-plugin-play-games-services

Cordova Plugin For Google Play Game Service
39 stars 32 forks source link

Build errors for the latest ionic version #2

Closed doug1e closed 5 years ago

doug1e commented 5 years ago

Hi Alberto,

Huge thanks for responding over twitter and apologies for bugging you on social media.

My application has been working perfectly fine till I updated my platform to the latest ionic and cordova. One major change at the latest ionic is that it started using angular 8 so I am not sure if the issue has anything to do with that.

To replicate the issue:

1) Create a blank project by: ionic start AndroidProject blank --cordova

2) Install the google-play-games-services by:

ionic cordova plugin add cordova-plugin-play-games-services --variable APP_ID=“XXXX”
npm install @ionic-native/google-play-games-services

3) Build the project ionic cordova build android --release --pro

Basically, this is a blank project with the cordova plugin. The build trows the following errors:

Task :app:compileReleaseJavaWithJavac FAILED
/home/AndroidProject/platforms/android/app/src/main/java/com/berriart/cordova/plugins/BaseGameActivity.java:21: error: cannot find symbol
import android.support.v4.app.FragmentActivity;
^
symbol: class FragmentActivity
location: package android.support.v4.app
/home/AndroidProject/platforms/android/app/src/main/java/com/berriart/cordova/plugins/BaseGameActivity.java:43: error: cannot find symbol
public abstract class BaseGameActivity extends FragmentActivity implements
^
symbol: class FragmentActivity
/home/AndroidProject/platforms/android/app/src/main/java/com/berriart/cordova/plugins/BaseGameActivity.java:92: error: incompatible types: BaseGameActivity cannot be converted to Activity
mHelper = new GameHelper(this, mRequestedClients);
^
/home/AndroidProject/platforms/android/app/src/main/java/com/berriart/cordova/plugins/BaseGameActivity.java:98: error: method does not override or implement a method from a supertype
@Override
^
/home/AndroidProject/platforms/android/app/src/main/java/com/berriart/cordova/plugins/BaseGameActivity.java:100: error: cannot find symbol
super.onCreate(b);
^
symbol: variable super
location: class BaseGameActivity
/home/AndroidProject/platforms/android/app/src/main/java/com/berriart/cordova/plugins/BaseGameActivity.java:107: error: method does not override or implement a method from a supertype
@Override
^
/home/AndroidProject/platforms/android/app/src/main/java/com/berriart/cordova/plugins/BaseGameActivity.java:109: error: cannot find symbol
super.onStart();
^
symbol: variable super
location: class BaseGameActivity
/home/AndroidProject/platforms/android/app/src/main/java/com/berriart/cordova/plugins/BaseGameActivity.java:110: error: incompatible types: BaseGameActivity cannot be converted to Activity
mHelper.onStart(this);
^
/home/AndroidProject/platforms/android/app/src/main/java/com/berriart/cordova/plugins/BaseGameActivity.java:113: error: method does not override or implement a method from a supertype
@Override
^
/home/AndroidProject/platforms/android/app/src/main/java/com/berriart/cordova/plugins/BaseGameActivity.java:115: error: cannot find symbol
super.onStop();
^
symbol: variable super
location: class BaseGameActivity
/home/AndroidProject/platforms/android/app/src/main/java/com/berriart/cordova/plugins/BaseGameActivity.java:119: error: method does not override or implement a method from a supertype
@Override
^
/home/AndroidProject/platforms/android/app/src/main/java/com/berriart/cordova/plugins/BaseGameActivity.java:121: error: cannot find symbol
super.onActivityResult(request, response, data);
^
symbol: variable super
location: class BaseGameActivity
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
12 errors

FAILURE: Build failed with an exception.

I tried to fix this with gradle as it seems to need a new dependency based on this page: https://developer.android.com/topic/libraries/support-library/packages

However, I have failed to do so. Please find the ionic info below:

Ionic:

   Ionic CLI                     : 5.2.4 (/home/dx/.npm-global/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.6.2
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 5 other plugins)

Utility:

   cordova-res : 0.6.0 
   native-run  : not installed

System:

   Android SDK Tools : 26.1.1 (/home/dx/Android/Sdk)
   NodeJS            : v12.6.0 (/usr/bin/node)
   npm               : 6.10.3
   OS                : Linux 4.18

I hope you can provide some pointers. I do appreciate your time and help on the matter and thanks again for responding to me.

Cheers,

Doug

artberri commented 5 years ago

Hi @doug1e,

Than you very much for finding the bug, reporting it and being so descriptive :+1:

I've just bumped a new version that should fix the bug: v1.1.1. I will appreciate if you test it and let me know if your problem was finally fixed.

If I have some extra time I'll try to update also the ionic plugin to include full functionality.

Regards.

doug1e commented 5 years ago

Works like a charm Alberto :) You are the best, huge thanks

doug1e commented 5 years ago

Hi Alberto,

Apologies for reopening the issue. Although the above build error is gone, I now get merging errors when I include another plugin (https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin)

Please see the error below:

D8: Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForRelease'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
  Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

This may be a totally different issue and maybe related to ionic/cordova changes, etc. I managed to bypass the error by the following:

ionic cordova plugin add cordova-plugin-androidx
ionic cordova plugin add cordova-plugin-androidx-adapter

I cannot launch the app right now and trying to figure out the issue. Again, this may be nothing to do with your changes but I thought I would let you know just in case.

Regards,

Doug

artberri commented 5 years ago

Hi again,

I've seen you've already opened an issue in the other repository, I'll put a link here only to be able to track it: https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/issues/1044

The thing is that there is a new version of the support library called AndroidX which is being used from the Android 9.0 (API level 28) version. This is being used by the latest Google Play Services library which is the one used by my plugin.

In order to avoid this kind of problem, I've released a new version just now (1.1.2) which allows to change Google Play Service libraries used so you can adapt it as you need.

For example you can install the plugins like this:

ionic cordova plugin add cordova-plugin-play-games-services --variable APP_ID="XXXXXX" --variable ANDROID_PLAY_SERVICES_GAMES_VERSION="16.+" --variable ANDROID_PLAY_SERVICES_PLUS_VERSION="16.+"
ionic cordova plugin add cordova-plugin-x-socialsharing --variable ANDROID_SUPPORT_V4_VERSION="+"

By using the 16.x version of the libraries you will be able to keep using the android.support.* libraries while the Social Sharing plugin moves to the new system.

I close the issue again, feel free to reopen it if you get in troubles.

doug1e commented 5 years ago

Many thanks for the clarification Alberto

faridmv commented 4 years ago

Hi @Artberri,

I just tried to build my project recently but I get errors as below:

`E:\phonegap\f2048\platforms\android\app\src\main\java\com\berriart\cordova\plugins\GameHelper.java:43: error: package com.google.android.gms.games.request does not exist import com.google.android.gms.games.request.GameRequest; ^ E:\phonegap\f2048\platforms\android\app\src\main\java\com\berriart\cordova\plugins\GameHelper.java:174: error: cannot find symbol ArrayList mRequests; ^ symbol: class GameRequest location: class GameHelper E:\phonegap\f2048\platforms\android\app\src\main\java\com\berriart\cordova\plugins\GameHelper.java:492: error: cannot find symbol public ArrayList getRequests() { ^ symbol: class GameRequest location: class GameHelper E:\phonegap\f2048\platforms\android\app\src\main\java\com\berriart\cordova\plugins\GameHelper.java:714: error: cannot find symbol mRequests = Games.Requests ^ symbol: variable Requests location: class Games Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. 4 errors

Task :app:compileReleaseJavaWithJavac FAILED`

Please tell me what should I do?

Regards