7

This is actually one of my first Cordova plugin using lots of device specificities.

Context

My android project is composed of :

  • libs (vendors libs such as libGoogleAnalyticsServices.jar or android-support-v4.jar)
  • res (anim / drawable / values / xml ...)
  • src (my project Java specific sources)

In android, once the project is compiled, there is a specific file created to handle all my project definition and dependencies : com.myProject.R.java The android project referenced lots of R.drawable (for instance) and needs therefore to import the com.myProject.R.java

I want to use that Android Project into a Cordova plugin.

I have therefore created a fresh new directory for my cordova plugin: - created my node interface - copied my Android Source - updated plugin.xml to reference mt files / intent ...

What does work

With that cordova plugin created, I added it to my existing ionic project This project was using ANT for build is it is 6months old and has not yet been updated to gradle new build system.

I copied mannually the eclipse generated R.java to ANT-BUILD com/myProject/R.java and my project is working properly.

This one time step allows us to export easily a full android project to a Cordova plugin

What does not work

Ionic has updated it's build process and is using now Gradle. After updating my android platform (with cordova platform rm android / cordova platform add android)

I have the lots of following errors now (others issues are same) :

platforms\android\build\intermediates\res\debug\layout\main.xml:30: error: Error: No resource found that matches the given name (at 'text' with value '@string/vehicleDetailsDefaultTxt').

This issue is linked to the fact that my com.myProject.R.java is not founded / generated within the gradle build and the references object can't be found.

I have tried to manually put the R.java file into:

  • platforms\android\build\intermediates : (many different dir) - same problem
  • platforms\android\build\generated\source\r\debug : This is where the file Shall be IMO but before packaging, gradle clean the directory

How shall I reference the R.java ? Or how shall I auto-compile that R.java ? Or even better, how can I make an Android project (with layout / resources ...) an Cordova project so that I prevent any manual steps like I did before?

Feel free to ask me another other information concerning that issue. I'll answer ASAP

aorfevre
  • 4,854
  • 3
  • 19
  • 50

0 Answers0