Missing allheaders.h in Android Studio Project

前端 未结 5 1685
礼貌的吻别
礼貌的吻别 2021-01-14 02:56

I am following the tutorial from this tesseract tutorial and had everything go smoothly up until my actual running of the Java code. When I try

new TessBaseA         


        
相关标签:
5条回答
  • 2021-01-14 03:40

    Ppl, After struggling a day.. finally got the solution

    In build.gradle of tess-two module add the below code:

      sourceSets.main {
        manifest.srcFile 'src/main/AndroidManifest.xml'
        java.srcDirs = ['src/main/java']
        resources.srcDirs = ['src/main/java']
        res.srcDirs = ['src/main/res']
        jni.srcDirs = []
        jniLibs.srcDirs = ['src/main/jniLibs']
    }
    

    Main thing is please check manually weather all those file paths specified in above code exists in tess-two module!!

    Check in which path "liblept.so" and other ".so" files exist in tess-two library. For me it was inside /tesstwo/src/main/jniLibs/armeabi-v7a . Hence i have made jniLibs.srcDirs = ['src/main/jniLibs'] in above code. Hope it helps !!

    0 讨论(0)
  • 2021-01-14 03:43

    I also ran into this problem with Android Studio. After googling some more i found this issue. https://code.google.com/p/android/issues/detail?id=74132

    Apparently the NDK plugin generates it's own Android.mk file and ignore any existing one, so the recommended way is to run ndk-build to generate the native .so files.

    When I used ndk-build in the tess-two directory it compiles just fine and the .so files is created.

    How you can include native libraries in gradle and android studio is described in this post: Add pre-built .so files in project using Android Gradle plugin 0.7.3

    0 讨论(0)
  • 2021-01-14 03:58

    At some point Android Studio suggests to set jni.srcDirs = []

    leading to following sourceSets in the gradle.build of my tess-two library project

    sourceSets.main {
        manifest.srcFile 'src/main/AndroidManifest.xml'
        java.srcDirs = ['src/main/java']
        resources.srcDirs = ['src/main/java']
        res.srcDirs = ['src/main/res']
        jni.srcDirs = []
        jniLibs.srcDirs = ['src/main/libs']
    }
    

    With correct src path entered here this actualy works

    0 讨论(0)
  • 2021-01-14 03:58

    I'm not sure if it works for you but in my case, here's what I've done:

    1. In common.h: change #include <allheaders.h> into #include <src/src/allheaders.h>.

    2. In the library project build.gradle: add this

    sourceSets{
        main {
            manifest.srcFile 'AndroidManifest.xml'
            jni.srcDirs = []
            jniLibs.srcDirs = ['src/main/jniLibs']
            resources.srcDirs = ['src']
            res.srcDirs = ['res']
    
        }
    }
    
    0 讨论(0)
  • 2021-01-14 04:03

    This works for me: https://coderwall.com/p/eurvaq/tesseract-with-andoird-and-gradle

    But do not delete libs directory!

    Set compileSdkVersion, buildToolsVersion, minSdkVersion and targetSdkVersio to the same values as in project buil.gradle

    I also change classpath 'com.android.tools.build:gradle:0.9.+' to classpath 'com.android.tools.build:gradle:1.0.+'

    0 讨论(0)
提交回复
热议问题