user7637750
user7637750

Reputation:

AAPT2 error: check logs for details(Build failed)

I just backed to my old project as I have been along time didn't work on it and I found a lot of errors as a build error in gradle as I use the compile instead implementation and many other process I tried to solve this error a lot but I failed as this my window error that's I couldn't recognize as I used also old Libraries from github

this is myGradle (build.gradle(Project:Waiterer))

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

and this is build.gradle(Module:app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "abtech.waiteriano.com.waitrer"
        minSdkVersion 18
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation project(':jtds-1.3.1')
    implementation project(':library')
    implementation project(':librarySV')
    implementation 'com.android.support:support-v4:25.2.0'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:25.3.1'
    implementation 'com.roughike:bottom-bar:1.3.9'
    implementation 'com.android.support:recyclerview-v7:25.2.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'
    implementation 'com.github.clans:fab:1.6.2'
    implementation 'de.hdodenhof:circleimageview:1.3.0'
    implementation 'com.android.support:cardview-v7:25.3.1'
    testImplementation 'junit:junit:4.12'
    implementation "com.android.support:gridlayout-v7:23.1.1"
}

and this my first gradle library I use build.gradle(Module:library)

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion '27.0.3'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:23.1.1'
}

and this is my second library I use build.gradle(Module:librarySV)

apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.novoda:bintray-release:0.8.1'
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.0'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.4.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:23.1.1'
    implementation 'com.android.support:design:23.1.1'
}

publish {
    userOrg = 'miguelcatalan'
    groupId = 'com.miguelcatalan'
    artifactId = 'materialsearchview'
    publishVersion = '1.4.0'
    desc = 'Cute library to implement SearchView in a Material Design Approach'
    website = 'https://github.com/MiguelCatalan/MaterialSearchView'
}

hope this could be clear enough If any some thing not clear tell me Note that: I am not using API I use JDBC JTDS Connection to retrieve data from data base

Upvotes: 1

Views: 2859

Answers (2)

Izabela Orlowska
Izabela Orlowska

Reputation: 7532

Okay, so the problem is with the AndroidManifest in your app module:

    <activity android:name=".Main2Activity">
        <service
            android:name="SoftKeyboard"
            android:permission="android.permission.BIND_INPUT_METHOD"
            tools:ignore="WrongManifestParent">
            <intent-filter>
                <action android:name="android.view.InputMethod" />
            </intent-filter>
            <meta-data
                android:name="android.view.im"
                android:resource="@xml/method" />
        </service>

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

According to the documentation the 'service' element must be nested under 'application' not 'activity'. So change that part of code to:

    <activity android:name=".Main2Activity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <service
        android:name="SoftKeyboard"
        android:permission="android.permission.BIND_INPUT_METHOD"
        tools:ignore="WrongManifestParent">
        <intent-filter>
            <action android:name="android.view.InputMethod" />
        </intent-filter>
        <meta-data
            android:name="android.view.im"
            android:resource="@xml/method" />
    </service>

This will fix the error you are getting from AAPT2. For your project to build successfully you will also need to update your dependencies as described here. If you do both, everything should build correctly. :)

Upvotes: 0

Khemraj Sharma
Khemraj Sharma

Reputation: 59004

Thing is developers are not comfortable to new AS still. Way of showing error is changed (is weird now).

First scroll to down in build errors. If you see an error, click to expand it. It will show you error most probably.

enter image description here

Second If that does not work (like i faced in data binding, where no errors were shown)

Then try build with debug or stacktrace

Go to

File > Settings > Build, Execution, Deployment > Compiler

add like this (add --stacktrace or --debug), it will log the exceptions. You can see what is causing issue.

screenshot

Upvotes: 1

Related Questions