Android Studio CMake Error: Build Command failed

前端 未结 9 1414
孤独总比滥情好
孤独总比滥情好 2020-12-15 20:21

I\'m running into an Error when I open a new project in Android Studio from the Code Samples (Hello JIN). When the Project is opened the following:

Build com         


        
9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-15 20:38

    @rpurohit was nearly right, Clang isn't working properly. But to change the Compiler you need to change build.gradle, in my build.gradle it was Line 12:

    apply plugin: 'com.android.application'
    
    1 android {
    2    compileSdkVersion 25
    3    buildToolsVersion '25.0.2'
    4    defaultConfig {
    5       applicationId 'com.example.hellojni'
    6       minSdkVersion 23
    7       targetSdkVersion 25
    8       versionCode 1
    9       versionName "1.0"
    10      externalNativeBuild {
    11          cmake {
    12              arguments '-DANDROID_TOOLCHAIN=clang' --> gcc
                }
            }
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        externalNativeBuild {
            cmake {
                path "src/main/cpp/CMakeLists.txt"
            }
        }
        productFlavors {
            arm7 {
                // in the future, ndk.abiFilter might also work
                ndk {
                    abiFilter 'armeabi-v7a'
                }
            }
            arm8 {
                ndk {
                    abiFilters 'arm64-v8a'
                }
            }
            arm {
                ndk {
                    abiFilter 'armeabi'
                }
            }
            x86 {
                ndk {
                    abiFilter 'x86'
                }
            }
            x86_64 {
                ndk {
                    abiFilter 'x86_64'
                }
            }
            mips {
                ndk {
                    abiFilters 'mips', 'mips64'
                }
            }
            universal {
                ndk {
                    abiFilters 'mips', 'mips64', 'x86', 'x86_64'
                }
            }
        }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:25.2.0'
        compile 'com.android.support.constraint:constraint-layout:1.0.1'
    }
    

提交回复
热议问题