tess-two can't find libpng.so - android

I have followed building instructions for tess-two on
Github
I build tess-two using NDK successfully and imported the library
I am trying to run the test application provided on the same repository but whenever the application starts it gives the following exception:
That error is caused once new TessBaseAPI(); is called.
dlopen("/data/app-lib/com.datumdroid.android.ocr.simple-2/liblept.so") failed: Cannot load library: soinfo_link_image(linker.cpp:1635): could not load library "libpng.so" needed by "liblept.so"; caused by load_library(linker.cpp:745): library "libpng.so" not found
Can anyone help with that?

I have followed suggestion of Dmitry Zaitsev & thannks to him , solved my problem also .
Please update your TessBaseAPI.java from tess-two library project as below :
static {
System.loadLibrary("png");
System.loadLibrary("lept");
System.loadLibrary("tess");
nativeClassInit();
}
Build tess-two project after updating these file . In my case I have build it using eclipse.
Hope it should solve your problem as well.

It seems like System.loadLibrary("png") call is missing in TessBaseAPI, therefore library can't be found.
Try to call System.loadLibrary("png") before calling new TessBaseAPI(). Typically this is done in static initialization block, like so:
public class MyClass {
static {
System.loadLibrary("png");
}
public void doStuff() {
new TessBaseAPI();
}
}

Related

how to use a native library using JNI in Android

I am new in JNI and trying to use a [library][1] in android project using ndk. It seems the
It seems the library is loaded in the android project properly using the following code :
static{
System.loadLibrary("usb1.0");
}
but when I try to call a native method following the libusb API like libusb_init() I get following error :
No implementation found for void com.example.hellojni.MainActivity.libusb_init() (tried Java_com_example_hellojni_MainActivity_libusb_1init and Java_com_example_hellojni_MainActivity_libusb_1init__)
what am I missing ? Do you have any better beginner examples ?
[1]: https://libusb.sourceforge.io/api-1.0/index.html

Visual Studio can't find extension methods Splat.BitmapMixins.FromNative() and Splat.BitmapMixins.ToNative() in Android app

While upgrading a Xamarin app that leverages Splat's bitmap functionality we are getting errors around the use of the methods mentioned in the title:
'IBitmap' does not contain a definition for 'ToNative' and no accessible extension method 'ToNative' accepting a first argument of type 'IBitmap' could be found (are you missing a using directive or an assembly reference?)
In an effort to troubleshoot the problem we have created a new sample Android-only Xamarin app and referenced Splat and Splat.Drawing via NuGet. We then added calls to these methods and have reproduced the error:
public void Bar(IBitmap source)
{
Bitmap native = source.ToNative();
IBitmap bitmap = native.FromNative();
}
It seems as though the Andriod app may not be referencing the proper build of the Splat libraries. When I monitor paths containing %USERPROFILE%\.nuget\packages\splat in ProcMon I don't see any attempt by Visual Studio to open/read anything other than files in the .\netstandard2.0 directories during the build process.
When I open the netstandard2.0 libraries in DotPeek I can see that the class BitmapMixins is not included, but it is included in the monoandroid90 builds.
How do I get the reference to Splat in the Android project to pull in the proper build of Splat?
Example project can be found here: https://github.com/jctlp/SplatBitmap
The error caused by that you did not have the extension methods to assist with dealing with Bitmaps of ToNative and FromNative.
Please do not add reference by installing the Splat from NuGet directly. Add reference to the whole project of Splat would be okay.
Download the whole Splat project from the link below.
https://github.com/reactiveui/splat.git
I create a Xamarin.forms app named App1. And create a class Class2.cs in App1.Android. When I add reference to Splat from the project. It works well with ToNative and FromNative extension method.
Please note: Do not use the Bitmap, use Android.Graphics.Drawables.Drawable or var instead.
public void Bar(IBitmap source)
{
Android.Graphics.Drawables.Drawable native = source.ToNative();//var
IBitmap bitmap = native.FromNative();
}

Android MapFragrement Missing Library libMAPSJNI.so

I am trying to embed HereMap into my project. But I had encounter the following errors:
ERROR: Cannot initialize Map Fragment,MISSING_LIBRARIES,Library /data/user/0/my_project_package/files/../lib/libMAPSJNI.so not found.,java.lang.Throwable
I: at com.nokia.maps.at.a(EngineError.java:27)
I: at com.nokia.maps.MapsEngine.b(MapsEngine.java:367)
I: at com.nokia.maps.MapsEngine.a(MapsEngine.java:343)
I: at com.here.android.mpa.common.MapEngine.init(MapEngine.java:129)
I: at com.nokia.maps.br.a(MapFragmentImpl.java:126)
I: at com.here.android.mpa.mapping.MapFragment.init(MapFragment.java:132)
Following are the codes to use HereMap:
gmMapFragment = new MapFragment();
activity.getFragmentManager().beginTransaction().add(gmCenterView.getId(), gmMapFragment, "here_map_fragment").commit();
gmMapFragment.init(activity, new OnEngineInitListener() {
#Override
public void onEngineInitializationCompleted(OnEngineInitListener.Error error) {
if (error == OnEngineInitListener.Error.NONE) {
gmMapFragment.getMapGesture().addOnGestureListener(gestureListener);
// Exceptions are thrown here!!!
gmMap = gmMapFragment.getMap();
....
}
}
};
I think I figure out what's wrong myself. It's that I didn't copy the "armeabi-v7a" folder with lots of .so files into the "jniLib" folder of my project. Sorry, I am pretty new on this.
thanks for the response.
Following are my steps of adopting Here Map into my project:
Step 1. Put the "HERE-sdk.jar" (also "HERE-sdk.jar.properties", "HERE-sdk-javadoc.jar") into the "lib" directory of my Android Studio project.
Step 2. Add the following setup in the build.gradle:
dependencies {
...
compile files('libs/HERE-sdk.jar')
...
}
Yes that link was the instructions we followed when we started the Here Map coding. The "gmCenterView" is actually a "RelativeLayout" that we will put the map fragment on.
public class MyView extends RelativeLayout {
...
}
MyView gmCenterView = ...
Please upgrade to the latest SDK. We have switched our deployment methods with AAR files which bundle both the Jar and native libraries together.
What you have provided above will only include the jar library. You still need to add the native binaries to the gradle file for it to work.

Robolectric - Could not load class: org.robolectric.shadows.ShadowMultiDex

I am configuring Robolectric for a project that uses multi dex. I am using Robolectric 3.0 RC3 which should support Multidex without throwing that "Multi dex installation failed" exception.
testCompile('org.robolectric:robolectric:3.0-rc3')
My sample test is in src/test/java/SandwichTest:
#RunWith(RobolectricGradleTestRunner.class)
public class SandwichTest {
#Test
public void firstTest() { }
}
I have a global configuration file to load ShadowMultiDex in src/test/resources called robolectric.properties per the instructions on the Robolectric site:
shadows=org.robolectric.shadows.ShadowMultiDex
When I run my sample SandwichTest, I get this exception:
Could not load class: org.robolectric.shadows.ShadowMultiDex
java.lang.RuntimeException: Could not load class: org.robolectric.shadows.ShadowMultiDex
at org.robolectric.annotation.Config$Implementation.parseClass(Config.java:147)
It looks like Robolectric is finding my configuration file but is unable to load the ShadowMultiDex class. Attempting to add the shadow multi dex module to my gradle file manually:
testCompile('org.robolectric:shadows-multidex:3.0-SNAPSHOT')
or
testCompile('org.robolectric:shadows-multidex')
Causes "failed to resolve" issues during sync.
What steps am I missing to get this sample test to run?
In your question, I noticed you were missing a version on your Gradle dependency.
You have:
testCompile('org.robolectric:shadows-multidex')
You need:
testCompile('org.robolectric:shadows-multidex:3.0')
Actual Release: https://oss.sonatype.org/content/repositories/releases/org/robolectric/shadows-multidex/
You should remove the:
shadows=org.robolectric.shadows.ShadowMultiDex
from your src/test/resources/robolectric.properties file. That is used for custom Shadows.

Importing Java Library JAR into eclipse

I'm currently trying to implement a browser with pipelining feature in it. The problem is in order to code the HTTP pipeline, i need the support of a library. I tried to import it to my workspace by using Project - > properties -> Java build path ->addJar. And I was able to add it successfully. But now my problem is, even though it is added to my workspace it doesnt let me run this code. It gives me errors as if I have not imported the library:
package com.test.download;
import java.util.Collections;
import org.factor45.*;
public class Example {
// Execute the request
HttpRequestFuture<String> future = client.execute("hotpotato.factor45.org", 80, request,
new BodyAsStringProcessor());
future.addListener(new HttpRequestFutureListener<String>() {
#Override
public void operationComplete(HttpRequestFuture<String> future) throws Exception {
System.out.println(future);
if (future.isSuccessfulResponse()) {
System.out.println(future.getProcessedResult());
}
client.terminate();
}
});
}
This is available in the same website which provided me the library for the above code. "Here" is the website for your reference. Also you can find the JAR file inside this website.
Please help me to figure out the problem. If you solve this you are a life saver! Thanks in advance!
Try this:
Properties >> Java Build Path >> Libraries >> Add External JARs... Then select the library

Categories

Resources