2016-07-13 3 views
1

나는 아래 URL의 도움으로 오픈 카스케이드에 안드로이드 어플리케이션을 만들려고합니다.오픈 카스케이드 안드로이드 스튜디오

07-12 17:13:09.711: E/occtJniViewer(16333): Error: native library "gnustl_shared" is unavailable: 

07-12 17:13:09.711: E/occtJniViewer(16333): dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.opencascade.jnisample-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libgnustl_shared.so" 

Error: native library "freetype" is unavailable: 

07-12 17:13:09.711: E/occtJniViewer(16333): dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.opencascade.jnisample-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libfreetype.so" 

Error: native library "freeimage" is unavailable: 

07-12 17:13:09.711: E/occtJniViewer(16333): dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.opencascade.jnisample-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libfreeimage.so" 

Error: native library "TKernel" is unavailable: 

07-12 17:13:09.711: E/occtJniViewer(16333): dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.opencascade.jnisample-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libTKernel.so" 

내가 gnustl_shared 라이브러리 및 기타 .so files을 추가 할 수 없습니다입니다 : 나는 아래의 오류에 갇혀 있어요 제외

http://www.opencascade.com/doc/occt-7.0.0/overview/html/samples_java_android_occt.html

모든 것이 잘 작동합니다. 위의 링크에서 이에 대한 세부 정보를 제공하지 않으므로 단계를 제안하십시오.

도움이 될 것입니다. 감사.

답변

1

OpenCascade는 응용 프로그램을 빌드하는 데 바이너리를 제공하지 않습니다. 윈도우 OS에서 안드로이드에 대한 자신의 .so를 바이너리 파일을 빌드 :

  1. Building with CMake for Android
  2. 만 사용 Freetype 열기 캐스케이드 설치되어 조심스럽게 여기에 주어진 단계를 따르십시오. FreeImage 및 기타는이 샘플에 필요하지 않습니다.
  3. CMake 파일을 성공적으로 구성하고 생성 한 후에 1 단계 URL을 따르십시오.
  4. Android 용 이진 파일을 만드는 중에 많은 문제가 발생할 수 있습니다. 아래 트릭을 따르십시오 :

    a. declspec(dllexport) x 관련 오류입니다. 그것은 freetype-x.x.x/include/config/ftoption.h 안에 OCC와 함께 제공되는 타사 라이브러리 freetype에 있습니다. 오류에 제공된 줄 번호 (OCC 7.0.0이 사용 된 경우 282 개)를 주석으로 처리하고 그 대신에 #define FT_EXPORT_DEF(x) x을 입력하여 해결할 수 있습니다.

    b. make 명령을 사용하여 다시 빌드를 시작하십시오.

    c. freetype.so를 freetype-xx/lib에 붙여 넣습니다. libEGL.so를 ..\android-ndk\platforms\android-xx\arch-arm\usr\lib에서 복사하여 freetype-xx/lib에 붙여 넣으십시오.

    d. 1 단계에서 주어진 CMake 출력 폴더의 inc 폴더를 엽니 다. ..\android-ndk\platforms\android-xx\arch-arm\usr\include에 내용을 복사하고 inc 폴더에 붙여 넣습니다. 4.b 단계를 수행하십시오.

참고 : 안드로이드-xx는 ANDROID_NATIVE_API_LEVEL에 따라 달라집니다. 그것은 android-15 일 수 있습니다.

  1. 오류가없는 경우 계속해서 1 단계 URL을 따르십시오.
  2. 설치가 성공적으로 완료되면 CMake 출력 디렉토리로 이동하여 모든 하위 폴더 (lib32/gcc/lib 일 수 있음)에서 lib 폴더를 찾습니다. lib 폴더 안에는 필요한 바이너리 파일이 모두 들어 있습니다.
  3. 바이너리를 만들었습니다. download from here 프로젝트의 jnilibs 폴더에 바이너리를 복사하십시오.
  4. freetype 외에도 타사 라이브러리가 필요하지 않습니다.

이제 외부 바이너리로 추가하려면 gnustl_shared이 필요하지 않습니다.local.properties 내부 코드

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

model { 
    android { 
     compileSdkVersion = 24 
     buildToolsVersion = "24.0.2" 

     defaultConfig.with { 
      applicationId = "com.occ_poc_as" 
      minSdkVersion.apiLevel = 21 
      targetSdkVersion.apiLevel = 24 
      versionCode = 1 
      versionName = "1.0" 
     } 
     buildTypes { 
      release { 
       minifyEnabled = false 
       proguardFiles.add(file('proguard-android.txt')) 
      } 
     } 

     ndk { 
      moduleName = "OcctJni_Viewer" 
      cppFlags.add("-I${file(getOpenCascadeDir())}".toString()) 
      cppFlags.add("-frtti") 
      cppFlags.add("-fexceptions") 
      stl = "gnustl_shared" 
      toolchain = 'clang' 
      ldLibs.addAll(['android', 'log', 'EGL', 'GLESv2']) 
      cppFlags.addAll(['-Wall', '-std=c++11']) 
      CFlags.addAll(['-Wall', '-std=c++11']) 
     } 

     productFlavors { 
      // for detailed abiFilter descriptions, refer to "Supported ABIs" @ 
      // https://developer.android.com/ndk/guides/abis.html#sa 
      create("arm7") { 
       ndk.with { 
        abiFilters.add("armeabi-v7a") 
        ldFlags.add("-L${file('src/main/jniLibs/armeabi-v7a')}".toString()) 
        File curDir = file('./') 
        curDir = file(curDir.absolutePath) 
        String libsDir = curDir.absolutePath + "\\src\\main\\jniLibs\\armeabi-v7a\\" 
        ldLibs.add(libsDir + "libfreetype.so") 



       ldLibs.add(libsDir + "libTKBRep.so") 
       ldLibs.add(libsDir + "libTKernel.so") 
       ldLibs.add(libsDir + "libTKG2d.so") 
       ldLibs.add(libsDir + "libTKG3d.so") 
       ldLibs.add(libsDir + "libTKGeomAlgo.so") 

       ldLibs.add(libsDir + "libTKGeomBase.so") 
       ldLibs.add(libsDir + "libTKMath.so") 
       ldLibs.add(libsDir + "libTKPrim.so") 
       ldLibs.add(libsDir + "libTKTopAlgo.so") 
       ldLibs.add(libsDir + "libTKBO.so") 

       ldLibs.add(libsDir + "libTKBool.so") 
       ldLibs.add(libsDir + "libTKFillet.so") 
       ldLibs.add(libsDir + "libTKHLR.so") 
       ldLibs.add(libsDir + "libTKIGES.so") 
       ldLibs.add(libsDir + "libTKMesh.so") 

       ldLibs.add(libsDir + "libTKOffset.so") 
       ldLibs.add(libsDir + "libTKOpenGl.so") 
       ldLibs.add(libsDir + "libTKService.so") 
       ldLibs.add(libsDir + "libTKShHealing.so") 
       ldLibs.add(libsDir + "libTKSTEP.so") 

       ldLibs.add(libsDir + "libTKSTEP209.so") 
       ldLibs.add(libsDir + "libTKSTEPAttr.so") 
       ldLibs.add(libsDir + "libTKSTEPBase.so") 
       ldLibs.add(libsDir + "libTKV3d.so") 
       ldLibs.add(libsDir + "libTKXSBase.so") 


       } 

      } 

     } 
    } 

} 

def getOpenCascadeDir() { 
    Properties properties = new Properties() 
    properties.load(new File(rootDir.absolutePath + "/local.properties").newDataInputStream()) 
    def externalModuleDir = properties.getProperty('occ.dir', null) 
    if (externalModuleDir == null) { 
     throw new GradleException(
       "OpenCascade location not found. Define location with occ.dir in the local.properties file!") 
    } 
    return externalModuleDir 
} 

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

아래

내부 app\build.gradle 사용은 조각 아래에 추가합니다.

sdk.dir=D\:\\Software\\android_sdk 
ndk.dir=D\:\\Software\\android-ndk-r12b-windows-x86_64\\android-ndk-r12b 
occ.dir=D\:\\Workspace\\OCCT\\inc 

OcctJniActivity.java를 들어 freeimage를 제거합니다.

  1. 를 사용하여 샘플에 대한 최신 Gradle을 실험 :

     // application code 
        || !loadLibVerbose ("OcctJni_Viewer", aLoaded, aFailed)) 
    

    참고TKJniSample를 교체합니다.

  2. assest 폴더에 셰이더를 추가하는 것을 잊지 마십시오. 이 샘플에는 기타가 필요하지 않습니다.

  3. OCC 7.0.0 및 최신 Android Studio를 사용했습니다.

나는 source codeOCC/include 폴더를 부착하고있다.

관련 문제