Configuring Tesseract in Android - android

I am facing a very weird problem while configuring Tesseract in Android. Following all required steps described here and SO like this and this i have imported tess-two library in eclipse. NDK-build and ant release was also successfull. I have used latest ndk version and android sdk v19(4.4.2).
Next, i had imported a sample project in eclipse written in above blog. All were build successfully. But, when i run the project in a real device, it gives me such a weird error in onPhotoTaken event that possible google search can't answer me nothing!
Logcat says:
08-22 15:04:44.812: V/SimpleAndroidOCR.java(16578): Before baseApi
08-22 15:04:44.812: D/dalvikvm(16578): Trying to load lib /data/app-lib/com.datumdroid.android.ocr.simple-1/liblept.so 0x41e56b50
08-22 15:04:44.822: D/dalvikvm(16578): GC_CONCURRENT freed 1K, 14% free 4989K/5788K, paused 2ms+2ms, total 18ms
08-22 15:04:44.822: E/dalvikvm(16578): dlopen("/data/app-lib/com.datumdroid.android.ocr.simple-1/liblept.so") failed: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "rand" referenced by "liblept.so"...
08-22 15:04:44.832: W/dalvikvm(16578): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/googlecode/tesseract/android/TessBaseAPI;
08-22 15:04:44.832: D/AndroidRuntime(16578): Shutting down VM
08-22 15:04:44.832: W/dalvikvm(16578): threadid=1: thread exiting with uncaught exception (group=0x41be0930)
08-22 15:04:44.832: E/AndroidRuntime(16578): FATAL EXCEPTION: main
08-22 15:04:44.832: E/AndroidRuntime(16578): java.lang.ExceptionInInitializerError
08-22 15:04:44.832: E/AndroidRuntime(16578): at com.datumdroid.android.ocr.simple.SimpleAndroidOCRActivity.onPhotoTaken(SimpleAndroidOCRActivity.java:211)
08-22 15:04:44.832: E/AndroidRuntime(16578): at com.datumdroid.android.ocr.simple.SimpleAndroidOCRActivity.onActivityResult(SimpleAndroidOCRActivity.java:135)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.Activity.dispatchActivityResult(Activity.java:5302)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.ActivityThread.deliverResults(ActivityThread.java:3315)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2729)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2771)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2235)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.os.Handler.dispatchMessage(Handler.java:99)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.os.Looper.loop(Looper.java:137)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.ActivityThread.main(ActivityThread.java:5041)
08-22 15:04:44.832: E/AndroidRuntime(16578): at java.lang.reflect.Method.invokeNative(Native Method)
08-22 15:04:44.832: E/AndroidRuntime(16578): at java.lang.reflect.Method.invoke(Method.java:511)
08-22 15:04:44.832: E/AndroidRuntime(16578): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
08-22 15:04:44.832: E/AndroidRuntime(16578): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561)
08-22 15:04:44.832: E/AndroidRuntime(16578): at dalvik.system.NativeStart.main(Native Method)
08-22 15:04:44.832: E/AndroidRuntime(16578): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "rand" referenced by "liblept.so"...
08-22 15:04:44.832: E/AndroidRuntime(16578): at java.lang.Runtime.loadLibrary(Runtime.java:371)
08-22 15:04:44.832: E/AndroidRuntime(16578): at java.lang.System.loadLibrary(System.java:535)
08-22 15:04:44.832: E/AndroidRuntime(16578): at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:44)
08-22 15:04:44.832: E/AndroidRuntime(16578): ... 17 more
Probably the most important part of this error message is:
08-22 15:04:44.832: E/AndroidRuntime(16578): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "rand" referenced by "liblept.so"...
I checked liblept.so is inside the libs folder of library project that i referenced in my sample project.
Can anyone point me the solution or suggestion of this time-killing problem? Thanks in advance.

There seems to be a problem with the NDK toolchain version 4.9.
Try pulling the latest version of the tess-two library code, which includes the following in its Application.mk:
NDK_TOOLCHAIN_VERSION := 4.8
You will need to use the "ndk32" version of the NDK for 32-bit targets.

Related

OutOfMemoryError occurs using YouTube Android player api 1.2.2

Play video using youtube player sdk about 30~40 times causes Youtube application crashes, then a DeadObjectException will raise from my app due to the death of remote process. steps to reproduce:
launch activity and initialize YouTubePlayer
load and play a video for a few seconds
release YouTubePlayer and exit activity
repeat step 1-3 about 30~40 times
OutOfMemoryError log(full logs):
08-22 12:01:01.461 E/AndroidRuntime( 3017): FATAL EXCEPTION: main
08-22 12:01:01.461 E/AndroidRuntime( 3017): Process: com.google.android.youtube.player, PID: 3017
08-22 12:01:01.461 E/AndroidRuntime( 3017): java.lang.OutOfMemoryError: Could not allocate JNI Env
08-22 12:01:01.461 E/AndroidRuntime( 3017): at java.lang.Thread.nativeCreate(Native Method)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at java.lang.Thread.start(Thread.java:1063)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:921)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at java.util.concurrent.ThreadPoolExecutor.ensurePrestart(ThreadPoolExecutor.java:1556)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:310)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:527)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at java.util.concurrent.ScheduledThreadPoolExecutor.execute(ScheduledThreadPoolExecutor.java:616)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at reo.a(SourceFile:134)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at sgh.a(SourceFile:722)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at gan.a(SourceFile:310)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at gan.b(SourceFile:338)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerService$2.run(SourceFile:215)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at android.os.Handler.handleCallback(Handler.java:739)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at android.os.Handler.dispatchMessage(Handler.java:95)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at android.os.Looper.loop(Looper.java:148)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at android.app.ActivityThread.main(ActivityThread.java:5417)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at java.lang.reflect.Method.invoke(Native Method)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
08-22 12:01:01.461 E/AndroidRuntime( 3017): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
and DeadObjectException
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): java.lang.IllegalStateException: android.os.DeadObjectException
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at gix.surfaceCreated(SourceFile:189)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.view.SurfaceView.updateWindow(SurfaceView.java:582)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:177)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2055)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.view.Choreographer.doCallbacks(Choreographer.java:670)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.view.Choreographer.doFrame(Choreographer.java:606)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.os.Handler.handleCallback(Handler.java:739)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.os.Handler.dispatchMessage(Handler.java:95)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.os.Looper.loop(Looper.java:148)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.app.ActivityThread.main(ActivityThread.java:5417)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at java.lang.reflect.Method.invoke(Native Method)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): Caused by: android.os.DeadObjectException
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.os.BinderProxy.transactNative(Native Method)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at android.os.BinderProxy.transact(Binder.java:503)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ISurfaceHolderService$Stub$Proxy.a(SourceFile:110)
08-22 12:01:01.842 E/MonitoringInstrumentation( 2976): at gix.surfaceCreated(SourceFile:186)
YouTube App version is 11.29.55 , Nexus 5 emulator with Marshmallow
, I've tested it with other versions of YouTube App like 10.25.57 and 10.40.58, the OOM still occurs.
At the very beginning when I encounter this issue I thought it was just caused by some incorrectly api method calls, but after so many hours research I figured out it should be a YouTube App's issue, hope someone can help me to resolve it, or at least avoid it.
The memory of process com.google.android.youtube.player is increasing while player initialization and video playing from Memory Monitor, and many YoutubeService instances created but not recycled from the dump file. Any idea?
I test it with a demo application based on the official YouTubeAndroidAPI sample and the OutOfMemory error occurs as well, I just replaced cueVideo(String) by loadVideo(String) in PlayerViewDemoActivity for auto-playing, and added YouTubePlayer#release() in onDestroy(), also I added a test code based on Espresso to reproduce the memory leak issue.
here is the test code, and here for full demo code.
package com.examples.youtubeapidemo.play;
import android.os.SystemClock;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import android.util.Log;
import com.examples.youtubeapidemo.YouTubeAPIDemoActivity;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.Espresso.pressBack;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
/**
* for YouTubePlayerView testing
*/
#RunWith(AndroidJUnit4.class)
#LargeTest
public class PlayerViewTest {
#Rule
public ActivityTestRule<YouTubeAPIDemoActivity> mActivityTestRule =
new ActivityTestRule<YouTubeAPIDemoActivity>(YouTubeAPIDemoActivity.class);
#Test
public void testYouTubeMemoryLeaks() {
int count = 0;
while(count < 100) {
onView(withText("Simple PlayerView")).perform(click());
SystemClock.sleep(10000); // waiting for video start playing
pressBack();
count++;
Log.i("PlayerViewTest", "count: " + count);
}
}
}
I reduced the bug occurrence by putting youtube calls (like youtubePlayer.loadVideo(), cueVideo(), getCurrentTimeMillis() etc.) in a try catch block and catch the IllegalStateException exception then reinitialize youtube player.
and worked around it by catching these exceptions and restart activity,
see my answer on this thread :
Getting a lot of crashes from android youtube player api

ActivityNotFoundException in library projecy while the Activity is there and is declared in Manifest

I am trying to use this library. But the library project as well as the demo project on the github page is for Android Studio, but for some reason I use Eclipse. So I added the library and the demo project to Eclipse (see below for how I did that) and uploaded them here:
customsearchable - library Eclipse project
demo - demo Eclipse project
So what I did was that I created a new library project in Eclipse and copied all the files from the github library project. Following screenshot shows my project structure:
I added this library project to my demo project just like we add the app_compat v7 project.
Then I went on the create a demo project in Eclipse and copied all the files and resources from the demo project in their github repository.
But when I run it, it gives me android.content.ActivityNotFoundException: Unable to find explicit activity class {br.com.edsilfer/br.com.customsearchable.SearchActivity}; have you declared this activity in your AndroidManifest.xml?
Following are the Logcat of the demo project, and the manifest of the library project:
FROM LOGCAT OF DEMO PROJECT:
08-22 02:53:26.110: E/AndroidRuntime(2405): FATAL EXCEPTION: main
08-22 02:53:26.110: E/AndroidRuntime(2405): Process: br.com.edsilfer, PID: 2405
08-22 02:53:26.110: E/AndroidRuntime(2405): android.content.ActivityNotFoundException: Unable to find explicit activity class {br.com.edsilfer/br.com.customsearchable.SearchActivity}; have you declared this activity in your AndroidManifest.xml?
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1777)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1501)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.app.Activity.startActivityForResult(Activity.java:3745)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.app.Activity.startActivityForResult(Activity.java:3706)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:820)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.app.Activity.startActivity(Activity.java:4016)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.app.Activity.startActivity(Activity.java:3984)
08-22 02:53:26.110: E/AndroidRuntime(2405): at br.com.edsilfer.Main.onOptionsItemSelected(Main.java:82)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.app.Activity.onMenuItemSelected(Activity.java:2885)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:353)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:144)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.support.v7.internal.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:99)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.support.v7.app.AppCompatDelegateImplV7.onMenuItemSelected(AppCompatDelegateImplV7.java:541)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.support.v7.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:811)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.support.v7.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:153)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.support.v7.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:958)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.support.v7.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:948)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.support.v7.widget.ActionMenuView.invokeItem(ActionMenuView.java:598)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.support.v7.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:139)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.view.View.performClick(View.java:4780)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.view.View$PerformClick.run(View.java:19866)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.os.Handler.handleCallback(Handler.java:739)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.os.Handler.dispatchMessage(Handler.java:95)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.os.Looper.loop(Looper.java:135)
08-22 02:53:26.110: E/AndroidRuntime(2405): at android.app.ActivityThread.main(ActivityThread.java:5254)
08-22 02:53:26.110: E/AndroidRuntime(2405): at java.lang.reflect.Method.invoke(Native Method)
08-22 02:53:26.110: E/AndroidRuntime(2405): at java.lang.reflect.Method.invoke(Method.java:372)
08-22 02:53:26.110: E/AndroidRuntime(2405): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
08-22 02:53:26.110: E/AndroidRuntime(2405): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
MANIFEST OF LIB PROJECT:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.com.customsearchable">
<uses-sdk
android:minSdkVersion="22"
android:targetSdkVersion="22" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<activity android:name="br.com.customsearchable.SearchActivity"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize|stateVisible"
android:theme="#style/Theme.AppCompat.Translucent" >
</activity>
</application>
</manifest>
EDIT # 1
After being pointed to this question by #MFaisalHyder I added the following element to the <application> element of the demo project:
<activity android:name="br.com.customsearchable.SearchActivity"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize|stateVisible"
android:theme="#style/Theme.AppCompat.Translucent" >
</activity>
Now, after touching the Search action from the toolbar, I get:
08-22 04:44:31.332: E/AndroidRuntime(2104): FATAL EXCEPTION: main
08-22 04:44:31.332: E/AndroidRuntime(2104): Process: br.com.edsilfer, PID: 2104
08-22 04:44:31.332: E/AndroidRuntime(2104): java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.edsilfer/br.com.customsearchable.SearchActivity}: android.view.InflateException: Binary XML file line #32: Error inflating class android.support.design.widget.TextInputLayout
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.app.ActivityThread.access$800(ActivityThread.java:151)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.os.Handler.dispatchMessage(Handler.java:102)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.os.Looper.loop(Looper.java:135)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.app.ActivityThread.main(ActivityThread.java:5254)
08-22 04:44:31.332: E/AndroidRuntime(2104): at java.lang.reflect.Method.invoke(Native Method)
08-22 04:44:31.332: E/AndroidRuntime(2104): at java.lang.reflect.Method.invoke(Method.java:372)
08-22 04:44:31.332: E/AndroidRuntime(2104): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
08-22 04:44:31.332: E/AndroidRuntime(2104): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
08-22 04:44:31.332: E/AndroidRuntime(2104): Caused by: android.view.InflateException: Binary XML file line #32: Error inflating class android.support.design.widget.TextInputLayout
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:916)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.view.LayoutInflater.rInflate(LayoutInflater.java:802)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
08-22 04:44:31.332: E/AndroidRuntime(2104): at br.com.customsearchable.SearchActivity.onCreate(SearchActivity.java:66)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.app.Activity.performCreate(Activity.java:5990)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
08-22 04:44:31.332: E/AndroidRuntime(2104): ... 10 more
08-22 04:44:31.332: E/AndroidRuntime(2104): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.TextInputLayout" on path: DexPathList[[zip file "/data/app/br.com.edsilfer-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
08-22 04:44:31.332: E/AndroidRuntime(2104): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
08-22 04:44:31.332: E/AndroidRuntime(2104): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-22 04:44:31.332: E/AndroidRuntime(2104): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.view.LayoutInflater.createView(LayoutInflater.java:571)
08-22 04:44:31.332: E/AndroidRuntime(2104): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
08-22 04:44:31.332: E/AndroidRuntime(2104): ... 22 more
08-22 04:44:31.332: E/AndroidRuntime(2104): Suppressed: java.lang.ClassNotFoundException: android.support.design.widget.TextInputLayout
08-22 04:44:31.332: E/AndroidRuntime(2104): at java.lang.Class.classForName(Native Method)
08-22 04:44:31.332: E/AndroidRuntime(2104): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
08-22 04:44:31.332: E/AndroidRuntime(2104): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
08-22 04:44:31.332: E/AndroidRuntime(2104): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
08-22 04:44:31.332: E/AndroidRuntime(2104): ... 25 more
08-22 04:44:31.332: E/AndroidRuntime(2104): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
EDIT # 2
The above error was resolved by adding the <activity> element for the SearchActivity in my project's Manifest. Now I am getting android.view.InflateException: Error Inflating class android.support.design.widget.TextInputLayout. I have added the design library. Below you can see the logcat for the exception and the project properties for the design library project
Logcat
08-22 05:44:34.827: E/AndroidRuntime(2582): FATAL EXCEPTION: main
08-22 05:44:34.827: E/AndroidRuntime(2582): Process: br.com.edsilfer, PID: 2582
08-22 05:44:34.827: E/AndroidRuntime(2582): java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.edsilfer/br.com.customsearchable.SearchActivity}: android.view.InflateException: Binary XML file line #32: Error inflating class android.support.design.widget.TextInputLayout
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.app.ActivityThread.access$800(ActivityThread.java:151)
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.os.Handler.dispatchMessage(Handler.java:102)
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.os.Looper.loop(Looper.java:135)
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.app.ActivityThread.main(ActivityThread.java:5254)
08-22 05:44:34.827: E/AndroidRuntime(2582): at java.lang.reflect.Method.invoke(Native Method)
08-22 05:44:34.827: E/AndroidRuntime(2582): at java.lang.reflect.Method.invoke(Method.java:372)
08-22 05:44:34.827: E/AndroidRuntime(2582): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
08-22 05:44:34.827: E/AndroidRuntime(2582): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
08-22 05:44:34.827: E/AndroidRuntime(2582): Caused by: android.view.InflateException: Binary XML file line #32: Error inflating class android.support.design.widget.TextInputLayout
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.view.LayoutInflater.createView(LayoutInflater.java:633)
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:916)
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.view.LayoutInflater.rInflate(LayoutInflater.java:802)
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
08-22 05:44:34.827: E/AndroidRuntime(2582): at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
08-22 05:44:34.827: E/AndroidRuntime(2582): at br.com.customsearchable.SearchActivity.onCreate(SearchActivity.java:66)
...
08-22 05:44:34.827: E/AndroidRuntime(2582): Caused by: java.lang.reflect.InvocationTargetException
...
08-22 05:44:34.827: E/AndroidRuntime(2582): Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/design/R$styleable;
...
...
java.lang.ClassNotFoundException: android.support.design.R$styleable
...
08-22 05:44:34.827: E/AndroidRuntime(2582): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
EDIT 4:
After deleting (from the emulator) and reinstalling the app, it works somehow, i.e. there is no exception in the appearance of the activity, but the voice search and search suggestions still don't work. =/
Maybe, the launcher intent filter is missing...
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<activity android:name="br.com.customsearchable.SearchActivity"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize|stateVisible"
android:theme="#style/Theme.AppCompat.Translucent" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Try with this, and let me know if it works.
check these two links for help :
One and this one.
Before using any activity of Library Project its every activity and other parts must be declared in the Manifest file.
For your Intent part try like this:
Intent i = new Intent();
i.setClassName("base.package.name.of.your.app","br.com.customsearchable.SearchActivity");
startActivity(i);
//*****Another way******\\
Intent i = new Intent(getApplicationContext(),br.com.customsearchable.SearchActivity.class);
startActivity(i);
One more thing: some people also found that it is the problem of Eclipse (Like this one) so do try to update Eclipse.
Hope i helped you.!
Actually the error you are facing,because of missing design support library.
you can follow the steps to import.
go to the properties of your design library>>select android>>check android version 5.0 or above>> check is library>>add library appcompat_v7>> click apply and ok

Error: You do not have read/write permission to the serial port

I have sample application to read from serial port from here.
I have set device to ttyUSB1(usbserial) and Baud rate to 9600 .
but when I click on console I am getting Error: You do not have read/write permission to the serial port
my logcat is
08-22 15:01:25.210: W/System.err(14524): java.io.IOException: Error running exec(). Command:
[/system/bin/su] Working Directory: null Environment: null
08-22 15:01:25.210: W/System.err(14524): at
java.lang.ProcessManager.exec(ProcessManager.java:211)
08-22 15:01:25.211: W/System.err(14524): at java.lang.Runtime.exec(Runtime.java:168)
08-22 15:01:25.211: W/System.err(14524): at java.lang.Runtime.exec(Runtime.java:241)
08-22 15:01:25.212: W/System.err(14524): at java.lang.Runtime.exec(Runtime.java:184)
08-22 15:01:25.212: W/System.err(14524): at android_serialport_api.SerialPort.<init>
(SerialPort.java:47)
08-22 15:01:25.212: W/System.err(14524): at
android_serialport_api.sample.Application.getSerialPort(Application.java:46)
08-22 15:01:25.213: W/System.err(14524): at
android_serialport_api.sample.SerialPortActivity.onCreate(SerialPortActivity.java:78)
08-22 15:01:25.213: W/System.err(14524): at
android_serialport_api.sample.Sending01010101Activity.onCreate(Sending01010101Activity.java:31)
08-22 15:01:25.214: W/System.err(14524): at
android.app.Activity.performCreate(Activity.java:5020)
08-22 15:01:25.214: W/System.err(14524): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
08-22 15:01:25.214: W/System.err(14524): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
08-22 15:01:25.214: W/System.err(14524): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
08-22 15:01:25.215: W/System.err(14524): at
android.app.ActivityThread.access$600(ActivityThread.java:149)
08-22 15:01:25.215: W/System.err(14524): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
08-22 15:01:25.215: W/System.err(14524): at
android.os.Handler.dispatchMessage(Handler.java:99)
08-22 15:01:25.216: W/System.err(14524): at android.os.Looper.loop(Looper.java:153)
08-22 15:01:25.216: W/System.err(14524): at
android.app.ActivityThread.main(ActivityThread.java:4987)
08-22 15:01:25.216: W/System.err(14524): at java.lang.reflect.Method.invokeNative(Native
Method)
08-22 15:01:25.216: W/System.err(14524): at java.lang.reflect.Method.invoke(Method.java:511)
08-22 15:01:25.217: W/System.err(14524): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
08-22 15:01:25.217: W/System.err(14524): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
08-22 15:01:25.217: W/System.err(14524): at dalvik.system.NativeStart.main(Native Method)
08-22 15:01:25.217: W/System.err(14524): Caused by: java.io.IOException: No such file or
directory
08-22 15:01:25.218: W/System.err(14524): at java.lang.ProcessManager.exec(Native Method)
08-22 15:01:25.219: W/System.err(14524): at
java.lang.ProcessManager.exec(ProcessManager.java:209)
08-22 15:01:25.219: W/System.err(14524): ... 21 more
How can I resolve this.
please help to solve this.
If you are using serial port application go to file SerialPort.java
change the line:
su = Runtime.getRuntime().exec("/system/bin/su");
to
su = Runtime.getRuntime().exec("/system/xbin/su");
Error: You do not have read/write permission to the serial port
Just change bin to xbin.
like this, Runtime.getRuntime().exec("/system/xbin/su");

Application Stopped while rotating the android device [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have five tabs in my application say A,B,C,D and E.My problem is that application stopped while changing the tab from B to any other tabs and rotating the device into landscape mode or portrait mode.
Error log is
08-22 11:27:22.835: E/AndroidRuntime(5992): FATAL EXCEPTION: main
08-22 11:27:22.835: E/AndroidRuntime(5992): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nv.netmdapp1/com.nv.netmdapp1.Home}: java.lang.NullPointerException
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3351)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.app.ActivityThread.access$700(ActivityThread.java:123)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1151)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.os.Handler.dispatchMessage(Handler.java:99)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.os.Looper.loop(Looper.java:137)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.app.ActivityThread.main(ActivityThread.java:4424)
08-22 11:27:22.835: E/AndroidRuntime(5992): at java.lang.reflect.Method.invokeNative(Native Method)
08-22 11:27:22.835: E/AndroidRuntime(5992): at java.lang.reflect.Method.invoke(Method.java:511)
08-22 11:27:22.835: E/AndroidRuntime(5992): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-22 11:27:22.835: E/AndroidRuntime(5992): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-22 11:27:22.835: E/AndroidRuntime(5992): at dalvik.system.NativeStart.main(Native Method)
08-22 11:27:22.835: E/AndroidRuntime(5992): Caused by: java.lang.NullPointerException
08-22 11:27:22.835: E/AndroidRuntime(5992): at com.nv.netmdapp1.ScheduleDailyView.onActivityCreated(ScheduleDailyView.java:89)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1468)
Java code given below.
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
dailyFragment = (SherlockFragment) Fragment.instantiate(appContext, AppointmentDailyView.class.getName(),arguments);
weeklyFragment=(SherlockFragment) Fragment.instantiate(appContext, AppointmentWeeklyView.class.getName(),arguments);
FragmentTransaction ft = getFragmentManager().beginTransaction();
Fragment lastFrag = getFragmentManager().findFragmentByTag("appointmentFrag");
if(lastFrag!=null)
ft.remove(lastFrag);
ft.replace(R.id.ll_appointment_layout, dailyFragment);
ft.commit();
}
#Override
public void onClick(View view)
{
FragmentTransaction ft = getFragmentManager().beginTransaction();
Fragment lastFrag = getFragmentManager().findFragmentByTag("appointmentFrag");
if(lastFrag!=null)
ft.remove(lastFrag);
if(view==btnDaily)
ft.replace(R.id.ll_appointment_layout, dailyFragment);
else
ft.replace(R.id.ll_appointment_layout, weeklyFragment);
ft.commit();
}
When clicking Tab C this part is executed.But while rotating the device control goes to onActivityCreated() of Tab B.
Here null pointer exception occurring line ScheduleDailyView.java:89 is associated with Tab B.But while rotating the device control goes from tab C and D to this file.What is the reason?
Add the android:configChanges="orientation" in the android manifest, it handles the orientation change event in application.
Manifest:
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:configChanges="orientation"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Hope helpful to you..
Rotating the Device restarts your app again:
OnActivityCreated Method is called and you are getting a null pointer exception here:
Caused by: java.lang.NullPointerException
08-20 16:54:43.319: E/AndroidRuntime(5646): at com.nv.netmdapp1.ScheduleDailyView.onActivityCreated(ScheduleDailyView.java:89)
Check what is null here, also you can avoid restarting your activity on rotation by handling configuration changes.

application show unfortunately CustumMenuActivity has stopped

08-22 15:28:41.848: E/Trace(678): error opening trace file: No such file or directory (2)
08-22 15:28:42.387: D/AndroidRuntime(678): Shutting down VM
08-22 15:28:42.387: W/dalvikvm(678): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
08-22 15:28:42.407: E/AndroidRuntime(678): FATAL EXCEPTION: main
08-22 15:28:42.407: E/AndroidRuntime(678): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vikram.custummenuactivity/com.vikram.custummenuactivity.CustumMenuActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.os.Handler.dispatchMessage(Handler.java:99)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.os.Looper.loop(Looper.java:137)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-22 15:28:42.407: E/AndroidRuntime(678): at java.lang.reflect.Method.invokeNative(Native Method)
08-22 15:28:42.407: E/AndroidRuntime(678): at java.lang.reflect.Method.invoke(Method.java:511)
08-22 15:28:42.407: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-22 15:28:42.407: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-22 15:28:42.407: E/AndroidRuntime(678): at dalvik.system.NativeStart.main(Native Method)
08-22 15:28:42.407: E/AndroidRuntime(678): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.ListActivity.onContentChanged(ListActivity.java:243)
08-22 15:28:42.407: E/AndroidRuntime(678): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:259)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.Activity.setContentView(Activity.java:1867)
08-22 15:28:42.407: E/AndroidRuntime(678): at com.vikram.custummenuactivity.CustumMenuActivity.onCreate(CustumMenuActivity.java:24)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.Activity.performCreate(Activity.java:5008)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
08-22 15:28:42.407: E/AndroidRuntime(678): ... 11 more
08-22 15:33:42.558: I/Process(678): Sending signal. PID: 678 SIG: 9
So problem shouldn't be tricky. Your problem is:
Caused by: java.lang.RuntimeException: Your content must have a
ListView whose id attribute is 'android.R.id.list'
It means that you ListView should have id attibute android.R.id.list
<ListView
android:id="#android:id/list"
...
/>
Similar topic:
runtime exception ListView whose id attribute is
'android.R.id.list'
From your stack trace:
"Your content must have a ListView whose id attribute is 'android.R.id.list". Add this id to the appropriate element in your XML layout file, for example:

Categories

Resources