Laney Williams
Laney Williams

Reputation: 593

Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. > java.lang.UnsupportedOperationException (no error message)

I am not sure why this is happening, but I did some digging and tried to find other solutions. None worked out especially duplicate questions:

android {
compileSdkVersion 26
buildToolsVersion "23.0.3"

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
    all*.exclude group: 'com.android.support', module: 'support-annotations'
}

defaultConfig {
    applicationId "com.myapp"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }


}

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':react-native-customized-image-picker')
    compile project(':react-native-vector-icons')
    compile project(':react-native-restart')
    compile project(':react-native-image-picker')
    compile project(':react-native-fast-image')
    compile project(':lottie-react-native')
    compile project(':react-native-fetch-blob')
    compile "com.android.support:multidex:1.0.1"
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.fresco:fresco:1.0.1"
    compile "com.facebook.fresco:animated-gif:1.0.1"
    compile("com.facebook.react:react-native:0.54.0") { force = true }  // From node_modules

}

I deleted some duplicate compiles that I found and still no help. I noticed in the trace this warning:

C:\ReactProjects\myapp\android\app\src\main\AndroidManifest.xml:11:5-29:19 Warning: application@android:theme was tagged at AndroidManifest.xml:11 to replace other declarations but no other declaration present C:\ReactProjects\myapp\android\app\src\main\AndroidManifest.xml:16:9-19:35 Warning: meta-data#com.bumptech.glide.integration.okhttp.OkHttpGlideModule was tagged at AndroidManifest.xml:16 to remove other declarations but no other declaration present

I don't know if that will cause this whole thing to fail. Lastly here is my manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:allowBackup="true"
  tools:replace="android:theme"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

Every problem that I had when trying to get a successful build I looked on SO or other sources, but this one takes the cake. I never inserted compile "com.android.support:multidex:1.0.1" before and it worked before this problem occurred. Still no success.

The last thing I remembered doing is saving a file called 'safecode.js' in the home directory and basically it just has code that I want to save.

Upvotes: 3

Views: 1617

Answers (1)

Andrew I.
Andrew I.

Reputation: 252

I had the exact same problem and I understand what a headache this can be. Here was my solution:

1) Make sure there are no duplicate dependencies in build.gradle and settings.gradle

2) Most of you might not like this one, but I (hurts to type this) upgraded most things such as:

  • compileSdkVersion 26 - build.gradle

  • buildToolsVersion "26.0.1" - build.gradle

  • distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip - settings.gradle
  • classpath 'com.android.tools.build:gradle:3.1.0' - build.gradle not in app directory

NOTE: Your Command Prompt's build UI will change and it does look overwhelming, but pretty cool. You'll get used to it. Also, you might need to change those compile in build.gradle soon.

Here is the solution for that: Android Studio build.gradle warning message

That should be pretty much it, but I'll also tell you other things I did that might affect your BUILD FAILED:

1) You might need Java 8. JDK 1.8. Add this to build.gradle app directory:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

2) Get rid of compile "com.android.support:multidex:1.0.1"

3) targetSdkVersion 22 update to 26

And lastly,

4) In build.gradle not in app directory, put maven { url 'https://maven.google.com' } in both repos.

NOTE: You could use google() in place of that, but it didn't work for me so I stuck with maven { url 'https://maven.google.com' }.

ALSO TO NOTE: You might get messages saying, "WARNING: The specified Android SDK Build Tools version (26.0.1) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.0.". Hey, 26 seems to be our magic number, if it works, then don't touch it. Unless you are absolutely certain you need to.

To my knowledge and experience the warnings you get from the build process won't affect your BUILD SUCCESS or BUILD FAILED.

I hope this works for everyone!

Upvotes: 2

Related Questions