Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AIR 33 doesn't support Java 8 features for Android extensions #84

Closed
itlancer opened this issue Aug 23, 2019 · 5 comments
Closed

AIR 33 doesn't support Java 8 features for Android extensions #84

itlancer opened this issue Aug 23, 2019 · 5 comments

Comments

@itlancer
Copy link

Problem Description

Android application cannot packaged if it use ANEs with Java 8 features such as lambda expressions, annotation etc.
It has been tested with different Windows 8.1/10 PCs for packaging with latests AIR 33.0.1.220 and AIR 33.0.1.228. For armv7 and armv8 build targets. Different 64-bit Java 8 versions was tried.
Compile options used in gradle for Android Studio project:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

The same problem in all cases.
Patching adt (mentioned here #48 ) doesn't help.

Related issue: #48

Steps to Reproduce

Create Java ANE for Android that uses some of Java 8 features. Lamda expressions for example in my case. Build ANE. Try to package Android application with apk-captive-runtime target.
Application example with sources for app and ANE with build scripts attached.
java8_ane.zip

public void init() {
        Activity mMainActivity = mFreContext.getActivity();
        View mMainView = mMainActivity.getWindow().getDecorView();
        mMainView.setOnClickListener((View view) -> Toast.makeText(mMainActivity, "Java 8 lambda feature test", Toast.LENGTH_LONG).show());
    }

Actual Result:
Application cannot be packaged. Got error:

dx tool failed:Uncaught translation error: com.android.dx.cf.code.SimException: ERROR in com.test.ane.Java8ANE.init:()V: invalid opcode ba - invokedynamic requires --min-sdk-version >= 26 (currently 13)
1 error; aborting

Expected Result:
Application will be packaged with Java 8 features support .

Known Workarounds

none

@ajwfrost
Copy link
Collaborator

FYI I think we have a fix or this - needs to be worked into the proper workflow, but we can look at adding the appropriate command line options and updating the other tools so that we support this.
AIR-199 internally..

@ajwfrost
Copy link
Collaborator

ajwfrost commented Sep 2, 2019

Hmm.. looks more complex than we first thought. We've got the workflow going without any errors from any of the Android tools but when we test this, it's throwing a bootstrap error. Needs further investigation...

@ajwfrost
Copy link
Collaborator

Updating other build tools within the SDK now allows us to use latest dex format which supports these Java 8 features - lambda test case is working. Will be included in the next release..

@ajwfrost
Copy link
Collaborator

ajwfrost commented Oct 9, 2019

Fixed in 33.0.2.281 which is now available from https://airsdk.harman.com/download
Please confirm and close this issue if it works for you!
thanks

@itlancer
Copy link
Author

For me now it works fine with AIR 33.0.2.281. Java 8 labmda feature works. A bit later will test with much more complex cases.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants