1

目前正在处理一个 NDK 项目并试图弄清楚为什么我的.so文件没有被打包到我的.apk. 不过,这些.so文件正在创建中,并被放入app/src/main/libs/$arch. 当我调试我的应用程序时,这是我得到的错误:

07-19 09:32:43.558 8530-8530/com.example.SanAngeles E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.SanAngeles, PID: 8530
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.SanAngeles-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.SanAngeles-2/lib/x86_64, /vendor/lib64, /system/lib64]]] couldn't find "libsanangeles.so"
    at java.lang.Runtime.loadLibrary(Runtime.java:367)
    at java.lang.System.loadLibrary(System.java:1076)
    at com.example.SanAngeles.GLES20Activity.<clinit>(GLES20Activity.java:133)
    at java.lang.Class.newInstance(Native Method)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

我目前classpath 'com.android.tools.build:gradle-experimental:0.8.0-alpha4'在主 gradle 文件中使用。这是应用程序gradle:

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

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile 'com.android.support:support-v4:24.1.+'
}

model {
    android {
        compileSdkVersion = 23
        buildToolsVersion = '23.0.2'



        defaultConfig.with {
            applicationId = 'com.example.SanAngeles'
            minSdkVersion.apiLevel    = 11
            targetSdkVersion.apiLevel = 23

            buildConfigFields {
                create() {
                    type "int"
                    name "VALUE"
                    value "1"
                }
            }
        }

        buildTypes {
            release {
                minifyEnabled = false
                proguardFiles.add(file('proguard-rules.txt'))
            }
        }

        ndk {
            moduleName "sanangeles"
            stl "stlport_static"
            CFlags.add("-I../../common/freetype/include")
            CFlags.add("-DANDROID_NDK")
            CFlags.add("-DDISABLE_IMPORTGL")
            CFlags.add("-DFT2_BUILD_LIBRARY=1")
            ldLibs.add("EGL")
            ldLibs.add("android")
            ldLibs.add("GLESv2")
            ldLibs.add("dl")
            ldLibs.add("log")
            ldLibs.add("mui")
        }

        sources {
            main {
                java {
                    source {
                        srcDir "src"
                    }
                }
                jni {
                    exportedHeaders {
                        srcDirs  = ["../../common/freetype/include"]
                        srcDirs += ["../../common/freetype/include/freetype"]
                        srcDirs += ["../../common/freetype/include/freetype/config"]
                    }

                    source {
                        srcDir "../../common/src"

                        include "../../common/freetype/src/autofit/autofit.c"
                        include "../../common/freetype/src/base/basepic.c"
                        include "../../common/freetype/src/base/ftapi.c"
                        ...
                    }
                }
            }
        }
    }
}
4

1 回答 1

0

刚刚想通了。这里的答案相同:Android Unsatisfied Link using gradle experimental v0.6.0-beta6

于 2016-07-19T14:57:25.647 回答