Search Unity

  1. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  2. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  3. If you couldn't join the live stream, take a peek at what you missed.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Java 8 aar library requires minimum sdk version 26

Discussion in 'Android' started by abhipray, Nov 11, 2017.

  1. abhipray

    abhipray

    Joined:
    Jan 30, 2017
    Posts:
    2
    I am trying to add an android library with Java 8 features to Unity. I get the following error while trying to build:

    CommandInvokationFailure: Unable to convert classes into dex format.
    /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir="/Users/abhipray/Library/Android/sdk/tools" -Dfile.encoding=UTF8 -jar "/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/sdktools.jar" -

    stderr[
    Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
    1 error; aborting
    ]

    I don't see an option for min-sdk-version as 26 via player settings using unity 2017.3.0b8.

    How do I set the min-sdk-version to 26 or is there another solution to this error?
     
  2. abhipray

    abhipray

    Joined:
    Jan 30, 2017
    Posts:
    2
    Found a solution. I fixed this by using the Gradle build option and adding a .gradle file to Plugins/Android/mainTemplate.gradle. The gradle file needs the following:
    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }

    Unity comes bundled with gradle-wrapper 4.0.1 but because 1.8 language features require gradle, I replaced 4.0.1 found in Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/gradle with 4.1.
     
  3. iamadamdev

    iamadamdev

    Joined:
    Jun 27, 2017
    Posts:
    1
    I am running into the same issue but unfortunately your solution didn't work for me. Still getting

    Unable to convert classes into dex format.
    Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)

    Anyone have any ideas?