12

I am using Dji-SDK. Recently i migrated the SDK from version 4.2 to 4.3.2. After changing the dji-sdk.aar in the libs folder i am not able to build because of the merge issues in the manifest. The merged manifest in build is getting created as follows.

...
<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"
...

I know that the receiver tag should come under application tag. But in the merged manifest the tag is under the uses-permission tag and showing an error. Is it an Sdk error or is it wrong on my side ? Error is

Error:(71) unknown element <receiver> found

Here is the 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;
    }
}

I am using

  • Android Studio 3.0 Beta 4
  • Dji-sdk 4.3.2
jknair0
  • 1,194
  • 13
  • 24

1 Answers1

29

Try disabling the AAPT2 by adding android.enableAapt2=false to your gradle.properties file.

Builds may fail while AAPT2 is enabled. Additionally, AAPT2 is currently not compatible with Robelectric. If your build fails due to an AAPT2 resource processing issue or you want to use Roboelectric, you can disable AAPT2 by setting android.enableAapt2=false in your gradle.properties file and restarting the Gradle daemon by running ./gradlew --stop from the command line.

Reference : here

I was using Android studio 3.0 beta 5 In which I disabled the AAPT2 and it resolved my error.

UPDATE :

As Jay has mentioned another solution could be update Android Studio to 3.1.1. Since updating has solved issue for him. I haven't cross checked though.

UPDATE : 01 March 2020 As Tarit has mentioned, android.enableAapt2=false is deprecated and shouldn't be used.

Nilesh Deokar
  • 2,975
  • 30
  • 53
  • 2
    adding `android.enableAapt2=false` to `gradle.properties` file worked. – jknair0 Oct 04 '17 at 14:31
  • Confirmed fix on Android Studio 3.0 – Pztar Oct 26 '17 at 16:26
  • I am not sure about fix since my project is still not working without adding `android.enableAapt2=false` in `Studio 3.0` – Nilesh Deokar Oct 27 '17 at 07:09
  • I can confirm it also works for me now with DJI SDK 4.4.1 and Android Studio 3.1... – user754730 Mar 29 '18 at 06:36
  • If it was corrected in a previous version then there is a regression. I get the problem on Android Studio 3.1.2 – rsan May 27 '18 at 05:46
  • Sadly this is not really a solution. In my case using android.enableAapt2=false makes me hit a different bug in AaPt that don't allow running the aplication...https://stackoverflow.com/questions/49513051/failed-to-execute-aapt-nosuchelementexception-at-abstractindexedlistiterator-ne – rsan May 27 '18 at 06:48
  • Well, sorry this solution couldn't help you. – Nilesh Deokar May 27 '18 at 13:32
  • @rsan try deleting the .gradle in root folder and try to rebuild after removing the android.enableAapt option. – jknair0 May 28 '18 at 06:45
  • WARNING: The option 'android.enableAapt2' is deprecated and should not be used anymore. – Tarit Ray Dec 17 '18 at 06:31