iradarask
iradarask

Reputation: 21

Change cmake directory in Android studio

I had copy an Android studio project from someone and i am unable to clean and rebuild the project. This is the following error pop out.

Error:Execution failed for task ':app:externalNativeBuildCleanDebug'.

A problem occurred starting process 'command 'C:\Users\Lenovo\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe''

Suppose the Users\Lenovo is the previous programmer user name where it is not my pc user name.

This is my build.gradle for app

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
    applicationId "linkdood.isenseocr_android"
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    externalNativeBuild {
        cmake {
            cppFlags ""
        }
    }
    ndk {
        abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
    }
}

buildTypes {
    release {
        useProguard true
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
externalNativeBuild {
cmake {
    path 'CMakeLists.txt'
}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
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'
compile 'com.rmtheis:tess-two:8.0.0'
implementation project(':openCVLibrary331')
implementation project(':isenselib')
}

Is there anyway to solve this problem?

Upvotes: 2

Views: 4869

Answers (2)

Phadu
Phadu

Reputation: 1

I know it's too late to answer this question but it will help others. You did remove externalNativeBuild { cmake { path 'CMakeLists.txt' } } - but because of this you wont be able to use c++ file then... for changing path do it like this:

Remove:

 externalNativeBuild {
    cmake {
        path "CMakeLists.txt"
    }
}

..from app build gradle

  • Right-click on the app module, select "Link C++ Project with Gradle" from the menu
  • You will see a dialog
  • Enter path of your cmakelist there and click ok
  • Rebuild the project
  • If it still doesn't work then invalidate the cache and restart android studio

Upvotes: 0

Vaishakh
Vaishakh

Reputation: 1206

Just comment abiFilters line under ndk in build.gradle and now sync,clean and rebuild,now the path will be changed, you can now reintroduce abiFilters and build again. This solved my problem.

Upvotes: 1

Related Questions