Unable to merge dex Android Studio 3.0.1 - java

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Just after updating Android studio 3.0.1 recently from 2.3.3 version, I am facing issue related to DexMergerException.
Someone else also posted question-related to this. But in this question, I want to analyze the stack trace to find the related solution(since I am a newbie here..).
I am unable to resolve it.
This is my build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.aimnatvtz.aimatv"
manifestPlaceholders = [onesignal_app_id: "MY_ONESIGNAL_APP_ID",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "226589149887"]
minSdkVersion 16
targetSdkVersion 27
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
google()
}
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'
})
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}
}
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:design:27.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'it.sephiroth.android.library.easing:android-easing:+'
implementation 'com.facebook.android:facebook-login:4.27.0'
implementation 'com.android.support:recyclerview-v7:27.0.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.github.bumptech.glide:glide:4.0.0'
implementation 'com.google.android.gms:play-services-auth:11.6.2'
implementation 'com.afollestad:sectioned-recyclerview:0.5.0'
implementation 'com.onesignal:OneSignal:[3.6.2, 3.99.99]'
implementation 'com.paypal.sdk:paypal-android-sdk:2.15.3'
testImplementation 'junit:junit:4.12'
}

Tried to enable multidex
modify your build.gradle
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
defaultConfig {
multiDexEnabled true
}
in your manifiest file define your apllication name properrty like this
android:name="com.pkg.YouApplication"
Include this in your Application class
public class YouApplication extends Application {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}

I had the same problem, it is associated with the update
compile 'com.google.android.gms: play-services: 11.4.2 to compile' com.google.android.gms: play-services: 11.6.0
Return back to the old version of the play-services

Related

How do I fix this error that I get when I open my application made in android studio?

I made an app in android studio and it worked for me. I tried exporting the apk to test it and it worked. So far so good.
Then when I upload it to PlayStore, I install it and when I try to open it I can not and I miss an error that I enclose in a capture.
The part of the application code that I think gives an error is this:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.facebook.fresco:fresco:1.11.0'
implementation 'com.facebook.fresco:webpsupport:1.11.0'
implementation 'com.facebook.fresco:animated-webp:1.11.0'
implementation 'com.google.android.gms:play-services-ads:17.1.2'
}
This is the build.gradle code:
apply plugin: 'com.android.application'
android {
//the compression of webp file during build causes problem with FileDescriptor in ContentProvider.
aaptOptions {
noCompress "webp"
}
compileSdkVersion 28
defaultConfig {
applicationId "com.shstickers.shstickers"
minSdkVersion 16
targetSdkVersion 28
versionCode 17
versionName "1.27"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
def contentProviderAuthority = applicationId + ".stickercontentprovider"
// Creates a placeholder property to use in the manifest.
manifestPlaceholders =
[contentProviderAuthority: contentProviderAuthority]
// Adds a new field for the authority to the BuildConfig class.
buildConfigField("String",
"CONTENT_PROVIDER_AUTHORITY",
"\"${contentProviderAuthority}\"")
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
task checkDebug {
doLast {
println("checkDebug")
if (android.defaultConfig.applicationId.startsWith("com.whatsapp")) {
throw new GradleException("applicationId in defaultConfig cannot start with com.whatsapp, please change your applicationId in app/build.gradle");
}
checkApplicationIdInDebug()
}
}
private void checkApplicationIdInDebug() {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ignoreApplicationIdCheck = properties.getProperty('ignoreApplicationIdCheck')
if (ignoreApplicationIdCheck == null) {
if (android.defaultConfig.applicationId.equals("com.example.samplestickerapp")) {
throw new GradleException("Your applicationId is currently com.example.samplestickerapp, please change your applicationId to a different string in app/build.gradle in line 16");
}
} else {
println("application id check ignored")
}
}
task checkRelease {
doLast {
println("checkRelease")
if (android.defaultConfig.applicationId.startsWith("com.example")) {
throw new GradleException("applicationId in defaultConfig cannot start with com.example, please change your applicationId in app/build.gradle");
}
}
}
tasks.whenTaskAdded { task ->
println(task.name)
if (task.name.contains("assembleDebug")) {
task.dependsOn checkDebug
}
if (task.name.contains("assembleRelease")) {
task.dependsOn checkRelease
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.facebook.fresco:fresco:1.11.0'
implementation 'com.facebook.fresco:webpsupport:1.11.0'
implementation 'com.facebook.fresco:animated-webp:1.11.0'
implementation 'com.google.android.gms:play-services-ads:17.1.2'
}
Any idea how to fix it? The error that appears when you open the app on your mobile device after installing it is attached as a capture.

Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. " i tried my best but i could not resolve it.."

I'm getting this error after I update my android studio...
More than one file was found with OS independent path
'org/jsoup/nodes/entities-full.properties'
My "app Build.gradle"
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "info.androidhive.newsaggregator"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
//implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.facebook.android:facebook-android-sdk:4.11.0'
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.mcxiaoke.volley:library-aar:1.0.0'
implementation 'org.jsoup:jsoup:1.8.3'
implementation 'com.github.siyamed:android-shape-imageview:0.9.3#aar'
implementation files('libs/gson-2.2.2.jar')
implementation files('libs/android-async-http-1.4.4.jar')
implementation('com.github.florent37:materialviewpager:1.1.3#aar') {
transitive = true
}
implementation 'com.github.clans:fab:1.6.3'
repositories {
mavenCentral()
}
implementation 'com.makeramen:roundedimageview:2.2.1'
implementation project(':library')
}
My "project build.gradle"
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
My "library Build.Gradle"
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.nineoldandroids:library:2.4.0'
}
Can anyone help me figuring out what's causing this error?
Any ideas on how to get this working? if you need more information please let me know. I am very new to this. Thank you so much in advance.

'provided' is obsolete but where is the provided

apply plugin: 'com.android.application'
apply plugin: 'net.saliman.cobertura'
android {
compileSdkVersion 26
buildToolsVersion '28.0.2'
defaultConfig {
applicationId "ch.zhaw.facerecognition"
minSdkVersion 21
targetSdkVersion 26
versionCode 28
versionName "1.5.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
cobertura {
coverageFormats = [ 'html', 'xml' ]
}
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
dependencies {
classpath 'net.saliman:gradle-cobertura-plugin:2.4.0'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
api 'com.android.support:appcompat-v7:26.0.0'
api 'com.android.support:support-v4:26.0.0'
api 'ch.zhaw:facerecognitionlibrary:1.5.3'
}
The compiler is android studio.
Above is my build file after I build it the compiler told me that Configuration 'provided' is obsolete and has been replaced with 'compileOnly'.
But where is the provided?
Replace "api" with "implementation" and your issue will be solved, like this:
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support:support-v4:26.0.0'
implementation 'ch.zhaw:facerecognitionlibrary:1.5.3'

How to use .so files in Android

I am tring to add a C++ library into my Android project, but I keep getting the error:
Could not get unknown property 'jniLibs' for source set 'main' of type org.gradle.api.internal.tasks.DefaultSourceSet.
The project attempts to use a .so library of SQLite ( amalgamation).
How can I include the .so lib in my project and link it successfully to be able to call its functions?
Thank you all in advance.
My build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
buildToolsVersion '27.0.3'
externalNativeBuild {
cmake {
path 'CMakeLists.txt'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:26.+'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
remove config in build.gradle. This path is the default value of jniLibs, no customer config is needed.
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
or try with this config
sourceSets {
main {
jniLibs.srcDir(['src/main/jniLibs'])
}
}
copy the so file into app/src/main/jniLibs.
add the JNI java interface jar into your dependency.
System.LoadLibrary(libName) // for example you put xxx.so into jniLibs folder. here would be System.LoadLibrary("xxx")
Use the native method in JNI java class to call so method.

Java\jdk1.7.0_06\bin\java.exe'' finished with non-zero exit value 1 android studio

I am getting this error while i run program in the Android studio.. There is no anyother is here i guess.
Error:Execution failed for task ':app:createDebugMainDexClassList'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.7.0_06\bin\java.exe'' finished with non-zero exit value 1
Here it is my gradle file copy..
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "app.example.com"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions { abortOnError false }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/socialauth-4.9.jar')
compile 'com.android.support:recyclerview-v7:+'
compile project(':linkedin-sdk')
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'org.lucasr.twowayview:twowayview:0.1.4'
compile 'de.hdodenhof:circleimageview:1.2.1'
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:design:+'
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile ('org.apache.httpcomponents:httpmime:4.3.5')
{
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
}
what's the issue ?
its seems to be multidex issue. just add maximum heap size and multidex library dependency.
android {
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g"
}
}
defaultConfig {
multiDexEnabled true
}
also put Dependency
compile 'com.android.support:multidex:1.0.0'
you will also need to extend your application class to MultiDexApplication
public class App extends MultiDexApplication {
#Override
public void onCreate()
{
super.onCreate();
// Initialize
}
#Override
protected void attachBaseContext(Context base)
{
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Don't forgot to make an entry of app class in manifest.
Use this in app build.gradle worked for me
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}

Categories

Resources