错误:(72)找到未知元素<receiver>

时间:2017-10-04 08:35:53

标签: android android-manifest android-studio-3.0 dji-sdk

我正在使用Dji-SDK。最近我将SDK从4.2版迁移到4.3.2版。更改libs文件夹中的dji-sdk.aar后,由于清单中的合并问题,我无法构建。构建中的合并清单将按如下方式创建。

...
<uses-permission android:name="android.permission.USE_CREDENTIALS" />

    <receiver
        android:name="dji.logic.receiver.DJIPilotStartupReceiver"
        android:exported="true"
        android:permission="dji.permission.sdk.wifi" >
        <intent-filter>
            <action android:name="dji.pilot.STARTUP" />
            <action android:name="dji.go3.STARTUP" />
            <action android:name="dji.go4.STARTUP" />
        </intent-filter>
    </receiver>

    <application
        android:name="com.sample.app.LinkApplication"
...

我知道receiver标记应位于application标记下。但是在合并清单中,标记位于uses-permission标记下并显示错误。这是一个Sdk错误还是我的错? 错误是

Error:(71) unknown element <receiver> found

这是build.gradle。

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

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'me.tatarka.retrolambda'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.sample.app"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 7
        versionName "4.0.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11"
            }
        }
        vectorDrawables {
            useSupportLibrary = true
        }
        packagingOptions {
            exclude 'META-INF/rxjava.properties'
        }
        multiDexEnabled true
        retrolambda {
            javaVersion JavaVersion.VERSION_1_6
            incremental true
        }
        buildConfigField "boolean", "DRONE_DEBUG", property('DRONE_DEBUG')
        buildConfigField "String", "BASE_URL", property('BASE_URL')
        buildConfigField "String", "LINK_DRONE_URL", property('LINK_DRONE_URL')
        buildConfigField "String", "LINK_SENSOR_URL", property('LINK_SENSOR_URL')
        resValue "string", "api_key_dji_sdk", "################"
        resValue "string", "app_name", "Link"
        dimension "default"
        applicationId = "com.sample.app"
    }
    buildTypes {
        debug {

        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    flavorDimensions "default"
    lintOptions {
        checkReleaseBuilds false
    }
    dataBinding {
        enabled = true
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}

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

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testImplementation 'junit:junit:4.12'
    testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
    implementation 'com.android.support:appcompat-v7:25.4.0'
    implementation 'com.android.support:design:25.4.0'
    implementation 'com.android.support:cardview-v7:25.4.0'
    implementation 'com.android.support:multidex:1.0.2'
    implementation 'com.google.android.gms:play-services-location:11.0.2'
    implementation 'com.google.android.gms:play-services-maps:11.0.2'
    implementation 'com.google.dagger:dagger:2.10'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.10'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.1'
    implementation('com.squareup.retrofit2:retrofit:2.3.0')
    implementation('com.squareup.retrofit2:converter-gson:2.3.0') {
        exclude group: 'com.google.code.gson', module: 'gson'
    }
    implementation 'com.squareup.retrofit2:converter-scalars:2.1.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'
    implementation 'com.jakewharton.timber:timber:4.5.1'
    implementation 'me.grantland:autofittextview:0.2.1'
    implementation 'com.squareup:otto:1.3.8'
    implementation('org.jscience:jscience:4.3.1', {
        exclude group: 'org.javolution', module: 'javolution'
    })
    //implementation 'com.dji:dji-sdk:4.3.2' (i have tried this too after removeing the dji-sdk.aar)
    implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true;
    }
}

我正在使用

  • Android Studio 3.0 Beta 4
  • Dji-sdk 4.3.2

1 个答案:

答案 0 :(得分:28)

尝试通过将AAPT2添加到android.enableAapt2=false文件来停用gradle.properties

  

启用AAPT2时,构建可能会失败。另外,AAPT2是   目前与Robelectric不兼容。如果你的构建失败了   AAPT2资源处理问题或您想使用Roboelectric,   你可以通过设置android.enableAapt2=false来禁用AAPT2   gradle.properties文件并通过运行重新启动Gradle守护程序   来自命令行的./gradlew --stop

参考:here

我使用的是Android Studio 3.0 beta 5,我在其中禁用了AAPT2并解决了我的错误。

更新:

正如Jay提到的另一种解决方案可能是将Android Studio更新为3.1.1。由于更新已经解决了他的问题。我没有交叉检查。