qq_45125262
BrainPain
采纳率0%
2019-09-29 17:34 阅读 1.9k

Android Studio的项目运行时报错:Error configuring CMake server

70

问题背景

我在跟着csdn上的一个教程尝试用Android Studio(3.4.1)
做一个变声器的app项目,fmod的so库都导入进项目的libs了
,build.gradle和cmakelist.txt也都按照那个教程配置了。

AS制作变声器

后来报错说不支持armeabi,网上查了下发现NDK17以上都不
支持了,遂下载了ndk16b替换之前的ndk17,ndk的location
也都改过了,然后终于build成功,开心。

但是插上usb准备在手机上运行测试下的时候,出现这个报错
,Google了也没解决掉。报错:Error configuring CMake
server (E:\Android\Sdk\cmake\3.10.2.4988404\bin).

图片说明

** 有大佬知道怎么回事儿吗?**

###代码(build.gradle)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.qq_voicechanger01"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags ""
                abiFilters 'armeabi','x86'
            }
        }
        //编译平台
        ndk{
            abiFilters "armeabi","x86"
        }

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version "3.10.2"
        }
    }
    //目录
    sourceSets.main{
        jniLibs.srcDirs = ['libs']
        jni.srcDirs = []
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

###代码(cmakelist.txt)

cmake_minimum_required(VERSION 3.4.1)

find_library(log-lib
        log )

set(my_lib_path ${CMAKE_SOURECE_DIR}/libs)

#添加第三方的so库
add_library( 
        libfomd
        SHARED
        IMPORTED)

#指明第三方so库的绝对路径
set_target_properties(  libfmod
                        PROPERTIES IMPORTED_LOCATION
                        ${my_lib_path}/${ANDROID_ABI}/libfmod.so
)

add_library(
        libfmodL
        SHARED
        IMPORTED
)

set_target_properties(
        libfmodL
        PROPERTIES IMPORTED_LOCATION
        ${my_lib_path}/${ANDROID_ABI}/libfmodL.so
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")

#添加我们需要编译的cpp绝对路径
add_library(
        changeVoice
        SHARED
        src/main/cpp/play_sound.cpp src/main/cpp/common.cpp src/main/cpp/common_platform.cpp
)

#导入路径,使编译时能找到这个文件夹
include_directories(src/main/cpp/inc)

#连接好三个路径
target_link_libraries(
        changeVoice
        libfmod
        libfmodL

        ${log-lib}
)
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

相关推荐