APK与本机代码崩溃

时间:2016-05-16 13:33:58

标签: android-studio android-ndk android-gradle apk build.gradle

我有一个本机代码,我使用ndk-build编译为exe,它在设备上运行完美。

然后我创建了一个简单的apk,将c源添加到jni文件夹,配置了gradle.build,当我启动apk时,它调用本机函数,但在某些时候应用程序崩溃。 我想我错误配置了gradle.build脚本。

有人可以查看吗?

Android.mk

    LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_ARM_MODE := arm
LOCAL_CFLAGS := -O3 -DNDEBUG --all-warnings --extra-warnings
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/

LOCAL_MODULE    := iovyroot
LOCAL_SRC_FILES := main.c getroot.c flex_array.c sid.c offsets.c

include $(BUILD_EXECUTABLE)

Application.mk

APP_PLATFORM := android-21
APP_ABI := arm64-v8a armeabi-v7a

的build.gradle(项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle-experimental:0.7.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

的build.gradle(APP)

apply plugin: 'com.android.model.application'

model {
    android {
        compileSdkVersion = 23
        buildToolsVersion = "23.0.3"

        defaultConfig {
            applicationId = "com.mymodule"
            minSdkVersion.apiLevel = 15
            targetSdkVersion.apiLevel = 23
            versionCode = 1
            versionName = "1.0"
        }
        buildTypes {
            release {
                minifyEnabled = false
                proguardFiles.add(file('proguard-android.txt'))
            }
        }
        ndk {
            moduleName = "mymodule"
            CFlags.add("-I" + file("src/main/jni/include").absolutePath)
            CFlags.add("-O3")
            CFlags.add("-DNDEBUG")
            CFlags.add("--all-warnings")
            CFlags.add("--extra-warnings")
            abiFilters.add("armeabi-v7a")
            stl = "stlport_shared"
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
}

修改 kmsg转储。 last kmsg dump

0 个答案:

没有答案