yandexmobile / metrica-plugin-cordova

Cordova plugin for Yandex AppMetrica SDK
Other
11 stars 26 forks source link

fix error #6

Open SergeyKatugin opened 6 years ago

SergeyKatugin commented 6 years ago

fix error with AndroidManifest.xml on cordova version 7+

SergeyKatugin commented 6 years ago

https://github.com/apache/cordova-android/blob/59018ab632e99b3e45a0bf9657c70282aeeac7bf/bin/templates/cordova/lib/AndroidStudio.js

this file detect eclipse IDE and broke correct url(because has a folder with name libs), when you use cordova 7+ version

artuska commented 6 years ago

После того, как поменяли libs на thirdparty-libs выскакивает такая ошибка при билде:

* What went wrong:
Could not resolve all files for configuration ':app:releaseCompileClasspath'.
> Could not find :mobmetricalib-2.78:.
  Searched in the following locations:
      file:/private/var/www/balu/balumates-ru-frontend/cordova/platforms/android/app/libs/mobmetricalib-2.78-.aar
      file:/private/var/www/balu/balumates-ru-frontend/cordova/platforms/android/app/libs/mobmetricalib-2.78.aar
  Required by:
      project :app
NesterovichAlexey commented 6 years ago

@artuska поменяй ещё в файле platforms/android/build.gradle в 5 строчке libs на thirdparty-libs

artuska commented 6 years ago

Ну он всё равно пытается искать в папке /app — что libs, что thirdparty-libs:

* What went wrong:
Could not resolve all files for configuration ':app:releaseCompileClasspath'.
> Could not find :mobmetricalib-2.78:.
  Searched in the following locations:
      file:/private/var/www/balu/balumates-ru-frontend/cordova/platforms/android/app/thirdparty-libs/mobmetricalib-2.78-.aar
      file:/private/var/www/balu/balumates-ru-frontend/cordova/platforms/android/app/thirdparty-libs/mobmetricalib-2.78.aar
  Required by:
      project :app
artuska commented 6 years ago

В общем, всё равно получаю ошибку:

cordova plugin add yandex-appmetrica-plugin-cordova --save
Failed to install 'yandex-appmetrica-plugin-cordova': Error: ENOENT: no such file or directory, open '/private/var/www/balu/balumates-ru-frontend/cordova/platforms/android/AndroidManifest.xml'
NesterovichAlexey commented 6 years ago

Предлагаю такое решение: в файле build.gradle ничего не менять, в файле plugin.xml заменить libs на app/libs. Также удалить android платформу и плагин, затем занаво добавить android платформу и уже измененный плагин.

Проводил такие действия:

  1. cordova create hello com.example.hello HelloWorld
  2. cd hello
  3. cordova platform add android
  4. git clone https://github.com/yandexmobile/metrica-plugin-cordova.git metrica-plugin
  5. изменил в файле metrica-plugin/plugin.xml в 31 строчек libs/ на app/libs/
  6. cordova plugin add metrica-plugin --save
  7. cordova build android

Плагин добавляется и проект успешно собирается

P.S. cordova - 8.0.0, android - 7.0.0

SergeyKatugin commented 6 years ago

@NesterovichAlexey вы это поправите сами или мне сделать еще один pr?

NesterovichAlexey commented 6 years ago

сами