1

How can I define android's compileOptions within codenameone1 project ?

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }

Thanks in advance

2 Answers2

1

We don't support that at this time. There's an RFE to add this but I can't seem to find it right now in our issue tracker.

This is a bit problematic as integrating the Android builtin Java 8 support somewhat collides with our builtin Java 8 support. I'm assuming you need this to integrate native Android code, the solution for that is rather simple. Wrap it as an AAR library which is self contained and as such should work regardless of our settings.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • Thanks for your response, My native Android code is already wrapped in an aar library where compileOptions are defined, but not working ! .. The app crash when calling the aar library .. However, when i add the compileOptions to the build.gradle of the generated native source code & running from android studio it works. Is there any other solution to define it or force it from my aar? because i want to developp a cn1lib for codenameone developpers based on my aar library. – Ayoub Bouziane Jun 14 '20 at 15:23
  • I would like also to bring your attention to the fact that the apk build failed firstly and the error log advise me to add the compileoptions with sourceCompatibility = JavaVersion.VERSION_1_8 to the buld.gradle file or set the min sdk to api 26 .. and even when i set the min sdk to 26 , the apk is built successfully  but it crash when calling the sdk. – Ayoub Bouziane Jun 14 '20 at 16:40
  • There's an experimental flag `android.java8=true` in the build hints. I'm not sure if it will work or just fail everything but it's worth a shot – Shai Almog Jun 15 '20 at 02:17
  • I have used this flag but the build failed with an exception : 'Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method jackOptions() for arguments ' – Ayoub Bouziane Jun 15 '20 at 11:44
  • Is there any way to remove jackOptions from gradle or some workaround to overcome this error ?! – Ayoub Bouziane Jun 15 '20 at 13:40
  • Thanks, but when will the next update take place? .. Because I must deliver the cn1lib as soon as possible. – Ayoub Bouziane Jun 16 '20 at 10:21
  • We make a release every Friday – Shai Almog Jun 17 '20 at 02:47
1

The solution that works for me was adding this build hint: android.xgradle_default_config = compileOptions {sourceCompatibility 1.8; targetCompatibility 1.8}