Reputation: 1444
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
Upvotes: 1
Views: 944
Reputation: 1444
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.
Upvotes: 0
Reputation: 11
You have to add dependency of support library in your gradle
compile 'com.android.support:multidex:1.0.1'
If you already have a custom application you have to change that instead of extending Application
you have to extends that class with MultiDexApplication
like this
MyApplication extends MultiDexApplication {
}
If you don't have any custom application class only need to add this in manifest inside application tag
<application
android:name="android.support.multidex.MultiDexApplication">
</application>
If you don't need the whole play service
you can remove the dependency and add only those dependencies you needed like this
compile 'com.google.android.gms:play-services-gcm:8.1.0'
compile 'com.google.android.gms:play-services-maps:8.1.0'
compile 'com.google.android.gms:play-services-location:8.1.0'
then no need to make your application MultiDex
For ndk you can see this SO Thread
Upvotes: 1
Reputation: 6938
You may give it a try!
sourceSets { main { jni.srcDirs = [] assets.srcDirs = [] //disable automatic ndk-build call } }
Upvotes: 0