Upgraded to Android studio 3.4 - Aapt2InternalException: AAPT2: Daemon startup failed

妖精的绣舞 提交于 2019-11-27 07:40:21

I had a same problem. Currently,the best option is to downgrade your class path to the last stable version. For me, i changed my class path to *classpath 'com.android.tools.build:gradle:3.3.2'*and it worked for me. In Android studio 3.4, you can easily downgrade Android Gradle Plugin Version.

  1. Go to File->Project-Structure->Project
  2. Change Android Gradle Plugin Version to 3.3.2 or the last stable version for you
  3. Change the Gradle Version to 4.10.1
  4. Click Ok and sync
  5. Build Apk

You might consider disabling the aaptOptions like the following. Add this in the android section in your build.gradle file.

android {
    aaptOptions.cruncherEnabled = false
    aaptOptions.useNewCruncher = false
}

And add the following line in your gradle.properties file.

android.enableAapt2=false

Project level gradle update classpath:

classpath 'com.android.tools.build:gradle:3.4.0'

gradle-wrapper.properties update distributionUrl:

distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

After these steps delete .iml file from your project directory and rebuild the project For further detail please see attached image

  1. Go to File->Project-Structure->Project Change Android Gradle Plugin Version to 3.3.2 or the last stable version for you Let the Gradle
    Version to 5.1.1 Click Ok and sync

it was working but it not use updated gradle 3.4.0

enter image description here

Use this build.gradle in your project


apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.fileobserver"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

Top level build.gradle downgrade version 
buildscript {
    ext.kotlin_version = '1.3.31'
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!