ProgramingTip

오류 : ': app : transformClassesWithDexForDebug'작업에 대한 실행이 실패했습니다.

bestdevel 2020. 10. 29. 08:23
반응형

오류 : ': app : transformClassesWithDexForDebug'작업에 대한 실행이 실패했습니다.


오류

오류 : ': app : transformClassesWithDexForDebug'작업에 대한 실행이 실패했습니다. com.android.build.transform.api.TransformException : com.android.ide.common.process.ProcessException : org.gradle.process.internal.ExecException : 프로세스 'command'/ usr / lib / jvm / java-8-oracle / bin / java ''가 0이 아닌 종료 값 1로 완료되었습니다.

내 앱 gradle 파일 :

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    defaultConfig {
        applicationId 'Hidden application ID'
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        disable 'InvalidPackage'
    }
    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }
    productFlavors {
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.facebook.android:facebook-android-sdk:4.7.0'
    compile 'com.googlecode.libphonenumber:libphonenumber:7.2.1'
    compile 'com.getbase:floatingactionbutton:1.10.1'
    compile 'com.android.support:preference-v7:23.1.1'
}

필요한 동안 minifyEnabled를 true로 설정하면 수행됩니다. 그러나 내 응용 프로그램은 존재하지 않습니다.

나는이 다른 질문을 확인 했습니다 : Android 용 Google 로그인을 구현하는 동안 ': app : transformClassesWithDexForDebug'작업에 대한 실행이 실패 했지만 대답은 하나 뿐이며 불행히도 문제를 해결하지 못합니다.

AFAIK, Gradle 오류가 발생하지만 많이 추가되어 오류가 있습니다. (이 모든 패키지가 정말 중요하기 때문에 틀 렸으면 좋!).

이 오류를 해결하도록 도와주세요. 대단히 감사합니다!


Google Play 서비스를 수정하십시오.

프로젝트에 모든 플레이 서비스를 포함하고 있습니다. 원하는 것만 추가하십시오.

예를 들어지도와 G + 로그인 만 사용하는 경우

 compile 'com.google.android.gms:play-services:8.1.0'

...에

compile 'com.google.android.gms:play-services-maps:8.1.0'
compile 'com.google.android.gms:play-services-plus:8.1.0'

문서에서 :

6.5 이전 버전의 Google Play 서비스에서는 전체 API 패키지를 앱으로 준비해야합니다. 경우에 따라 앱의 메소드 수 (프레임 워크 API, 라이브러리 메소드 및 자체 코드 포함)를 65,536 제한으로 유지하기가 더 어려워졌습니다.

버전 6.5부터는 Google Play 서비스 API를 선택적으로 앱으로 선택할 수 있습니다. 예를 들어 Google Fit 및 Android Wear API 만 포함 비용 build.gradle 파일에서
'com.google.android.gms : play-services : 8.3.0' 줄을 다음 줄로 바꿉니다
.

'com.google.android.gms : play-services-fitness : 8.3.0'
'com.google.android.gms : play-services-wearable : 8.3.0'컴파일

전체 목록은 여기에서 수 있습니다 .


시험

dexOptions {
    javaMaxHeapSize "4g"
    preDexLibraries = false
}

이유를 모르겠습니다. 관련 사항 preDexLibraries: https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/tips

@ lgdroid57에 따르면 :

다음 리소스는 코드의 기능을 설명하는 데 도움이됩니다. 링크 ( http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.DexOptions.html ) 속성 | 설명 javaMaxHeapSize | dx를 호출 할 때 -JXmx * 값을 설정합니다. 형식은 1024M 패턴을 따라야합니다. preDexLibraries | 라이브러리를 pre-dex할지 여부입니다. 이것은 증분 빌드를 개선 할 수 있도록 클린 빌드는 느릴 수 있습니다.


multiDexEnabled truebuild.gradle파일에 추가 추가 .

  defaultConfig {
    multiDexEnabled true
}

이것이 Multidex에 대한 문제입니다. 일부 jar를 제거하거나 다음과 같이 시도 할 수 있습니다. http://developer.android.com/tools/building/multidex.html#mdex-gradle in app build.gradle :

    defaultConfig {
        ...
        minSdkVersion 14
        targetSdkVersion 21
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
dependencies {
  compile 'com.android.support:multidex:1.0.0'
}

매니페스트에서 :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.multidex.myapplication">
    <application
        ...
        android:name="android.support.multidex.MultiDexApplication">
        ...
    </application>
</manifest>

추가 multiDexEnabled true에서 default config filebuild.gradle이 같은

    defaultConfig {
        multiDexEnabled true
       }

저에게 개인적으로 도움이 된 솔루션은 다음과 다양합니다.

build.gradle

defaultConfig {
        multiDexEnabled true
    }

 dexOptions {
        javaMaxHeapSize "4g"
    }

내 응답은 약간 오래 내 유일한 솔루션은 다음과 같이 defaultConfig에 multiDexEnabled 옵션을 추가하는 것입니다.

    android{
        ...
        defaultConfig{
            ...
            multiDexEnabled true
        }
    }

이것이 작동하지 다음 코드를 추가해 작동합니다.

    configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '26.1.0'
            }
        }
    }
}

내 오류는 다른 라이브러리 버전의 문제와 관련이 있고 이것이 트릭을 만들었습니다.

나는 그것이 누군가를 도울 수 있기를 바랍니다 :)


두 가지 버전의 Google 서비스를 사용하고 있지 않은지 확인하세요.

예 :

compile 'com.google.firebase:firebase-messaging:9.8.0'

compile 'com.google.firebase:firebase-ads:10.0.0'

Android Studio가 제안한대로 Gradle 버전 버전 1.2.3에서 1.5.0 업데이트 할 때 문제가 발생했습니다. 그에서 웹 페이지 , 1.5.0이 나타납니다 베타 버전이 될 수 있습니다.

솔직히 1.5.0 버전이 어떤 가능성이 있는지 모르겠지만 앞으로 나올 버전이 있습니다.

물론 1.2.3으로 돌아가서 문제가 해결되었습니다.


가능한 도움

다른 모든 옵션을 다 실험 후 절대 최후의 수단으로 시도했습니다.

모든 메모리 스틱 (RAM)을 제거했지만 하나는 제거했습니다. 이제 메모리가 적지 만 다시 작동합니다. 한 이유 또는 본 원인이 100 % 인 경우-다른 라이브러리에서는 시스템 빌드가 실행 된 이유를 아는 척할 수 없습니다. 아마도 이것은 시도해 볼 수 있습니다. 행운을 빕니다.


다른 모든 Android Studio를 닫으면 문제가 해결되었습니다.

오류가 발생했을 때 3 개의 안드로이드 스튜디오를 열람 할 수 있습니다.

multiDex와 관련된 코드를 추가 할 필요가 없습니다!


멀티 텍스가 필요 없습니다. Android Studio 2.1에서 열린 "이전"프로젝트의 경우 gradle 버전을 1.5.0에서 2.1.0으로 변경하여 문제를 해결했습니다.

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

내가 해결 했어! 구성 및 업데이트 모음입니다. build.gradle에 맞는 곳에 설치된 변수를 추가하십시오.

android {
packagingOptions {
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
}
dexOptions {
    javaMaxHeapSize "4g"
}
defaultConfig {
    multiDexEnabled true
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}
}

그런 다음 Java 8로 업데이트하면 http://tecadmin.net/install-oracle-java-8-jdk-8-ubuntu-via-ppa/모든 것이 해결됩니다! buildTools업데이트와 새로운 Android 스튜디오 때문입니다 . 다른 것은 실패하지 않습니다.


변경하여

'com.google.android.gms : play-services : 8.1.0'컴파일

필요한 파일로만 문제를 해결할 수 있습니다.이 문제는 build.gradle 파일의 파일을 초과하여 발생합니다.


빌드-> 정리로 이동하여 앱을 다시 실행하십시오.


빌드로 이동->

깨끗한 프로젝트->

프로젝트 실행 : 완료

나를 위해 안드로이드 5.1에서 작업


ionic을 사용하여 "cordova clean"명령을 사용하여이 오류를 수정할 수있었습니다.


SSH를 통해 컴파일 작업을 Google Compute Engine에 위임 할 때이 문제가 발생했습니다 . 이 문제의 본질은 충돌 로그에 표시된 것처럼 메모리 오류입니다. 특히 Java가 빌드 중에 작업 할 가상 메모리가 부족할 때 발생합니다.

중요 : 이 메모리 오류로 인해 gradle이 충돌하면 컴파일 작업이 실패한 후에도 gradle 데몬이 계속 실행됩니다. 다시 gradle을 사용하여 빌드를 다시 시도하면 새 gradle 데몬이 할당됩니다. 사용하여 충돌 한 인스턴스를 올바르게 처리 해야합니다 gradlew --stop .

hs_error_pid충돌 로그는 다음과 같은 대안을 나타냅니다 :

# There is insufficient memory for the Java Runtime Environment to continue.
# Possible reasons:
#   The system is out of physical RAM or swap space
#   In 32 bit mode, the process size limit was hit
# Possible solutions:
#   Reduce memory load on the system
#   Increase physical memory or swap space
#   Check if swap backing store is full
#   Use 64 bit Java on a 64 bit OS
#   Decrease Java heap size (-Xmx/-Xms)
#   Decrease number of Java threads
#   Decrease Java thread stack sizes (-Xss)
#   Set larger code cache with -XX:ReservedCodeCacheSize=

가상 머신의 런타임 리소스를 늘린 후이 문제가 해결 되었음을 알았습니다 .


비슷한 오류가 발생했습니다. 디렉토리를 전환하여 수정했습니다. 내 git 저장소에서 프로젝트를 다시 복제하고 Android 스튜디오로 가져와 빌드합니다. 프로젝트를 빌드 할 때 Android Studio에서 생성 된 디렉토리 / 파일 중 하나가 손상되었을 수 있습니다. 프로젝트에서 모든 Android Studio 생성 파일을 삭제하거나 내가 한 작업을 수행하면 문제를 해결할 수 있습니다. 도움이 되었기를 바랍니다.


이 문제에 직면 한 모든 분들께 / 앞으로 직면하게 될 것입니다 :

빌드 메뉴를 클릭-> 빌드 변형 선택-> '디버그'로 복원

module : app / * debug {debuggable true} * /에서 디버깅 가능에 대한 결과

빌드 메뉴로 이동-> 서명 된 APK 생성-> ....-> 빌드


파일 맨 아래에서 플러그인 적용 선언을 이동합니다.

플러그인 적용 : 'com.google.gms.google-services'


분명히 나는 ​​안드로이드 매니페스트에 다음을 추가하는 모든 솔루션을 결합하여 문제를 해결했습니다.

<application
...
        android:name="android.support.multidex.MultiDexApplication" >
...
</application>

build.gradle 앱 모듈에 따라

android {
...

    dexOptions {
        javaMaxHeapSize "4g"
        preDexLibraries = false
    }
...
    defaultConfig {

        multiDexEnabled true

   }

}

  1. 실행 : cordova plugin rm cordova-plugin-compat --force
  2. 실행 : cordova plugin add cordova-plugin-compat@1.2
  3. 변경 사항 : 프로젝트 폴더의 config.xml은 "^ 6.2.3"이 아닌 "6.2.3"을 사용하고, 플랫폼 / 안드로이드 폴더를 삭제하고, 코도 바 준비 안드로이드를 다시 실행하고, 코도 바 빌드 안드로이드

build폴더를 모두 제거 /android하고/android/app

그리고 다시 빌드 react-native run-android


미쳐 가지마 그냥 청소하고 프로젝트를 다시 빌드하고 오류가 사라졌습니다.


Android 기기에서 Ionic 프로젝트를 실행할 때이 오류가 발생했으며 Android 플랫폼을 제거하고 추가하여 해결했습니다.

ionic cordova platform remove android
ionic cordova platform add android

자바 8 이상을 사용하는 경우 문제는 우리가 사용하는 라이브러리가 자바 8과 호환되지 않는다는 것입니다. 따라서이 문제를 해결하려면이 두 줄을 앱의 build.gradle에 추가하고있는 경우 모든 하위 모듈을 추가합니다. (Android 스튜디오는 오류 메시지에이를 수행하는 방법을 명확하게 보여줍니다.)

targetCompatibility = '1.7'sourceCompatibility = '1.7'

참고 URL : https://stackoverflow.com/questions/33717886/errorexecution-failed-for-task-apptransformclasseswithdexfordebug

반응형