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
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
}
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.
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'
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
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
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
}
}
Related
After upgrading to Android Studio 3.1, I started to get following error during build. Project uses multidex and DX is enabled by default as you would notice in the error. I tried to check dependency graph to understand what is going on but so far have no clue. Interestingly this only fails on my machine. I cleaned up everything, including reinstall etc but nothing worked.
Anyone had the same issue and how did you solve it? Or any direction that I can take a look?
AGPBI: {
"kind":"error",
"text":"Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat",
"sources":[{}],
"tool":"D8"
}
This is the task that fails:
transformDexArchiveWithExternalLibsDexMergerForDebug
I checked similar issues and it seems random things fixes their problem, I'm not sure what is the real cause.
For my solution (I do not know it will work for you):
Firstly I followed #Orhan Obut's solution:
Search for duplicate classes in your project
I found that there are more than one class files in different libraries.
Then I put the ignore annotation above my support dependency in my project module's build.gradle (app folder):
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
I realized that ignorance is no solution, because the error did not go away, even after clean-rebuilding and clearing/invalidating cache for the project.
See: Infographic: 11 Most Common Android Errors and How to Fix Them
So I explored more, and found out this link:
Android - Understanding and dominating gradle dependencies
It suggests ways to resolve conflicts. Hence I put this on my gradle just above the declarations of dependencies:
configurations.all {exclude group: 'com.android.support', module: 'support-v4'}
Since then when I search for duplicate classes for this one using #Orhan Obut's solution above, I find only single entry in the result. That meant that there were no duplicates.
Also, it will be better if you migrate to AndroidX with latest SDK and build tools. Make sure you don't have older support dependencies anywhere.
Happy Coding :-)
I have my solution by change this:
implementation 'com.android.support:appcompat-v7:27.0.0'
to
implementation 'com.android.support:appcompat-v7:26.0.0'
it works for me.
I managed to determine the root cause by using the following steps. It may be different use case for each issue, therefore this is the way to determine the root cause.
Go to android studio
Navigate -> Class
Check include non-project classes
Copy paste full class path with package name. android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat
You should be able to see where it is used. Most probably you may need to remove it from one of them.
In my case the issue was ViewPagerIndicator library was downloading support library as jar. Removing it solved the issue.
For the easy option just add
configurations.all {exclude group: 'com.android.support', module: 'support-v4'}
before dependencies in build.gradle app module, it should ignore v4 support libraries, and the duplicate error will go away.
Adding the below line in the build.gradle of the app level worked for me
implementation 'com.android.support:support-v4:28.0.0'
As for me this helps to resolve such issues
all support libraries (also included thirdy-part) reduces to specified version
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '28.0.0-beta01'
}
}
}
}
I also faced the same problem just a while ago. In my case the third party library used the older AccessibilityServiceInfoCompat version v4 22 and i already updated to newer one v4 28 so both support library classes clashed
In y case I've resolved issue by
implementation 'com.android.support:appcompat-v7:26.0.0'
to
implementation 'com.android.support:appcompat-v7:27.1.1'
some third-party library may be use different version of support library. you can use ./gradlew :app:dependencies find out it, and then import the current version of the support library.
I have my solution by change this :
android / build.gradle
buildscript {
ext {
supportLibVersion = "27.0.3"
}
}
to
buildscript {
ext {
supportLibVersion = "26.0.0"
}
}
directory android / app / build.gradle
defaultConfig {
multiDexEnabled true
}
In recent days I'm getting failed to resolve github libraries for so many popular libraries. I know it generally happens when the library is suspended or not available. But i tried it for so many libraries. And getting same result. But doesn't mean every libraries don't work. Some works.
For example..
I tried it for PhotoView..
compile 'com.github.chrisbanes:PhotoView:2.0.0'
In the release page the latest version was 2.0.0
I get same thing for so many other libraries. I think last week I updated the gradle. So is that why I'm getting this problem for some libraries..
Or what can be the problem..
I'm also using all maven urls for all libraries as mentioned in the docs file..
Make sure you added this root build.gradle file (Not your module build.gradle file):
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
FYI
New version has been released, You can try with
compile 'com.github.chrisbanes:PhotoView:2.1.3'
After that, Clean-Rebuild-Run.
I'm getting this error in my Kotlin project:
Here is my app's Gradle files:
I haven't really done anything to the project yet except add Kotlin and Anko dependencies. Not sure what's happening...
This is a well known issue with Anko. It is mentioned here.
You can try to exclude implicit com.google.android:android dependency from Anko's dependencies:
compile("org.jetbrains.anko:anko-appcompat-v7:$anko_version") {
exclude group: 'com.google.android', module: 'android'
}
(Keep in mind as you are using separate Anko libraries - you may need to use exclusion in multiple pleces).
You can also try to update Gradle plugin:
classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
Add the dependency inside you app-level app module :
// Anko
compile 'org.jetbrains.anko:anko-sdk15:0.8.2' // sdk19, sdk21, sdk23 are also available
compile 'org.jetbrains.anko:anko-support-v4:0.8.2' // In case you need support-v4 bindings
compile 'org.jetbrains.anko:anko-appcompat-v7:0.8.2' // For appcompat-v7 bindings
As In your screenshot I can see that while adding Anko dependencies you didn't mention the Anko version , kindly mention that it should work fine post that.
Add like this too.
flavorDimensions "default"
productFlavors {
debug {
dimension "default"
...
}
release {
dimension "default"
...
}
foss {
dimension "default"
...
}
}
AFAIK, its Google Repository which is missing. As you can see the ide itself is informing you about it.
Failed to resolve: com.google.android:android.2.3.1 which is Google Repository.
If you are connected to internet then simply click on Install Repository and Sync project in the Gradle Sync window. It will download the google repository and sync your project.
I have project with two modules.
I'm using SalesforceSDK which is included as separate module and inside SalesforceSDK I have Cordova which is using okhttp.
In second module I have retrofit library which is using okhttp too and when I try to build the project I get
duplicate dex files error
I tried to delete okhttp dependency from SalesforceSDK and include it from my second module but I'm getting
symbols not found error
Only thing left to do is to include okhttp as different module but before I do that I want to ask you if there is another way to fix this problem ?
EDIT:
I tried solution proposed by Aayushi but still I get errors :
Error:Execution failed for task
':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: com/squareup/okhttp/Address.class
if you are using android studio no need to delete you can use both library
just use
android {
defaultConfig {
...
multiDexEnabled = true
}
}
using this statement is also required
dependencies
{
compile 'com.android.support:multidex:1.0.0'
}
Take a look at jarjar, which can let you use one version of OkHttp in one place and another somewhere else.
There are other similar tools (shade), and most of ‘em will work for you.
I also have another solution for this issue.
Firstly, I run this command line:
and this is result:
I saw that Paypal also use okhttp library.So, I added this line to gradlew:
compile('com.paypal.sdk:paypal-android-sdk:2.13.3')
{
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
And It aslo works fine for me.
I was able to fix the issue by following this - https://developer.android.com/studio/build/dependencies#duplicate_classes
In my case, cordova-android-3.3.0.jar was a dependency in 2 different projects and one of those is a dependency of the other one.
I am trying to apply material theme. After changing com.android.support:appcompat-v7:19.1.0 in build.gradle file to v7:21.0.0.-rc1 or v7:21+, i am getting following error:
Module version com.loopj.android:android-async-http:1.4.3 depends on
libraries but is not a library itself
com.loopj.android:android-async-http:1.4.3 dependency is in another build.gradle which is like a project inside main project.
dependencies {
compile 'com.loopj.android:android-async-http:1.4.3'
}
Update: I changed it to 1.4.4 but now I am getting:
Error:Execution failed for task ':mergeDebugManifests'. Manifest
merging failed. See console for more info.
As per this link, I have 'android-L' everywhere, still no luck
By modifying the answer found here: Crouton depends on libraries but is not a library itself
I changed the dependency declaration in build.gradle as follows:
compile('com.strongloop:loopback-android:1.+#aar') {
exclude group: 'com.google.android', module: 'support-v4'
}
This seems to have solved it for me. If there is a better solution to this, I for one would like to hear what it is.