我正试图在Android上为opengl es 2编写一个hello三角形。
我发现唯一可行的解决方案是app/
|--> src/
|--> main/
|--> jniLibs/
|--> lib*.so
下build.gradle
下的原生jogl库:
def joglVersion = '2.3.2'
compile "org.jogamp.gluegen:gluegen-rt-main:$joglVersion"
compile "org.jogamp.jogl:jogl-all-main:$joglVersion"
在我对应的this way上,我只是在我的project/natives
build.gradle
它完美无瑕,在运行时,库被提取并提供。
此解决方案的一种替代方法是手动提取它们并将它们放在jniLibs/
下。他们都工作。
在Android上,我从来没有像桌面那样工作,简单natives/android-armv6
。唯一的办法是,正如我在开始时所说的那样,从它们所在的罐子中手动提取它们并将它们放在.jar
下
无论我把plaind目录.apk
(不是压缩,E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.helloTriangle_es2, PID: 9735
java.lang.UnsatisfiedLinkError: dlopen failed: library "//natives/android-armv6//libgluegen-rt.so" not found
at java.lang.Runtime.load(Runtime.java:332)
at java.lang.System.load(System.java:1069)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:624)
at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:63)
at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:106)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:487)
at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:421)
at com.jogamp.common.os.Platform$1.run(Platform.java:317)
at java.security.AccessController.doPrivileged(AccessController.java:45)
at com.jogamp.common.os.Platform.<clinit>(Platform.java:287)
at com.jogamp.common.os.Platform.initSingleton(Platform.java:355)
at com.jogamp.opengl.GLProfile.<clinit>(GLProfile.java:147)
at org.helloTriangle_es2.MainActivity.onCreate(MainActivity.java:23)
at android.app.Activity.performCreate(Activity.java:6322)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5728)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
I/Process: Sending signal. PID: 9735 SIG: 9
Application terminated.
或apk files
)放在哪里,它总是会失败:
provided files('libs/gluegen-rt-natives-android-armv6.jar')
provided files('libs/jogl-all-natives-android-armv6.jar')
环顾四周,我读了hello desktop project,他们说基本上compile
是(某种)运行时..
我试过了,添加:
provided
但没办法。同时尝试provided
/ src/main/jniLibs/armeabi
代替{{1}}没有任何区别......始终是相同的异常
我做错了什么或在{{1}}下手动提取它真的是唯一的解决方案吗?