Android multidex build issue

Hi,

I’m having some problems building my game starting today. I’ve been building my game with Unity 2017.4.x for a while now using Mutidex definied in a custom gradle file, which I have attached, with the changes from the highlighted:

// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
    }
}

allprojects {
   repositories {
      google()
      jcenter()
      flatDir {
        dirs 'libs'
      }
   }
}

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:multidex:1.0.1'
**DEPS**}

android {
    compileSdkVersion **APIVERSION**
    buildToolsVersion '**BUILDTOOLS**'

    defaultConfig {
        targetSdkVersion **TARGETSDKVERSION**
        applicationId '**APPLICATIONID**'
        multiDexEnabled true
        ndk {
            abiFilters **ABIFILTERS**
        }
    }

    lintOptions {
        abortOnError false
    }

    aaptOptions {
        noCompress '.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**
    }

**SIGN**
    buildTypes {
          debug {
            minifyEnabled **MINIFY_DEBUG**
            useProguard **PROGUARD_DEBUG**
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
              jniDebuggable true
          }
          release {
            minifyEnabled **MINIFY_RELEASE**
            useProguard **PROGUARD_RELEASE**
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
              **SIGNCONFIG**
          }
    }
**PACKAGING_OPTIONS**
    bundle {
        language {
            enableSplit = false
        }
        density {
            enableSplit = false
        }
        abi {
            enableSplit = true
        }
    }
}


**SOURCE_BUILD_SETUP**

I was informed by Unity today during a build that my Android Build Tools were out of date and I should update them to 28, which I allowed it to do. I’m not sure if anything else updated in the background, but now I get a really odd error when building.

Execution failed for task ':processReleaseManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 4 declared in library [com.android.support:multidex:1.0.2] C:\Users\alan_\.gradle\caches\transforms-1\files-1.1\multidex-1.0.2.aar\4040f530868e9b5988bc4ae7c19735b6\AndroidManifest.xml as the library might be using APIs not available in 1
      Suggestion: use a compatible library with a minSdk of at most 1,
          or increase this project's minSdk version to at least 4

Now, I’ve searched through all my manifests for anything that specified minSdkVersion, but they’re all way above 1 (most are 16), so I’m really stumped. I tried rolling back to build tools 27.3 and still get the same error, so something else has changed somewhere.

Any suggestions?

Thanks

Alan

OK - I’ve sort of figured it out. For some reason, I had to go through all of the Android Manifests I had from 3rd parties and add in <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" /> to each one. There were some manifests that didn’t define this value, which are the ones I’m assuming are reporting as version 1?

Is this a new requirement for Android or something Unity has changed? I’ve updated to 2017.4.18 as well which I didn’t mention earlier.

Hello! Try this:

android {
defaultConfig {
minSdkVersion MINSDKVERSION // add this line in gradle template
}
}

Thank you, I’ll give it a go

For me, just changing the AndroidManifest.xml worked

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.yusufolokoba.natrender"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="16" />

</manifest>

Just changing the last line for the version you wanted.