Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  5. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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?