I am building my first app in android studio but my app crash when I try to open it. I am very new to this and I don't even know what I can show you to solve my problem.
What should I do to solve this problem?
This is what i get from logcat:
--------- beginning of crash
09-06 06:45:25.516 4182-4182/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.questionnaireapplication, PID: 4182
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.questionnaireapplication/com.example.android.questionnaireapplication.QuestionnaireActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.content.res.Resources.getText(Resources.java:331)
at android.widget.TextView.setText(TextView.java:4554)
at com.example.android.questionnaireapplication.QuestionnaireActivity.mettreÀJourQuestion(QuestionnaireActivity.java:38)
at com.example.android.questionnaireapplication.QuestionnaireActivity.onCreate(QuestionnaireActivity.java:49)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Below portion of stacktrace should be useful for you as it says that you have a problem on line 38 in QuestionnaireActivity.java which is actually a resource not found exception, i-e string resource you are using to set text in your text view is not a valid resource.
Caused by: android.content.res.Resources$NotFoundException: String
resource ID #0x0 at
android.content.res.Resources.getText(Resources.java:331) at
android.widget.TextView.setText(TextView.java:4554) at
com.example.android.questionnaireapplication.QuestionnaireActivity.mettreÀJourQuestion(QuestionnaireActivity.java:38)
at
Related
I get the next message from logcat afyter trying to run my app in andorid studio:
5545-5545/com.example.reyesdelafter E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.reyesdelafter, PID: 5545
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.reyesdelafter/com.example.reyesdelafter.MainActivity}: java.lang.InstantiationException: java.lang.Class cannot be instantiated
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2567)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.InstantiationException: java.lang.Class cannot be instantiated
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2557)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Also y get the message: "E/art: Failed sending reply to debugger: Broken pipe" before that, my code is exactly the same as in the beginning (and it runned well in the emulator, but I do some tries to change the icons of bottom nav view, and some other things but I get back everything to normality (or so I thought ) and it does not run properly. What is the possible problem ? I alredy tried to uprgrade SDK tools, and make sure my Manifest.xml includes my main activity.
The app has just the splash screen and login with Firebase alredy well done and it runned well before that. Thanks
Can't load a layout, activity fails on: setContentView
the "missing" resource is the activity layout itself found under layout folder
Activity extends FragmentActivity
the device: HTC M9 running marshmallow
stack trace:
Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{MyActivty}:
android.content.res.Resources$NotFoundException: File Share with %s from xml type layout resource ID #0x7f0a001d
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2484)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: android.content.res.Resources$NotFoundException: File Share with %s from xml type layout resource ID #0x7f0a001d
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2836)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2791)
at android.content.res.Resources.getLayout(Resources.java:1173)
at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:411)
at android.app.Activity.setContentView(Activity.java:2177)
at packageName.MyActivty.onCreate(MyActivty.java:43)
at android.app.Activity.performCreate(Activity.java:6248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: java.io.FileNotFoundException: Share with %s
at android.content.res.AssetManager.openXmlAssetNative(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:508)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2818)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2791)
at android.content.res.Resources.getLayout(Resources.java:1173)
at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:411)
at android.app.Activity.setContentView(Activity.java:2177)
at packageName.MyActivity.onCreate(MyActivty.java:43)
at android.app.Activity.performCreate(Activity.java:6248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
12-24 17:43:16.037 10054-10054/com.deepinstinct.android.dev.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.deepinstinct.android.dev.debug, PID: 10054
java.lang.RuntimeException: Unable to start activity ComponentInfo{packageName/packageName.MyActivity}:
android.content.res.Resources$NotFoundException: File Share with %s from xml type layout resource ID #0x7f0a001d
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2484)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: android.content.res.Resources$NotFoundException: File Share with %s from xml type layout resource ID #0x7f0a001d
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2836)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2791)
at android.content.res.Resources.getLayout(Resources.java:1173)
at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:411)
at android.app.Activity.setContentView(Activity.java:2177)
at packageName.MyActivity.onCreate(MyActivity.java:43)
at android.app.Activity.performCreate(Activity.java:6248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: java.io.FileNotFoundException: Share with %s
at android.content.res.AssetManager.openXmlAssetNative(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:508)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2818)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2791)
at android.content.res.Resources.getLayout(Resources.java:1173)
at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:411)
at android.app.Activity.setContentView(Activity.java:2177)
at packageName.MyActivity.onCreate(MyActivity.java:43)
at android.app.Activity.performCreate(Activity.java:6248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
I have never seen this error: File Share with %s from xml type layout resource
how can i fix this?
solved it:
I had an android library loaded to my project by reflection. the specified resource in the stack trace: 0x7f0a001d (my layout id) was a resource id of an appcompat component in the loaded library and the resources conflicted.
brute force solution:
create a unique layout id for my layout that doesn't conflict with the loaded library's one (by copy-pasting the original layout). obviously not the best solution
actual solution that worked for me:
the loaded library is all code and there is no native android functionality, so I have removed the appcompat v7 support library from the .gradle, making the conflicting resource to disappear
I can't seem to find whats wrong with my application...
Here is the logcat:
11-05 16:37:30.030 7867-7867/com.capstone.miguel.studentassistant E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.capstone.miguel.studentassistant, PID: 7867
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.capstone.miguel.studentassistant/com.capstone.miguel.studentassistant.user_sign.LoginActivity}: java.lang.ClassCastException: android.support.design.widget.TextInputEditText cannot be cast to android.support.design.widget.TextInputLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassCastException: android.support.design.widget.TextInputEditText cannot be cast to android.support.design.widget.TextInputLayout
at com.capstone.miguel.studentassistant.user_sign.LoginActivity.onCreate(LoginActivity.java:34)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Any idea why the application crashes?
It looks like you have wrong casting: java.lang.ClassCastException: android.support.design.widget.TextInputEditText cannot be cast to android.support.design.widget.TextInputLayout
Check if you use the same types in xml and in your code, probably they are different.
This line is the problem
Caused by: java.lang.ClassCastException: android.support.design.widget.TextInputEditText cannot be cast to android.support.design.widget.TextInputLayout
Check the declared types match those in the layout file
private TextInputEditText inputEmail, inputPass;
inputEmail = (TextInputEditText) findViewById(R.id.input_log_email);
inputPass = (TextInputEditText) findViewById(R.id.input_log_pass);
I am trying to use the Linphone library for Android. I have installed all the libraries as specified and when I am trying to run the project, I am getting the below error.
Process: org.linphone, PID: 13440
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.linphone/org.linphone.LinphoneLauncherActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f0a003b type #0x5 is not valid
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f0a003b type #0x5 is not valid
at android.content.res.Resources.getBoolean(Resources.java:999)
at org.linphone.LinphoneLauncherActivity.onCreate(LinphoneLauncherActivity.java:50)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Please let me know how can I resolve this as my work is stuck because of this.
Thanks in advance !!.
Regarding this ans:
Android Resources$NotFoundException: Resource ID #0x7f030027
You can check your R file for Resources$NotFoundException: Resource ID #0x7f030027. It'll tell you which resource was creating problem. As an alternative sollution I think you might have setText or any content just an int.And as you know here compiler will look for corresponding resource value. So, just concat an empty string there as ""
I am attempting to use a custom font in an Android app. I placed my font files under /app/src/main/assets/fonts, and I reference them with
Typeface.createFromAsset(getApplicationContext().getAssets(),
"fonts/magorian_font.ttf")
When I run my app, I get the error:
04-23 16:14:40.017 13342-13342/com.pottermore.mandrake.pottermoreapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.pottermore.mandrake.pottermoreapp, PID: 13342
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pottermore.mandrake.pottermoreapp/com.pottermore.mandrake.pottermoreapp.ActivityHome}: java.lang.RuntimeException: Font asset not found magorian_font.ttf
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.RuntimeException: Font asset not found magorian_font.ttf
at android.graphics.Typeface.createFromAsset(Typeface.java:206)
at com.pottermore.mandrake.pottermoreapp.ActivityHome.onCreate(ActivityHome.java:34)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
What am I doing wrong?
add assets folder in this path : src/main/assets/font
and use this code :
Typeface typrface=Typeface.createFromAsset(getAssets(),"font/iranian_sans");
Text.setTypeface(typrface);
Update
ِDont Forget , you must copy ttf format of font in font folder
It should be look like this when you want to give a TextView a different font :)
private TextView yourtext;
yourtext= (TextView) findViewById(R.id.the_id_of_the_textview);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/magorian_font.ttf");
yourtext.setTypeface(tf);