I have a project which has gui consisting of three buttons.Now one of these button is to be associated with other activity.I have developed the code for this activity separately and tested it but now when I'm integrating this in my main gui project it is showing errors.(Clicking on button will get me the current location on google maps).
Here is my log cat :
10-27 01:45:44.533: E/ActivityThread(357): Failed to find provider info for com.google.settings
10-27 01:45:44.563: E/ActivityThread(357): Failed to find provider info for com.google.settings
10-27 01:45:44.633: D/AndroidRuntime(357): Shutting down VM
10-27 01:45:44.633: W/dalvikvm(357): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
10-27 01:45:44.643: E/AndroidRuntime(357): Uncaught handler: thread main exiting due to uncaught exception
10-27 01:45:44.653: E/AndroidRuntime(357): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.gui/com.example.gui.LocationActivity}: java.lang.NullPointerException
10-27 01:45:44.653: E/AndroidRuntime(357): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
10-27 01:45:44.653: E/AndroidRuntime(357): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
10-27 01:45:44.653: E/AndroidRuntime(357): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
10-27 01:45:44.653: E/AndroidRuntime(357): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
10-27 01:45:44.653: E/AndroidRuntime(357): at android.os.Handler.dispatchMessage(Handler.java:99)
10-27 01:45:44.653: E/AndroidRuntime(357): at android.os.Looper.loop(Looper.java:123)
10-27 01:45:44.653: E/AndroidRuntime(357): at android.app.ActivityThread.main(ActivityThread.java:4363)
10-27 01:45:44.653: E/AndroidRuntime(357): at java.lang.reflect.Method.invokeNative(Native Method)
10-27 01:45:44.653: E/AndroidRuntime(357): at java.lang.reflect.Method.invoke(Method.java:521)
10-27 01:45:44.653: E/AndroidRuntime(357): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
10-27 01:45:44.653: E/AndroidRuntime(357): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
10-27 01:45:44.653: E/AndroidRuntime(357): at dalvik.system.NativeStart.main(Native Method)
10-27 01:45:44.653: E/AndroidRuntime(357): Caused by: java.lang.NullPointerException
10-27 01:45:44.653: E/AndroidRuntime(357): at com.example.gui.LocationActivity.onCreate(LocationActivity.java:50)
10-27 01:45:44.653: E/AndroidRuntime(357): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-27 01:45:44.653: E/AndroidRuntime(357): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
10-27 01:45:44.653: E/AndroidRuntime(357): ... 11 more
10-27 01:45:44.693: I/dalvikvm(357): threadid=7: reacting to signal 3
10-27 01:45:44.693: E/dalvikvm(357): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
Can anyone help me to solve this ?
You are getting the error message because at line 50 when you call
map.setBuiltInZoomControls(true);
your map variable is null. Please post your main.xml file as that is where your onCreate method is looking for views when you call findViewById since you called
setContentView(R.layout.main);
Related
I don't know why the app crashes whenever it's supposed to go to the next Activity. I made a practice app that works as it should when using the same format. I uploaded the files to gist.github.
The error is
1216-1216/com.example.chiozokamalu.newfreshstart E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.ArrayIndexOutOfBoundsException
at com.example.chiozokamalu.newfreshstart.MainActivity.onClick(MainActivity.java:164)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
On line 164 of MainActivity.java:
questionView.setText(questions[questionIndex]); // set the text to the next question
EDIT: After Varun helped me, I get a new error which is
1307-1307/com.example.chiozokamalu.newfreshstart E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.chiozokamalu.newfreshstart/com.example.chiozokamalu.newfreshstart.Results1}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.chiozokamalu.newfreshstart.Results1.onCreate(Results1.java:58)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
The questions array at line no. 164 is going out of bound that means questionIndex is greater than the total length of the questions array. So you should add a check on the length before extracting value from the array.
You have added the check but after that you incremented the value so either you modify the if condition to if (questionIndex < questions.length -1)
or modify the questionIndex variable before the if condition
You are getting problem because you haven't initiated resultView9 that is why it is null and giving nullpointer, just initiatlise it as you done with other and everything is fine. You have initialised the resultView8 twice just add resultview9 over there
I'm writing a program for android in Eclipce.
I got a problem with error debugging, when error happens, for example NullPointerExceptioin and I can see that, log the double click (on the log) is not working? As I know it should show me the line in the code where the exception is made.
Does anybody know how to fix this?
10-27 20:28:41.202: E/AndroidRuntime(3232): FATAL EXCEPTION: main
10-27 20:28:41.202: E/AndroidRuntime(3232): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bignerdranch.andriod.geoquiz/com.bignerdranch.andriod.geoquiz.QuizActivity}: java.lang.NullPointerException
10-27 20:28:41.202: E/AndroidRuntime(3232): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
10-27 20:28:41.202: E/AndroidRuntime(3232): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
10-27 20:28:41.202: E/AndroidRuntime(3232): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
10-27 20:28:41.202: E/AndroidRuntime(3232): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
10-27 20:28:41.202: E/AndroidRuntime(3232): at android.os.Handler.dispatchMessage(Handler.java:99)
10-27 20:28:41.202: E/AndroidRuntime(3232): at android.os.Looper.loop(Looper.java:137)
10-27 20:28:41.202: E/AndroidRuntime(3232): at android.app.ActivityThread.main(ActivityThread.java:5039)
10-27 20:28:41.202: E/AndroidRuntime(3232): at java.lang.reflect.Method.invokeNative(Native Method)
10-27 20:28:41.202: E/AndroidRuntime(3232): at java.lang.reflect.Method.invoke(Method.java:511)
10-27 20:28:41.202: E/AndroidRuntime(3232): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-27 20:28:41.202: E/AndroidRuntime(3232): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-27 20:28:41.202: E/AndroidRuntime(3232): at dalvik.system.NativeStart.main(Native Method)
10-27 20:28:41.202: E/AndroidRuntime(3232): Caused by: java.lang.NullPointerException
10-27 20:28:41.202: E/AndroidRuntime(3232): at com.bignerdranch.andriod.geoquiz.QuizActivity.onCreate(QuizActivity.java:57)
10-27 20:28:41.202: E/AndroidRuntime(3232): at android.app.Activity.performCreate(Activity.java:5104)
10-27 20:28:41.202: E/AndroidRuntime(3232): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
10-27 20:28:41.202: E/AndroidRuntime(3232): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
10-27 20:28:41.202: E/AndroidRuntime(3232): ... 11 more
I cant click anywhere.
you can only double click on the line in logcat where your package name is mentioned.You can't double click all the lines in the LogCat
For example, For this LogCat
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.exampl.sample5/com.exampl.sample5.MainActivity}: java.lang.NullPointerException
10-27 23:06:22.269: E/AndroidRuntime(348): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-27 23:06:22.269: E/AndroidRuntime(348): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-27 23:06:22.269: E/AndroidRuntime(348): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-27 23:06:22.269: E/AndroidRuntime(348): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-27 23:06:22.269: E/AndroidRuntime(348): at android.os.Handler.dispatchMessage(Handler.java:99)
10-27 23:06:22.269: E/AndroidRuntime(348): at android.os.Looper.loop(Looper.java:123)
10-27 23:06:22.269: E/AndroidRuntime(348): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-27 23:06:22.269: E/AndroidRuntime(348): at java.lang.reflect.Method.invokeNative(Native Method)
10-27 23:06:22.269: E/AndroidRuntime(348): at java.lang.reflect.Method.invoke(Method.java:507)
10-27 23:06:22.269: E/AndroidRuntime(348): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-27 23:06:22.269: E/AndroidRuntime(348): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-27 23:06:22.269: E/AndroidRuntime(348): at dalvik.system.NativeStart.main(Native Method)
10-27 23:06:22.269: E/AndroidRuntime(348): Caused by: java.lang.NullPointerException
10-27 23:06:22.269: E/AndroidRuntime(348): at com.example.sample.MainActivity.onCreate(MainActivity.java:19)
10-27 23:06:22.269: E/AndroidRuntime(348): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-27 23:06:22.269: E/AndroidRuntime(348): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-27 23:06:22.269: E/AndroidRuntime(348): ... 11 more
Since com.example.sample is my package name, double clicking on the line com.example.sample.MainActivity.onCreate(MainActivity.java:19) will show the line in code.
We use Android Youtube API in out application. Lately I noticed that application crashes every time I try to play a video with enabled ads.
I'm able to reproduce it using their sample applications. I've tried SimplePlayerFragment and SimplePlayerView examples. Both crash when I try to cue the http://www.youtube.com/watch?v=QudbrUcVPxk video (this is just an example, other videos with ads are failing too).
Here is LogCat output:
10-26 19:10:49.074: E/AndroidRuntime(21637): FATAL EXCEPTION: main
10-26 19:10:49.074: E/AndroidRuntime(21637):
java.lang.IllegalStateException: android.os.DeadObjectException 10-26
19:10:49.074: E/AndroidRuntime(21637): at
com.google.android.apps.youtube.api.jar.a.eo.surfaceDestroyed(SourceFile:236)
10-26 19:10:49.074: E/AndroidRuntime(21637): at
android.view.SurfaceView.updateWindow(SurfaceView.java:555) 10-26
19:10:49.074: E/AndroidRuntime(21637): at
android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:232)
10-26 19:10:49.074: E/AndroidRuntime(21637): at
android.view.View.dispatchDetachedFromWindow(View.java:12156) 10-26
19:10:49.074: E/AndroidRuntime(21637): at
android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2565)
10-26 19:10:49.074: E/AndroidRuntime(21637): at
android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2565)
10-26 19:10:49.074: E/AndroidRuntime(21637): at
android.view.ViewGroup.removeViewInternal(ViewGroup.java:3785) 10-26
19:10:49.074: E/AndroidRuntime(21637): at
android.view.ViewGroup.removeViewInternal(ViewGroup.java:3758) 10-26
19:10:49.074: E/AndroidRuntime(21637): at
android.view.ViewGroup.removeView(ViewGroup.java:3690) 10-26
19:10:49.074: E/AndroidRuntime(21637): at
com.google.android.youtube.player.YouTubePlayerView$1.b(Unknown
Source) 10-26 19:10:49.074: E/AndroidRuntime(21637): at
com.google.android.youtube.player.internal.r.h(Unknown Source) 10-26
19:10:49.074: E/AndroidRuntime(21637): at
com.google.android.youtube.player.internal.r$e.onServiceDisconnected(Unknown
Source) 10-26 19:10:49.074: E/AndroidRuntime(21637): at
android.app.LoadedApk$ServiceDispatcher.doDeath(LoadedApk.java:1111)
10-26 19:10:49.074: E/AndroidRuntime(21637): at
android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1125)
10-26 19:10:49.074: E/AndroidRuntime(21637): at
android.os.Handler.handleCallback(Handler.java:730) 10-26
19:10:49.074: E/AndroidRuntime(21637): at
android.os.Handler.dispatchMessage(Handler.java:92) 10-26
19:10:49.074: E/AndroidRuntime(21637): at
android.os.Looper.loop(Looper.java:137) 10-26 19:10:49.074:
E/AndroidRuntime(21637): at
android.app.ActivityThread.main(ActivityThread.java:5103) 10-26
19:10:49.074: E/AndroidRuntime(21637): at
java.lang.reflect.Method.invokeNative(Native Method) 10-26
19:10:49.074: E/AndroidRuntime(21637): at
java.lang.reflect.Method.invoke(Method.java:525) 10-26 19:10:49.074:
E/AndroidRuntime(21637): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
10-26 19:10:49.074: E/AndroidRuntime(21637): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 10-26
19:10:49.074: E/AndroidRuntime(21637): at
dalvik.system.NativeStart.main(Native Method) 10-26 19:10:49.074:
E/AndroidRuntime(21637): Caused by: android.os.DeadObjectException
10-26 19:10:49.074: E/AndroidRuntime(21637): at
android.os.BinderProxy.transact(Native Method) 10-26 19:10:49.074:
E/AndroidRuntime(21637): at
com.google.android.apps.youtube.api.b.a.be.a(SourceFile:221) 10-26
19:10:49.074: E/AndroidRuntime(21637): at
com.google.android.apps.youtube.api.jar.a.eo.surfaceDestroyed(SourceFile:233)
10-26 19:10:49.074: E/AndroidRuntime(21637): ... 22 more
I'd appreciate any ideas on how to solve the problem.
UPD:
Thanks to #septagon, found another related LogCat message:
10-27 16:58:51.763: D/YouTubeAndroidPlayerAPI(25196):
apps.youtube.core.client.DefaultAdStatsClient.a:485 Pinging
__AWCl-JGAkAHIAQWpAn4krwpwE7A-4AIAqAMBmAQFqgSwAU_QADdeVEnDazwBrSnaYs3R1HBqy45Cu537TEJ3YTBlvSni0sRdoz7KdLcSM8GN-htn40LlHEa78Q0Wc-Hrk04QcefoGDWqXcyn7fC6U9J6CfOz_J6n509CB7hJfQX2xrj2YTLwO2_AeK-bj9k3KWULoKQv_ZBYw5PfzGYPi2xuSOmQuuFoYcr0atVp-oLKiFDMrNiGhAsjaCbg8jlG43cEZZZ-VSGq1f9Oz1b-XQKw4AQBiAXhiftBkgUGCAMQARgBkgUGCAQQBRgKkgUGCAQQARgBkgUGCAYQARgBkgUECAYYA5AGAaAGHNgGAoAHuaXfLA&sigh=PjCzMkHYDKo&cid=5Gi9PCMcr3WKhFJWqILtjrdq&template_id=213">http://pubads.g.doubleclick.net/pagead/adview?ai=Cr6PgkatsUt7LE8GpmgXc3oHwBbGx9t8DsZHlu3Kx0vmLARABIOP7kwNQ4vr5ivj___AWCl-JGAkAHIAQWpAn4krwpwE7A-4AIAqAMBmAQFqgSwAU_QADdeVEnDazwBrSnaYs3R1HBqy45Cu537TEJ3YTBlvSni0sRdoz7KdLcSM8GN-htn40LlHEa78Q0Wc-Hrk04QcefoGDWqXcyn7fC6U9J6CfOz_J6n509CB7hJfQX2xrj2YTLwO2_AeK-bj9k3KWULoKQv_ZBYw5PfzGYPi2xuSOmQuuFoYcr0atVp-oLKiFDMrNiGhAsjaCbg8jlG43cEZZZ-VSGq1f9Oz1b-XQKw4AQBiAXhiftBkgUGCAMQARgBkgUGCAQQBRgKkgUGCAQQARgBkgUGCAYQARgBkgUECAYYA5AGAaAGHNgGAoAHuaXfLA&sigh=PjCzMkHYDKo&cid=5Gi9PCMcr3WKhFJWqILtjrdq&template_id=213
10-27 16:58:51.763: D/AndroidRuntime(25196): Shutting down VM 10-27
16:58:51.763: W/dalvikvm(25196): threadid=1: thread exiting with
uncaught exception (group=0x4158d700) 10-27 16:58:51.773:
E/AndroidRuntime(25196): FATAL EXCEPTION: main 10-27 16:58:51.773:
E/AndroidRuntime(25196): java.lang.NullPointerException 10-27
16:58:51.773: E/AndroidRuntime(25196): at
com.google.android.apps.youtube.core.player.AdStatsMacros.a(SourceFile:185)
10-27 16:58:51.773: E/AndroidRuntime(25196): at
com.google.android.apps.youtube.core.client.DefaultAdStatsClient.a(SourceFile:481)
10-27 16:58:51.773: E/AndroidRuntime(25196): at
com.google.android.apps.youtube.core.client.DefaultAdStatsClient.a(SourceFile:467)
10-27 16:58:51.773: E/AndroidRuntime(25196): at
com.google.android.apps.youtube.core.client.DefaultAdStatsClient.a(SourceFile:461)
10-27 16:58:51.773: E/AndroidRuntime(25196): at
com.google.android.apps.youtube.core.client.DefaultAdStatsClient.h(SourceFile:320)
10-27 16:58:51.773: E/AndroidRuntime(25196): at
com.google.android.apps.youtube.core.player.StatsTracker.g(SourceFile:409)
10-27 16:58:51.773: E/AndroidRuntime(25196): at
com.google.android.apps.youtube.core.player.an.handleMessage(SourceFile:1615)
10-27 16:58:51.773: E/AndroidRuntime(25196): at
android.os.Handler.dispatchMessage(Handler.java:95) 10-27
16:58:51.773: E/AndroidRuntime(25196): at
android.os.Looper.loop(Looper.java:137) 10-27 16:58:51.773:
E/AndroidRuntime(25196): at
android.app.ActivityThread.main(ActivityThread.java:5103) 10-27
16:58:51.773: E/AndroidRuntime(25196): at
java.lang.reflect.Method.invokeNative(Native Method) 10-27
16:58:51.773: E/AndroidRuntime(25196): at
java.lang.reflect.Method.invoke(Method.java:525) 10-27 16:58:51.773:
E/AndroidRuntime(25196): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
10-27 16:58:51.773: E/AndroidRuntime(25196): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 10-27
16:58:51.773: E/AndroidRuntime(25196): at
dalvik.system.NativeStart.main(Native Method)
There is bug filed in public issue tracker.
You can track the progress from there.
Bug is also filed internally.
I encounter the same problem too using my Galaxy S4 with the latest version of youtube.
I tried it on my Gnex which does not have the most recent version of youtube and of course everything works fine. seems like the last update made a mess.
Is there any other way to get their attention? is there a way to remove the latest update (just for now, to continue with the development) ?
And for a different topic, have you tried the getCurrentTimeMillis method more than once a second? do you get different time stamps or just the same when you call it more than once a second (say once every 100ms) ?
Thanks,
Roy
Check your unfiltered logcat for a NullPointerException coming from com.google.android.apps.youtube.core.player.AdStatsMacros. If you can find such an error, you're probably having the same problem as I and this question are experiencing.
Youtube Player API android crashes on playback on some devices
I can confirm that this error has been introduced within the last seventy-two hours and caused a flawlessly-working app to crash whenever an ad tries to play. The error appears to be coming from deep inside the YouTube Player API jar. Nothing seems to be confirmed yet, but it looks like YouTube is trying something new on their API back-end and having some troubles.
I am trying to include a customized font in my android application. This is the tutorial that I followed and this seems to have worked for many people: http://tharindudassanayake.wordpress.com/2012/02/25/use-sinhala-fonts-for-your-android-app/
This is how I have tried it:
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/sinhala_font"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="wdhqfndajka"
android:textSize="25sp" />
</LinearLayout>
Code:
TextView txt = (TextView) findViewById(R.id.sinhala_font);
Typeface font = Typeface.createFromAsset(getAssets(), "fonts/amal.TTF");
txt.setTypeface(font);
Unfortunately app crashes (due to native typeface cannot be made) and I get the following in my log cat:
10-27 11:39:14.311: E/AndroidRuntime(28133): FATAL EXCEPTION: main
10-27 11:39:14.311: E/AndroidRuntime(28133): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sinhala/com.example.sinhala.MainActivity}: java.lang.RuntimeException: native typeface cannot be made
10-27 11:39:14.311: E/AndroidRuntime(28133): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
10-27 11:39:14.311: E/AndroidRuntime(28133): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
10-27 11:39:14.311: E/AndroidRuntime(28133): at android.app.ActivityThread.access$600(ActivityThread.java:128)
10-27 11:39:14.311: E/AndroidRuntime(28133): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
10-27 11:39:14.311: E/AndroidRuntime(28133): at android.os.Handler.dispatchMessage(Handler.java:99)
10-27 11:39:14.311: E/AndroidRuntime(28133): at android.os.Looper.loop(Looper.java:137)
10-27 11:39:14.311: E/AndroidRuntime(28133): at android.app.ActivityThread.main(ActivityThread.java:4517)
10-27 11:39:14.311: E/AndroidRuntime(28133): at java.lang.reflect.Method.invokeNative(Native Method)
10-27 11:39:14.311: E/AndroidRuntime(28133): at java.lang.reflect.Method.invoke(Method.java:511)
10-27 11:39:14.311: E/AndroidRuntime(28133): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
10-27 11:39:14.311: E/AndroidRuntime(28133): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
10-27 11:39:14.311: E/AndroidRuntime(28133): at dalvik.system.NativeStart.main(Native Method)
10-27 11:39:14.311: E/AndroidRuntime(28133): Caused by: java.lang.RuntimeException: native typeface cannot be made
10-27 11:39:14.311: E/AndroidRuntime(28133): at android.graphics.Typeface.<init>(Typeface.java:238)
10-27 11:39:14.311: E/AndroidRuntime(28133): at android.graphics.Typeface.createFromAsset(Typeface.java:212)
10-27 11:39:14.311: E/AndroidRuntime(28133): at com.example.sinhala.MainActivity.onCreate(MainActivity.java:15)
10-27 11:39:14.311: E/AndroidRuntime(28133): at android.app.Activity.performCreate(Activity.java:4470)
10-27 11:39:14.311: E/AndroidRuntime(28133): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
10-27 11:39:14.311: E/AndroidRuntime(28133): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
10-27 11:39:14.311: E/AndroidRuntime(28133): ... 11 more
What could possibly be the reason for this? Any help is appreciated!
Are you created a folder called fonts in assets or directly placed in assets folder??if folder not created create a folder and place your font file there I think that is the mistake..In your example he is not created any fonts folder he is directly accessing but you are accessing from fonts folder..
If not fonts folder then change this line to.
Typeface font = Typeface.createFromAsset(getAssets(), "fonts/amal.TTF");
like this..
Typeface font = Typeface.createFromAsset(getAssets(), "amal.TTF");
i got the same exception.
in my case i gave a wrong path to my ttf file.
i wrote: /font/somefont.ttf
i fixed it by removing the first hyphen: font/somefont.ttf
You'll save yourself a lot of trouble, if you're using Android Studio, by placing the "assets/" folder WITHIN "src/main", NOT on the same level as "src/".
In Typeface font = Typeface.createFromAsset(getAssets(), "fonts/amal.TTF"); change to
Typeface font = Typeface.createFromAsset(getAssets(), "fonts/amal.ttf");
that solved for me.
Just bought PhoneGap 2.x Mobile Application Development Hotshot book to improve my knowledge working with PhoneGap and try to run some apps from the book. I downloaded whose apps from their github repository (https://github.com/photokandyStudios/PhoneGap-HotShot-Book-Code-Bundle) and, for example, tried to run first app from Chapter1 (QuizApp). Imported that whole folder with Eclipse(Import > Existing Android Code Into Workspace) and when I try to run it on my emulator or on my real Android device, it just stops working and shuts down. Looks like everything is in their right places, but nothing.
Here I will provide my LogCat information:
07-26 15:24:51.418: E/Trace(853): error opening trace file: No such file or directory (2)
07-26 15:24:51.688: W/dalvikvm(853): Unable to resolve superclass of Lcom/phonegaphotshot/QuizTime/QuizTime; (15)
07-26 15:24:51.688: W/dalvikvm(853): Link of class 'Lcom/phonegaphotshot/QuizTime/QuizTime;' failed
07-26 15:24:51.718: D/AndroidRuntime(853): Shutting down VM
07-26 15:24:51.718: W/dalvikvm(853): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
07-26 15:24:51.798: E/AndroidRuntime(853): FATAL EXCEPTION: main
07-26 15:24:51.798: E/AndroidRuntime(853): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.phonegaphotshot.QuizTime/com.phonegaphotshot.QuizTime.QuizTime}: java.lang.ClassNotFoundException: com.phonegaphotshot.QuizTime.QuizTime
07-26 15:24:51.798: E/AndroidRuntime(853): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
07-26 15:24:51.798: E/AndroidRuntime(853): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
07-26 15:24:51.798: E/AndroidRuntime(853): at android.app.ActivityThread.access$600(ActivityThread.java:130)
07-26 15:24:51.798: E/AndroidRuntime(853): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
07-26 15:24:51.798: E/AndroidRuntime(853): at android.os.Handler.dispatchMessage(Handler.java:99)
07-26 15:24:51.798: E/AndroidRuntime(853): at android.os.Looper.loop(Looper.java:137)
07-26 15:24:51.798: E/AndroidRuntime(853): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-26 15:24:51.798: E/AndroidRuntime(853): at java.lang.reflect.Method.invokeNative(Native Method)
07-26 15:24:51.798: E/AndroidRuntime(853): at java.lang.reflect.Method.invoke(Method.java:511)
07-26 15:24:51.798: E/AndroidRuntime(853): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-26 15:24:51.798: E/AndroidRuntime(853): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-26 15:24:51.798: E/AndroidRuntime(853): at dalvik.system.NativeStart.main(Native Method)
07-26 15:24:51.798: E/AndroidRuntime(853): Caused by: java.lang.ClassNotFoundException: com.phonegaphotshot.QuizTime.QuizTime
07-26 15:24:51.798: E/AndroidRuntime(853): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
07-26 15:24:51.798: E/AndroidRuntime(853): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-26 15:24:51.798: E/AndroidRuntime(853): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-26 15:24:51.798: E/AndroidRuntime(853): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
07-26 15:24:51.798: E/AndroidRuntime(853): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
07-26 15:24:51.798: E/AndroidRuntime(853): ... 11 more
Thanks for any help
Solved it! If someone having similar problem, just do this step by step:
Right click on Cordovaxxx.jar -> Configure Build Path in Tab Order and Export and make sure these ones are selected:
1. Android (in my case was Adnroid 4.1.2)
2. Android Dependencies
3. Cordova....
4. ..../src
5. ..../gen