# حل تعارضات خدمات Google Play

يمكن أن تستخدم الإضافات المختلفة لأطر العمل المختلفة إصدارات مختلفة من مكتبة google-play-services، مما يتسبب في فشل مشروعك في الترجمة أو تعطله لأن إصدار المكتبة قديم.

توفر الأقسام التالية حلولاً للإضافات المختلفة.

## موقع المكتبة

يمكنك العثور على مكتبة خدمات Google Play في `<Android SDK>/extras/google`.

المكتبة متاحة بتنسيقين:

1.  **ملف jar متجانس** (يحتوي على جميع مكونات خدمات Google Play في ملف واحد):
    ```
    sdk/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar
    ```

2.  **ملفات aar معيارية** (أرشيف Android)، حيث يكون كل مكون في ملف منفصل:
    ```
    sdk/extras/google/m2repository/com/google/android/gms/…
    ```

يمكن تجريد ملف **aar** إلى ملف **jar** (لا تدعم جميع أطر العمل aar في الوقت الحالي) عن طريق فك ضغط الملف (aar هو أرشيف zip) وأخذ **classes.jar** - وهو كود المكتبة.

### 1. Cordova

يتم حل جميع تعارضات خدمات google play على Cordova تلقائيًا باستخدام gradle. في بعض الأحيان (على سبيل المثال، تستخدم الإضافات المختلفة إصدارات رئيسية مختلفة من المكتبة) قد يفشل الحل وقد يظهر إصداران مختلفان من نفس المكتبة في البنية الناتجة.

### 2. Unity, Appcelerator Titanium

يمكنك العثور على مكتبة خدمات Google Play في الإضافة (أو المشروع النموذجي). من السهل تحديثها/تغييرها/إزالتها لحل التعارضات المحتملة:

*   Unity: [https://github.com/Pushwoosh/pushwoosh-unity/tree/master/PushwooshUnitySample/Assets/Plugins/Android](https://github.com/Pushwoosh/pushwoosh-unity/tree/master/PushwooshUnitySample/Assets/Plugins/Android)
*   Unity وإضافة Google Analytics: تستخدم إضافة Google analytics مكتبة google play قديمة، والتي تحتاج إلى تحديث. مزيد من المعلومات هنا: [https://github.com/Pushwoosh/pushwoosh-unity/issues/5](https://github.com/Pushwoosh/pushwoosh-unity/issues/5)

```bash
rm -rf Assets/Plugins/Android/google-play-services_lib/libs
rm -rf Assets/Plugins/Android/google-play-services_lib/res
cp ${ANDROID_HOME}/extras/google/m2repository/com/google/android/gms/play-services-analytics/8.4.0/play-services-analytics-8.4.0.aar Assets/Plugins/Android/
cp ${ANDROID_HOME}/extras/google/m2repository/com/google/android/gms/play-services-ads/8.4.0/play-services-ads-8.4.0.aar Assets/Plugins/Android/
```

*   Appcelerator Titanium (لاحظ أن إصدار الوحدة قد يتغير أسرع من هذا المستند!): [https://github.com/Pushwoosh/pushwoosh-appcelerator-titanium/tree/master/Module-Source/android/src/com/pushwoosh/module](https://github.com/Pushwoosh/pushwoosh-appcelerator-titanium/tree/master/Module-Source/android/src/com/pushwoosh/module)

### 3. Adobe Air

خذ ملحق ANE، واستخرجه، وعدّله، وأعد حزمه.

استخدم المثال التالي مع **PushNotification.ane**:

```bash
unzip PushNotification.ane -d tmp
```

يستخرج هذا الأمر محتويات ملف .ane إلى دليل `tmp`.

الآن في _tmp/META-INF/ANE/Android-ARM/_ و _tmp/META-INF/ANE/Android-x86/_ يمكنك العثور على جميع المكتبات: android-support_، play-services_، التي ربما تم تعديلها/تحديثها/إزالتها.

إذا كنت لا تزال تتبع الرابط إلى المستند أعلاه، فقم بتغيير `tmp/META-INF/ANE/Android-ARM/platform.xml` و `tmp/META-INF/ANE/Android-x86/platform.xml`، ثم قم بضغط الملحق مرة أخرى ويجب أن يعمل كل شيء بشكل طبيعي.

إذا حصلت على الخطأ:

> PushNotification.ane is not a valid native extension file.

أعد حزم الملحق باستخدام الخطوات التالية:

1.  احذف `tmp/META-INF/ANE/Android-ARM/platform.xml` و `tmp/META-INF/ANE/Android-x86/platform.xml`
2.  عدّل حسب الدليل في الرابط أعلاه `tmp/META-INF/ANE/Android-ARM/android-depends.xml` و `tmp/META-INF/ANE/Android-x86/android-depends.xml` بدلاً من ذلك
3.  قم بتشغيل أوامر bash التالية:

```bash
#rename platform.xml on iOS, required to repackage the extension
mv tmp/META-INF/ANE/iPhone-ARM/platform.xml tmp/META-INF/ANE/iPhone-ARM/platform-iOS.xml 

#pack the extension back with adt
cd tmp/META-INF/ANE/
“${flex.sdk}/bin/adt" -package -target ane PushNotification.ane extension.xml -swc ../../../../SWC-Pushwoosh/PushNotification.swc -platform iPhone-ARM -platformoptions iPhone-ARM/platform-iOS.xml -C iPhone-ARM/ . -platform Android-ARM -platformoptions Android-ARM/android-depends.xml -C Android-ARM/ . -platform Android-x86 -C Android-x86/ . -platformoptions Android-x86/android-depends.xml -platform default -C default/ .
```

يمكنك العثور على PushNotification.swc هنا: [https://github.com/Pushwoosh/pushwoosh-adobe-air/blob/master/SWC-Pushwoosh/PushNotification.swc](https://github.com/Pushwoosh/pushwoosh-adobe-air/blob/master/SWC-Pushwoosh/PushNotification.swc)

### 4. Unreal Engine

سيتعارض Unreal Engine و Pushwoosh Plugin دائمًا مع بعضهما البعض تقريبًا. يفسر هذا باحتواء Unreal Engine على خدمات Google Play بشكل افتراضي، وتستخدم الإصدارات المختلفة من المحرك إصدارات مختلفة من هذه المكتبات. يستخدم Pushwoosh plugin هذه المكتبات أيضًا، ولكن مجموعة فرعية مختلفة. كن حذرًا دائمًا عند دمج Pushwoosh Plugin لـ Unreal Engine. حتى لو بدا أن مشروعك يترجم ويعمل بشكل جيد، تأكد من أن كل من Pushwoosh و Unreal Engine يستخدمان نفس إصدار خدمات Google Play. يؤدي استخدام إصدارات مختلفة من google-play-services في مشروع واحد إلى سلوك غير محدد.

لحل التعارض، يجب عليك القيام بما يلي:

**1.** حدد مكتبات خدمات Google Play المستخدمة بالفعل في المشروع. تحقق من الدلائل `${UNREAL_PROJECT}/Intermediate/Android/APK/JavaLibs` و `${UNREAL_PROJECT}/Intermediate/Android/APK/libs`. على سبيل المثال، في [المشروع النموذجي](https://github.com/Pushwoosh/pushwoosh-unreal-engine) الذي تم إنشاؤه باستخدام Unreal Engine 4.15 توجد المكتبات التالية:

JavaLibs:

*   downloader_library
*   play-services-ads-lite-9.2.0
*   play-services-auth-base-9.2.0
*   play-services-basement-9.2.0
*   play-services-drive-9.2.0
*   play-services-gass-9.2.0
*   play-services-plus-9.2.0
*   support-v4-23.0.0
*   play-services-ads-9.2.0
*   play-services-auth-9.2.0
*   play-services-base-9.2.0
*   play-services-clearcut-9.2.0
*   play-services-games-9.2.0
*   play-services-nearby-9.2.0
*   play-services-tasks-9.2.0
*   pushwoosh-ue-plugin // تمت إضافته بواسطة Pushwoosh plugin

libs:

*   SystemUtils.jar
*   VrApi.jar
*   play-services-gcm-9.2.0.jar // تمت إضافته بواسطة Pushwoosh plugin
*   play-services-iid-9.2.0.jar // تمت إضافته بواسطة Pushwoosh plugin

**2.** إذا كانت إصدارات مكتبات play-services* المستخدمة في Pushwoosh و Unreal Engine غير متطابقة، فقم بإزالة هذه المكتبات من [Pushwoosh plugin](https://github.com/Pushwoosh/pushwoosh-unreal-engine/tree/master/Plugins/Pushwoosh/lib/Android/JavaLibs/pushwoosh-ue-plugin).

**3.** حدد المكتبات المفقودة التي يجب إضافتها إلى Pushwoosh Plugin. يتطلب الملحق مكتبات android-support-v4، play-services-base، play-services-basement، play-services-gcm، play-services-iid. بالنسبة للمشروع النموذجي، لا تتداخل سوى **play-services-gcm** و **play-services-iid**، لذا فهي المكتبات الوحيدة التي يجب إضافتها في هذه الحالة بالذات.

**4.** أضف المكتبة عن طريق وضع ملف .jar من Android SDK في [https://github.com/Pushwoosh/pushwoosh-unreal-engine/tree/master/Plugins/Pushwoosh/lib/Android/libs](https://github.com/Pushwoosh/pushwoosh-unreal-engine/tree/master/Plugins/Pushwoosh/lib/Android/libs). تم وصف موقع مكتبات Google Play في بداية هذا المقال.

## شاركنا ملاحظاتك

تساعدنا ملاحظاتك في إنشاء تجربة أفضل. إذا واجهت أي صعوبات أثناء عملية دمج SDK، فشاركنا أفكارك [عبر هذا النموذج](https://docs.google.com/forms/d/e/1FAIpQLSd_0b8jwn-V_JmoPLIxIFYbHACCQhrzidOZV3ELywoQPXRSxw/viewform).