简体   繁体   English

带有andengine physicsbox2d扩展的Android Studio

[英]Android studio with andengine physicsbox2d extension

I'm trying to include andengine physicsbox2d-extension in my project. 我正在尝试在我的项目中加入andengine physicsbox2d-extension。 It was very easy using eclipse (Just import the project and include in path) 使用eclipse非常容易(只需导入项目并包含在路径中)

But now I'm trying to do it in android studio 但是现在我正在尝试在android studio中做到这一点

I tried those 2 method and get exception in both of them 我尝试了这两种方法并在两者中都获得了例外

Method 1: Include andenginephysicsbox2dextension.jar 方法1:包含andenginephysicsbox2dextension.jar

this cause the following run time exception: 这会导致以下运行时异常:

E/AndroidRuntime﹕ FATAL EXCEPTION: UpdateThread
java.lang.UnsatisfiedLinkError: Couldn't load andenginephysicsbox2dextension from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.myproject.myproject-2.apk,libraryPath=/data/app-lib/com.myproject.myproject-2]: findLibrary returned null
        at java.lang.Runtime.loadLibrary(Runtime.java:355)
        at java.lang.System.loadLibrary(System.java:525)
        at org.andengine.extension.physics.box2d.PhysicsWorld.<clinit>(PhysicsWorld.java:35)

Method 2 : Include andEnginePhysicsBox2DExtension project 方法2:包含andEnginePhysicsBox2DExtension项目

this cause a compilation error: 这会导致编译错误:

    Error:Execution failed for task ':andEnginePhysicsBox2DExtension:compileReleaseNdk'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\Program Files\Android\android-ndk-r10\ndk-build.cmd NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\MYUSER\AndroidstudioProjects\myproject\andEnginePhysicsBox2DExtension\build\intermediates\ndk\release\Android.mk APP_PLATFORM=android-14 NDK_OUT=C:\Users\MYUSER\AndroidstudioProjects\myproject\andEnginePhysicsBox2DExtension\build\intermediates\ndk\release\obj NDK_LIBS_OUT=C:\Users\MYUSER\AndroidstudioProjects\myproject\andEnginePhysicsBox2DExtension\build\intermediates\ndk\release\lib APP_ABI=all
Error Code:
    1 

Does anyone manage to import this extension to android studio? 是否有人设法将此扩展名导入android studio?

What am I doing wrong? 我究竟做错了什么?

You can go on with Method 1: 您可以继续进行方法1:

  • include andenginephysicsbox2dextension.jar 包括andenginephysicsbox2dextension.jar
  • create a folder named jniLibs inside your app project directory and copy armeabi , armeabi-v7a and x86 folders to it 在您的应用程序项目目录中创建一个名为jniLibs的文件夹,并将armeabiarmeabi-v7ax86 文件夹复制到该文件夹

your project is ignoring .so files from the extension project. 您的项目正在忽略扩展项目中的.so文件。

you can follow my answer here https://stackoverflow.com/a/34068202/2026280 您可以在这里按照我的回答https://stackoverflow.com/a/34068202/2026280

or 要么

Its very simple. 非常简单。 Follow this simple steps 遵循以下简单步骤

1) Create a new folder called "lib" inside the libs folder of the main app . 1)主应用程序的libs文件夹中创建一个名为“ lib”的新文件夹。

2) Copy all the folders ie.armabi , armabi-v7a etc from andEnginePhysicsBox2DExtension/libs folder, and paste in in the previously created "lib" folder in main app . 2)从andEnginePhysicsBox2DExtension / libs文件夹复制所有文件夹,例如.armabi,armabi-v7a等,然后粘贴到主应用程序中先前创建的“ lib”文件夹中。

3) Now compress the "lib" folder as "lib.zip" and rename it to "lib.jar" . 3)现在将“ lib”文件夹压缩为“ lib.zip” ,并将其重命名为“ lib.jar” this changes the zip extension to jar . 这将zip扩展名更改为jar

4) Finally add a line -- compile files('lib.jar') under dependencies{} in Build.gradle file of your main app . 4)最后添加一行-在主应用程序的 Build.gradle文件中的dependencies {}下编译files('lib.jar')

5) Clean and build the project. 5)清理并构建项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM