任务':app:transformClassesWithMultidexlistForDebug'的执行失败。> java.lang.UnsupportedOperationException(无错误消息)

兰妮·威廉姆斯

我不确定为什么会这样,但是我做了一些挖掘,并试图找到其他解决方案。没有人解决特别重复的问题:

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

}

我删除了一些重复的副本compiles,但仍然没有帮助。我在跟踪中注意到此警告:

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

我不知道这是否会导致整个事情失败。最后是我的清单:

<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>

当我尝试获得成功的构建时遇到的每个问题,我都在SO或其他来源上寻找,但这是很重要的。我从来没有插入compile "com.android.support:multidex:1.0.1"过,并且在出现此问题之前它就起作用了。仍然没有成功。

我记得做的最后一件事是在主目录中保存一个名为“ safecode.js”的文件,基本上它只包含我要保存的代码。

安德鲁一世

我遇到了完全相同的问题,并且我知道这可能会令人头疼。这是我的解决方案:

1)确保build.gradle中没有重复的依赖项settings.gradle

2)你们中的大多数人可能不喜欢这个,但是我(要求键入)升级了大多数东西,例如:

  • 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

注意:您的命令提示符的生成UI将会更改,看起来确实很庞大,但是很酷。您会习惯的。此外,您可能需要更改这些compilebuild.gradle不久。

这是解决方案:Android Studio build.gradle警告消息

差不多就可以了,但是我也会告诉您我所做的其他事情可能会影响您的工作BUILD FAILED

1)您可能需要Java8。JDK1.8。将此添加到build.gradle app directory

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

2)摆脱 compile "com.android.support:multidex:1.0.1"

3) targetSdkVersion 22 update to 26

最后,

4)在中build.gradle not in app directory,放入maven { url 'https://maven.google.com' }两个存储库。

注意:您可以google()代替它,但是它对我不起作用,所以我坚持使用maven { url 'https://maven.google.com' }

另请注意:您可能会收到消息,说"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."嘿,26似乎是我们的魔法数字,如果有效,那就不要碰它。除非您绝对确定需要。

据我所知和经验,您从构建过程中获得的警告不会影响您BUILD SUCCESSBUILD FAILED

我希望这对每个人都有效!

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章