Search code examples
androidandroid-multidex

Android studio multidex And Ndk issue


I am using android studio for developing android app. I have one project which is having two modules as library and both the modules having few libraries common(.so file) due to this I am getting multi-dex issue. Below is the gradle message

> Error:Execution failed for task ':ftrScanApiAndroidHelperUsbHost:compileReleaseNdk'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/intel/BackUp/Ndk/ndk-build'' finished with non-zero exit value 2

I tried below solution for this issue but this didn't work for me

defaultConfig{
       multiDexEnabled true
    } 

build.gradle file:

> apply plugin: 'com.android.application' // apply plugin: 'android'
> 
> android {
> 
>     signingConfigs {
>         config {
>             keyAlias 'xxx'
>             keyPassword 'xxx'
>             storeFile file('/home/intel/Downloads/xxx.jks')
>             storePassword 'xxx'
>         }
>     }
>     compileSdkVersion 21
>     buildToolsVersion '21.1.2'
>     defaultConfig {
>         applicationId 'com.xxxx.xxx.xxx'
>         minSdkVersion 14
>         targetSdkVersion 14
>         versionCode 3
>         versionName "1.2"
>         signingConfig signingConfigs.config
>         multiDexEnabled true
>     }
>     buildTypes {
>         release {
>             minifyEnabled false
>             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
>             signingConfig signingConfigs.config
>         }
>         debug {
>             signingConfig signingConfigs.config
>         }
>     }
>     productFlavors {
>     }
>     sourceSets {
>         main {
>             jni.srcDirs = []
>             assets.srcDirs = ['src/main/assets', 'src/main/assets/']
>         }
>     }
> 
> }
> 
> dependencies {
>     compile 'com.android.support:appcompat-v7:21.0.3'
>     compile 'com.google.android.gms:play-services:+'
>     compile project(':pulltorefresh')
>     compile 'com.google.code.gson:gson:2.3.1'
>     compile files('libs/ksoap2-android-assembly-3.4.0-jar-with-dependencies.jar')
>     compile files('libs/possdk.jar')
>     compile project(':ftrScanApiAndroidHelperUsbHost')
>     compile project(':ftrWsqAndroidHelper') }

local.properties below:

sdk.dir=/home/intel/Takencode/Android/Sdk

ndk.dir=/home/intel/Takencode/Android/Ndk

Is there any other solution for the above error? Any suggestion


Solution

  • Finally after googling a lot I rectify the issues.Things that goes wrong for above issue.

    Case 1:In modules I'm having jni and jnilibs few files common(.so files) ...so I deleted the jni folder because it containing the same .so file...removing redundancy and conflict from the project.

    Case 2:There may be the case where modules(Library) and main project's theme,icons are different(defined in AndroidManifest.xml file). In order to correct that look for manifest file...make the module and main project theme same..

    In my case module having below Theme

    android:theme="@style/AppTheme" 
    

    and main project having

     android:theme="@android:style/Theme.Holo.Light.NoActionBar"
    

    so I change module theme same as project theme.

    Also add below line to manifest tag

    xmlns:tools="http://schemas.android.com/tools"  
    

    Once added above line add below line to application tag

    tools:replace="android:icon,android:theme"
    

    Now it working flawless.