Android Studio 报出此错AAPT: error: unexpected element <intent-filter> found in <manifest><application>.

Posted 再见不是来时人

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android Studio 报出此错AAPT: error: unexpected element <intent-filter> found in <manifest><application>.相关的知识,希望对你有一定的参考价值。

出现错误:AAPT: error: unexpected element <intent-filter> found in <manifest><application>.

你的android Studio会出现:

你每次运行都会出现这个界面,你可能会有些崩溃,因为我当时学习的时候,我卡在此处,放弃了好长一段时间,不过随着我再次拾起Android开发,我逐渐觉得发现问题,解决问题,在学习道路上的快乐才能逐渐体现出来,不闲扯了,看看我的方法吧。

此界面为debug界面,切记不要在此界面更改代码(无效哦)

发现错误之后,我们首先调到main\\AndroidManifest.xml界面(当然你看到的这个界面是一个红色也没有的),然后找到<intent-filter></intent-filter>整体之间的代码位置错误,和默认的MainActivity对应的位置不对。

我也懂得大家在初学的时候都只是看着教学视频,看一步,做一步,看着看着,做着做着,就发现,人家教学没错,你的代码却出现了这个错误。

下面是错误的更改:

一定眼看清<intent-filter></intent-filter>此段代码一定要在你写

android:exported="true"

代码下的

<activity>
</activity>内

然后你写的这个地方所对应android:name="*****"的class文件就成了默认的主界面了

更改后的main\\AndroidManifest.xml界面是这样的:

接下来我们就能跑起来手机模拟器了

当然你如果想试一试在

android:exported="false"

代码下的

<activity>
</activity>内写,它就会很明确的提示你android:exported="false"此代码有错误,改成true就可以了。

当然你也可以重新建一个大项目作为解决此错误的办法,但是这样治标不治本(是因为教学视频中的老师希望在一个相关的知识点中能系统的给我们讲解,可以给我们带来联想,然后他们会带着我们更改默认的主界面,我们没有观察好,所以才会产生这个错误

 

下面是另一种更改默认主界面的方法:

 这个方法既简单,也不容易出错,就算出错那个错误报出的位置是具体的,所以还望大家在学习的时候看视频中的代码如果自己出错误,一定是自己对着敲出来的代码存在问题,平常学习是解决这种问题的最好办法就是多回放之前的代码,多观察,细观察,一定会发现错误的,学习嘛,就是在不断地发现问题解决问题,相信自己一定可以的。

 

更新后Android Studio 3.3到3.4 AAPT2生成错误

更新Android Studio 3.3到3.4之后会出现错误。它得到的错误是AAPT2,这让我建议我喜欢这个:

在此版本中使用了不推荐使用的Gradle功能,使其与Gradle 6.0不兼容。使用'--warning-mode all'显示各个弃用警告。看到

gradle.properties
org.gradle.warning.mode=all

但它仍然无法正常工作。

错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeIntroMakerDebugResources'.
> 8 exceptions were raised by workers:
  com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-windows Daemon #2: Daemon startup failed
  This should not happen under normal circumstances, please file an issue if it does.
  com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-windows Daemon #0: Daemon startup failed
  This should not happen under normal circumstances, please file an issue if it does.
  com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-windows Daemon #1: Daemon startup failed
  This should not happen under normal circumstances, please file an issue if it does.
  com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-windows Daemon #3: Daemon startup failed
  This should not happen under normal circumstances, please file an issue if it does.
  com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-windows Daemon #4: Daemon startup failed
  This should not happen under normal circumstances, please file an issue if it does.
  com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-windows Daemon #5: Daemon startup failed
  This should not happen under normal circumstances, please file an issue if it does.
  com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-windows Daemon #6: Daemon startup failed
  This should not happen under normal circumstances, please file an issue if it does.
  com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-windows Daemon #7: Daemon startup failed
  This should not happen under normal circumstances, please file an issue if it does.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 23s

这是Build.gradle文件:

buildscript {

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    // The Fabric Gradle plugin uses an open ended version to react
    // quickly to Android tooling updates
    classpath 'io.fabric.tools:gradle:1.+'
}
 }

plugins {
id "com.onesignal.androidsdk.onesignal-gradle-plugin" version "0.12.1"
 }

   apply plugin: 'com.android.application'
 //Put Fabric plugin after Android plugin
 apply plugin: 'io.fabric'
  apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
signingConfigs {
    config {
        keyAlias 'maker_key'
        keyPassword '!23342'
        storeFile 
       file('E:/axita.savani/Android_Project/AppCred/maker_key.jks')
        storePassword '!23342'
    }
}
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
    applicationId "com.example.myapplication"
    minSdkVersion 17
    targetSdkVersion 28
       vectorDrawables.useSupportLibrary = true
    multiDexEnabled true
    ndk {
        abiFilters "armeabi-v7a", "x86", "arm64-v8a"
    }
}
buildTypes {
    debug {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android- 
     optimize.txt'), 'proguard-rules.pro'
        zipAlignEnabled true
        shrinkResources false
        externalNativeBuild { ndkBuild { cFlags '-DDEBUG' } }
    }
    release {
        debuggable false
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android- 
     optimize.txt'), 'proguard-rules.pro'
        zipAlignEnabled true
        shrinkResources true
        externalNativeBuild { ndkBuild { cFlags '-DRELEASE' } }
    }
}

sourceSets {
    main {
        res.srcDirs =
                [
                        'src/main/res/layouts/activities',
                        'src/main/res/layouts/fragments',
                        'src/main/res/layouts/background',
                        'src/main/res/layouts/camera',
                        'src/main/res/layouts/sticker',
                        'src/main/res/layouts/text',
                        'src/main/res/layouts/editor',
                        'src/main/res/layouts/commom',
                        'src/main/res/layouts/other',
                        'src/main/res/layouts/videotrimmer',
                        'src/main/res/layouts/obgallarylib',
                        'src/main/res/layouts/template',
                        'src/main/res/layouts/eraser',
                        'src/main/res/layouts/user_guide',
                        'src/main/res/layouts/my_art',
                        'src/main/res/layouts/audio',
                        'src/main/res/layouts/video',

                        'src/main/res/layouts-land/activities',
                        'src/main/res/layouts-land/fragments',
                        'src/main/res/layouts-land/background',
                        'src/main/res/layouts-land/camera',
                        'src/main/res/layouts-land/sticker',
                        'src/main/res/layouts-land/text',
                        'src/main/res/layouts-land/editor',
                        'src/main/res/layouts-land/commom',
                        'src/main/res/layouts-land/other',
                        'src/main/res/layouts-land/my_art',

                        'src/main/res/layouts',
                        'src/main/res/layouts-land',
                        'src/main/res'
                ]
    }
}

  android {
    aaptOptions {
        ignoreAssetsPattern "!*ffprobe"
    }
    dexOptions {
        jumboMode true
    }
    lintOptions {
        disable 'GoogleAppIndexingWarning'
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in 
 release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
}

def flavorName = 'Maker'
// todo change in flavorname which app is used

externalNativeBuild {
    ndkBuild {
        path "src/${flavorName}/jni/Android.mk"
    }
}

flavorDimensions "default"

product flavors {

    // ONE SIGNAL IDs
        Maker {
        applicationId "com.example.maker"

        versionCode 9
        versionName "9.0"
        flavorDimensions "default"
        signingConfig signingConfigs.config
        setProperty("archivesBaseName", 
    "Business_$versionName.$versionCode")
    }


}

packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/LGPL2.1'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/notice.txt'
}
compileOptions {
    sourceCompatibility 1.8
    targetCompatibility 1.8
}
}

  dependencies {
/*TODO one Signal*/
implementation 'com.onesignal:OneSignal:3.10.6'

implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:appcompat-v7:28.0.0'
 //    implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
//implementation 'com.android.support:palette-v7:27.1.1'
implementation 'com.google.code.gson:gson:2.8.5'

 //    implementation 'com.github.yalantis:ucrop:2.2.1'
implementation 'com.github.yalantis:ucrop:2.2.2'

//    implementation 'com.kbeanie:multipicker:1.1.31@aar'
   //    implementation project(path: ':multipicker')

    /*database Dislay From chorome used this */
implementation 'com.facebook.stetho:stetho:1.5.0'

implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'

/* Pinch zoom image */
//implementation 'com.davemorrissey.labs:subsampling-scale-image- 
 view:3.6.0'

implementation 'com.viewpagerindicator:library:2.4.1@aar'

/*GIF Image View*/
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16'

/* YOYO animation*/
implementation 'com.daimajia.easing:library:2.0@aar'
implementation 'com.daimajia.androidanimations:library:2.3@aar'

implementation 'com.codemybrainsout.rating:ratingdialog:1.0.8'

/* FCM */
//    implementation 'com.google.firebase:firebase-messaging:15.0.2'
/* AdMob */
implementation 'com.google.firebase:firebase-ads:17.2.0'

/* InAppPurchase */
implementation 'com.android.billingclient:billing:1.2'

/* EU User Consent SDK */
implementation 'com.google.android.ads.consent:consent-library:1.0.7'

//For Crash analytics
implementation('com.crashlytics.sdk.android:crashlytics:2.9.7@aar') {
    transitive = true
}

implementation 'com.azeesoft.lib.colorpicker:colorpicker:1.0.9@aar'
implementation 
'com.h6ah4i.android.widget.verticalseekbar:verticalseekbar:0.7.2'


implementation 'nl.bravobit:android-ffmpeg:1.1.5'
implementation 'com.googlecode.mp4parser:isoparser:1.1.22'
/*storage for path */
implementation 'com.snatik:storage:2.1.0'
/*exo player for Audio and Video */
implementation 'com.devbrackets.android:exomedia:4.3.0'

/*Download file From Server */
implementation 'com.mindorks.android:prdownloader:0.5.0'

      /*Ob Volly library*/
implementation 'com.optimumbrew.corelib:networking-volly:8.0.8'
   /*Audio picker library */
implementation 'com.optimumbrew.picker:audiopicker:1.1.17'

/* Optimumbrew Image loader*/
implementation 'com.optimumbrew.obglide:obglide:2.0.2'
/* inhouse ads library*/
implementation 'com.optimumbrew.obinhouseads:obinhouseads:11.0.11'

implementation project(path: ':spacelib')

/*Video Tools*/
implementation project(':video-record')
implementation project(':video-compressor')
implementation project(':video-effect')

implementation 'com.daasuu:ExoPlayerFilter:0.2.3'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.1.5'
implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.4@aar'

implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

//exo player note : Don't upgrade of exoplayer vesion
implementation 'com.google.android.exoplayer:exoplayer:2.9.1'

implementation 'com.android.volley:volley:1.1.1'




}
   //apply plugin: 'com.google.gms.google-services' // Use for FCM Push
答案

在Android Studio终端中使用./gradlew build --warning-mode all来获取更多信息。

首先要做的是Invalidate caches + restart。

另一答案

请将build script {更改为buildscript {,不得有空格。它会工作。还尝试在“gradle-wrapper.properties”中使用distributionUrl=https://services.gradle.org/distributions/gradle-4.10.1-all.zip并再次同步

以上是关于Android Studio 报出此错AAPT: error: unexpected element <intent-filter> found in <manifest><application>.的主要内容,如果未能解决你的问题,请参考以下文章

生成签名时出现错误 AAPT Android Studio

Android Studio Android 资源链接失败错误.. AAPT:错误:找不到资源 android:attr/lStar。在 values.xml 105

在android studio中构建apk时找不到Aapt_rules.txt

更新后Android Studio 3.3到3.4 AAPT2生成错误

Android Studio升级到3.0,抛出Aapt2Exception异常

Android Studio3.3打包报错AAPT2 process unexpectedly exit. Error output: