AAPT2 error in Android Studio 3.0.1

I am trying to get the "hello world" application using Android Studio 3.0.1 and get the following error output from AAPT2:

Error:(16) error: not well-formed (invalid token).
Error:(16) not well-formed (invalid token).
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details...

I was not able to find a solution, can someone help me?

+6
source share
8 answers

android.enableAapt2 = false Do not take this step to temporarily hide the problem. Aapt1 will soon be deprecated, and Aapt2 should be used by the end of 2018.

This is just a problem with Gradle build tools. Just update your gradle and gradle tools.

classpath 'com.android.tools.build:gradle:3.3.0-alpha02' ' Gradle , Gradle 4.8. .

,

+5

" " AAPT2 , XML , , - . , . res/ .

+2

, , AAPt2

AAPT2:

.

, , Debug,

Debug.

enter image description here

png . .

+1

gradle.properties android.enableAapt2=false

0

Instant Run, .

0

. RelativeLayout TextView ProgressBar. Progressbar TextView, :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="1"
    tools:context="com.caoa.yakokoe.yakokoe.ui.splash.SplashActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.5">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:contentDescription="@string/content_desc_logo_green"
            android:src="@drawable/logo_green" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.5">

        <ProgressBar
            android:id="@+id/splash_progress_bar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@id/splash_text"
            android:layout_centerHorizontal="true"
            android:indeterminate="true"
            android:visibility="gone" />

        <TextView
            android:id="@+id/splash_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="24dp"
            android:layout_marginTop="16dp"
            android:text="@string/splash_text_default"
            android:textAlignment="center"
            android:visibility="gone" />
    </RelativeLayout>
</LinearLayout>

- (, , " layout_above").

ProgressBar TextView Locations, :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="1"
    tools:context="com.caoa.yakokoe.yakokoe.ui.splash.SplashActivity">

    <!-- Content here -->

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.5">

        <TextView
            android:id="@+id/splash_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="24dp"
            android:layout_marginTop="16dp"
            android:text="@string/splash_text_default"
            android:textAlignment="center"
            android:visibility="gone" />

        <ProgressBar
            android:id="@+id/splash_progress_bar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@id/splash_text"
            android:layout_centerHorizontal="true"
            android:indeterminate="true"
            android:visibility="gone" />
    </RelativeLayout>
</LinearLayout>
0

,

compileSdkVersion 22 compileSdkVersion 25

targetSdkVersion 22 to targetSdkVersion 25

'com.android.support:appcompat-v7:22' 'com.android.support:appcompat-v7:25'

.

0

. build.gradle (: )

defaultConfig {
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
}
0

Source: https://habr.com/ru/post/1692938/


All Articles