20

I'm trying to add mopub. But when I do, the build manifest adds a library tag and then says it doesn't know what it is. If I remove the link, all works fine.

compile('com.mopub:mopub-sdk:4.16.0@aar') {
    transitive = true
}

<library android:name="moat-mobile-app-kit" />

Error:(34) unknown element found

Error:E:\Web\Studio\Opus\app\build\intermediates\manifests\full\live\debug\AndroidManifest.xml:34 unknown element found

Error:java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.AaptException: AAPT2 link failed:

Error:com.android.builder.internal.aapt.AaptException: AAPT2 link failed: Error:Execution failed for task ':app:processLiveDebugResources'. Failed to execute aapt

natedogg265
  • 239
  • 2
  • 6

6 Answers6

7

I experience this issue, after several inspections i can only conclude that manifest merger, includes the line

<library android:name="moat-mobile-app-kit" />

from mopub avid and moat kit,as this is not supported in the new android gradle plugin, your best bet for now will be to disable viewability measurement by editing mopub dependency line as defined below

compile('com.mopub:mopub-sdk:4.17.0@aar') {
    transitive = true
    exclude module: 'libAvid-mopub' // To exclude AVID
    exclude module: 'moat-mobile-app-kit' // To exclude Moat
}
Distjoy
  • 431
  • 3
  • 7
  • It works clean your project and make a rebuild..... if your build log is as stated above...if it doesnt work then maybe you are not including mopub aar from jcenter....let me see your dependency line. – Distjoy Oct 27 '17 at 08:02
  • @casolorz check my answer well, you are only meant to include the compile statement in your build.gradle, rebuild and you will see that the library line is gone. Note: Do not add the line in your manifest.xml – Distjoy Oct 27 '17 at 08:14
  • I actually copy pasted what you have on your answer and it still didn't work. I never added the ` – casolorz Oct 27 '17 at 12:43
  • @casolorz yes you are right, disabling moat is just a temporary solution am sure as mopub update this will be resolve. If this does not work for you, its either moat is still in your dependencies internally (in that way a simple clean will do), or you included mopub in your build.gradle multiple times,or maybe another library is including it also...there are othe ways to disable moat ...check it here [Mopub Docs](https://github.com/mopub/mopub-android-sdk#strip-out-from-github-integration) – Distjoy Oct 27 '17 at 12:56
  • I wonder if it is because of `maven { url "https://s3.amazonaws.com/moat-sdk-builds" }`, but I don't really want to go through removing that if I'm going to need it later. I'll just use 4.15 for now since moat would have to be disabled anyways on 4.17. – casolorz Oct 27 '17 at 13:45
  • Also note that version 4.15 is probably using support library lower than version 26, which will conflict the one included in studio 3.0 – Distjoy Oct 27 '17 at 14:46
7

The only solution I have found so far is to use MoPub 4.15.

Edit: MoPub has confirmed the issue and they wouldn't give me an ETA on a fix.

Edit: 4.18 still broken.

Edit: I should mention I am using 4.19 now with Moat still disabled and using the code to remove Moat, but I also have to do that on other ad networks that include Moat as well. So if you are having this issue you might want to look at all your ad network compile lines.

Edit: According to MoPub, this is fixed on 4.20.0 and it seems to work for me.

casolorz
  • 8,486
  • 19
  • 93
  • 200
5

There is a moat update that seemingly solves the problem. For me this compiles properly:

implementation 'com.mopub:mopub-sdk:4.19.0@aar'
implementation 'com.moat.analytics.mobile.mpub:moat-mobile-app-kit:2.4.1'
Mate Herber
  • 101
  • 1
  • 3
0

I got a response from Mopub.

Android Studio 3 uses Gradle 4, and Gradle 4 deprecates the use of the "compile" statement. Therefore you will need to use keywords such as "api" or "implementation" in place of "compile". Please also reference this StackFlow link for additional information.

link here

natedogg265
  • 239
  • 2
  • 6
  • converting from 'compile' to 'implimentation' didn't work. Nor does 'api'. Has the MoPub team given any more information? It seems that their documentation still uses the old style dependency keywords: https://github.com/mopub/mopub-android-sdk/wiki/Getting-Started – AdamWardVGP Oct 26 '17 at 21:43
  • @AdamWardVGP check my answer and try it...i just resolve the same issue in my project – Distjoy Oct 27 '17 at 08:03
0

Add this to your gradle dependencies.

exclude module: 'moat-mobile-app-kit' if you are using Mopub SDK <= 4.18.0.

It worked for me.

If you are using 4.20.0, they fixed this issue. https://developers.mopub.com/docs/android/changelog/#version-4200-february-20-2018

Ravi
  • 631
  • 5
  • 15
0

keep repositories and dependencies at a file(build.gradle) ,not two file, like repositories at root build file ,dependencies at module build file

 repositories {
   // ... other project repositories
    jcenter() // includes the MoPub SDK and AVID library
    maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
 }

 // ...

dependencies {
 // ... other project dependencies
 compile('com.mopub:mopub-sdk:4.16.0@aar') {
     transitive = true
  }
}
chen
  • 172
  • 1
  • 7