【问题标题】:Change cmake directory in Android studio在 Android Studio 中更改 cmake 目录
【发布时间】:2018-04-02 10:26:54
【问题描述】:

我从某人那里复制了一个 Android Studio 项目,但我无法清理和重建该项目。这是弹出以下错误。

错误:任务 ':app:externalNativeBuildCleanDebug' 执行失败。

启动进程'command'C:\Users\Lenovo\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe''时出现问题

假设 Users\Lenovo 是以前的程序员用户名,而不是我的电脑用户名。

这是我的 build.gradle 应用程序

应用插件:'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')
}

有没有办法解决这个问题?

【问题讨论】:

  • 能否把build.gradle文件的内容贴出来
  • 哪个 build.gradle 文件?项目,应用程序,opencv,库。这个android studio文件是用来生成aar文件的。
  • 要更改构建目录(最近命名为.cxx),在another thread 中找到正确的解决方案,例如!请参阅CMake docs 和详细信息。

标签: android cmake


【解决方案1】:

只需在 build.gradle 中的 ndk 下注释 abiFilters 行,然后同步、清理和重建,现在路径将更改,您现在可以重新引入 abiFilters 并再次构建。这解决了我的问题。

【讨论】:

  • 嗨!感谢回复。抱歉没有更新。我删除 externalNativeBuild { cmake { path 'CMakeLists.txt' } } 后我的代码仍然有效,感谢您提供信息!
【解决方案2】:

我知道现在回答这个问题为时已晚,但它会帮助其他人。 您确实删除了 externalNativeBuild { cmake { path 'CMakeLists.txt' } } - 但因此您将无法使用 c++ 文件... 要更改路径,请这样做:

删除:

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

..来自应用程序构建 gradle

  • 右键单击应用模块,从菜单中选择“Link C++ Project with Gradle”
  • 您将看到一个对话框
  • 在此处输入您的 cmakelist 的路径,然后单击确定
  • 重建项目
  • 如果还是不行,那就让缓存失效,重启android studio

【讨论】:

    猜你喜欢
    • 2019-03-09
    • 2014-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-18
    • 2015-10-27
    相关资源
    最近更新 更多