Unable to display EditText error in Kotlin code - android

I have switched my Android development over to Kotlin, but I am dealing with a crash that I can't figure out. I am used to, in Java, being able to display an error on an empty EditText:
if(mEmail.getText().toString().isEmpty()) {
mEmail.setError("Email cannot be blank.");
}
To the best of my knowledge, that could be translated to Kotlin as:
if(email.text.toString().isEmpty()) {
email.error = "Email cannot be blank."
}
However, that doesn't work, and I get the following stack trace:
Process: com.androidessence.capturethetag, PID: 4016
android.view.InflateException: Binary XML file line #17: Error inflating class TextView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.widget.Editor.showError(Editor.java:319)
at android.widget.Editor.setError(Editor.java:355)
at android.widget.TextView.setError(TextView.java:4648)
at android.widget.TextView.setError(TextView.java:4633)
at com.androidessence.capturethetag.activities.LoginActivity.validateInput(LoginActivity.kt:31)
at com.androidessence.capturethetag.activities.LoginActivity.access$validateInput(LoginActivity.kt:12)
at com.androidessence.capturethetag.activities.LoginActivity$onCreate$1.onClick(LoginActivity.kt:19)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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: java.lang.RuntimeException: Failed to resolve attribute at index 24
at android.content.res.TypedArray.getColor(TypedArray.java:401)
at android.widget.TextView.<init>(TextView.java:696)
at android.widget.TextView.<init>(TextView.java:632)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:60)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:56)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:92)
at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:938)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:992)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
at android.widget.Editor.showError(Editor.java:319) 
at android.widget.Editor.setError(Editor.java:355) 
at android.widget.TextView.setError(TextView.java:4648) 
at android.widget.TextView.setError(TextView.java:4633) 
at com.androidessence.capturethetag.activities.LoginActivity.validateInput(LoginActivity.kt:31) 
at com.androidessence.capturethetag.activities.LoginActivity.access$validateInput(LoginActivity.kt:12) 
at com.androidessence.capturethetag.activities.LoginActivity$onCreate$1.onClick(LoginActivity.kt:19) 
at android.view.View.performClick(View.java:4780) 
at android.view.View$PerformClick.run(View.java:19866) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
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) 
Any ideas why this is crashing in Kotlin?
EDIT
For more information, you can see my content_login.xml file here. I've used Gist to save space.
Also, I never call findViewById(); on my EditText because the Kotlin-Android Extension Plugin can do it, as mentioned here: https://kotlinlang.org/docs/tutorials/android-plugin.html
I have no doubts that it's referencing the right EditText, because logging showed me that it was able to determine the EditText was empty, but is unable to set the error attribute.

Related

ByteBuddy Android crashes at load(getClass().getClassLoader())

I have created "Hello World!" android application in the Android Studio which compiled and run successfully.
Next I have added "Hello World!" ByteBuddy code:
Class<?> dynamicType = new ByteBuddy()
.subclass(Object.class)
.method(ElementMatchers.named("toString"))
.intercept(FixedValue.value("Hello World!"))
.make()
.load(getClass().getClassLoader())
.getLoaded();
Next I have added dependency:
compile 'net.bytebuddy:byte-buddy-android:1.7.6'
The application crashed while executing
.load(getClass().getClassLoader())
line with the following logcat output:
10-12 11:47:59.977 30562-30562/com.example.bytebuddyandroid D/AndroidRuntime: Shutting down VM
--------- beginning of crash
10-12 11:47:59.979 30562-30562/com.example.bytebuddyandroid E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.bytebuddyandroid, PID: 30562
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.bytebuddyandroid/com.example.bytebuddyandroid.MainActivity}: java.lang.UnsupportedOperationException: Cannot define class using reflection
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: java.lang.UnsupportedOperationException: Cannot define class using reflection
at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$Unavailable.defineClass(ClassInjector.java:821)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection.inject(ClassInjector.java:185)
at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$InjectionDispatcher.load(ClassLoadingStrategy.java:187)
at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default.load(ClassLoadingStrategy.java:120)
at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:79)
at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:4456)
at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:4446)
at com.example.bytebuddyandroid.MainActivity.onCreate(MainActivity.java:22)
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) 
Caused by: java.lang.IllegalStateException: This JVM's version string does not seem to be valid: 0
at net.bytebuddy.ClassFileVersion$VersionLocator$ForLegacyVm.locate(ClassFileVersion.java:388)
at net.bytebuddy.ClassFileVersion.ofThisVm(ClassFileVersion.java:147)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$CreationAction.run(ClassInjector.java:301)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$CreationAction.run(ClassInjector.java:290)
at java.security.AccessController.doPrivileged(AccessController.java:45)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection.<clinit>(ClassInjector.java:70)
at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$InjectionDispatcher.load(ClassLoadingStrategy.java:184)
at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default.load(ClassLoadingStrategy.java:120) 
at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:79) 
at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:4456) 
at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:4446) 
at com.example.bytebuddyandroid.MainActivity.onCreate(MainActivity.java:22) 
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) 
--------- beginning of system
Why the
"java.lang.UnsupportedOperationException: Cannot define class using reflection"
exception is thrown? What to do to avoid this exception?
OK, I had to use other version of load() with the argument specifying ClassLoadingStrategy. So I have changed it to
.load(getClass().getClassLoader(), new AndroidClassLoadingStrategy.Wrapping(this.getDir("dexgen", Context.MODE_PRIVATE)))
and it works now!

After clicking in buttons My App has stopped

02-20 13:57:58.601 5952-5952/com.counter.milion.milioncounter E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.counter.milion.milioncounter, PID: 5952
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.counter.milion.milioncounter/com.counter.milion.milioncounter.Menu}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2702)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
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:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:640)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:435)
at android.app.Activity.setContentView(Activity.java:2267)
at com.counter.milion.milioncounter.Menu.onCreate(Menu.java:35)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767) 
at android.app.ActivityThread.access$900(ActivityThread.java:177) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:5951) 
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:1400) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:614)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:483) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:415) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:366) 
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:435) 
at android.app.Activity.setContentView(Activity.java:2267) 
at com.counter.milion.milioncounter.Menu.onCreate(Menu.java:35) 
at android.app.Activity.performCreate(Activity.java:6289) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767) 
at android.app.ActivityThread.access$900(ActivityThread.java:177) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:5951) 
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:1400) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) 
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 35389452 byte allocation with 16777216 free bytes and 32MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:726)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:547)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1014)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:3730)
at android.content.res.Resources.loadDrawable(Resources.java:3603)
at android.content.res.TypedArray.getDrawable(TypedArray.java:762)
at android.view.View.<init>(View.java:3970)
at android.view.ViewGroup.<init>(ViewGroup.java:507)
at android.widget.LinearLayout.<init>(LinearLayout.java:199)
at android.widget.LinearLayout.<init>(LinearLayout.java:195)
at android.widget.LinearLayout.<init>(LinearLayout.java:191)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
at android.view.LayoutInflater.createView(LayoutInflater.java:614) 
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:483) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:415) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:366) 
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:435) 
at android.app.Activity.setContentView(Activity.java:2267) 
at com.counter.milion.milioncounter.Menu.onCreate(Menu.java:35) 
at android.app.Activity.performCreate(Activity.java:6289) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767) 
at android.app.ActivityThread.access$900(ActivityThread.java:177) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:5951) 
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:1400) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) 
are you using android:onClick="yourfunction" feature?
If yes check that you declared the right activity in the top of your xml
tools:context="youractivity"
Then be sure to have the function implemented in your class:
public void yourclick(View v){...}
Reading your stack trace tells me three things:
Your activity couldn't load because it couldn't finish inflating the XML layout
Your XML layout couldn't finish inflating because it ran out of memory when trying to create a Bitmap
And finally, your answer:
Your XML layout is trying to load either too many images or images that are too big for the memory allocated to your application.
You can remedy this in lots of ways, but most simply:
Reduce the size of your images. (Normally this means resolution.)
Ensure you're only keeping the images you need in memory. (You might be loading images that are off the screen.)
Hope this helps.

Facebook Login Android keeps crashing

I have been constructing a Facebook login for my android app. For some reason it keeps on crashing. I have followed this tutorial to the letter, and copied whole parts of this guys code (besides the part for copying photos, I removed anything picasso related and the xml elements belonging to it. I have also removed the textview with the user name.):
https://www.youtube.com/watch?v=LPG7Rxj3u94
https://github.com/delaroy/AndroidFacebook/blob/master/app/src/main/java/com/tutorialsbuzz/androidfacebook/LoginFragment.java
I have already checked my manifest, my gradle.build files to ensure i have the right dependencies. I have checked my app ID at facebook, and have input the ssl key. Lastly I have indeed initialized the FacebookSDK before trying to inflate any xml in the loginactivity.
at the moment I don't know what the error is...
Here is my error message:
FATAL EXCEPTION: main
Process: com.example.riaan.dutchmanners, PID: 25681
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.riaan.dutchmanners/com.example.riaan.dutchmanners.LoginActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class com.facebook.login.widget.LoginButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
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:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class com.facebook.login.widget.LoginButton
at android.view.LayoutInflater.createView(LayoutInflater.java:640)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:933)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.riaan.dutchmanners.LoginActivity.onCreate(LoginActivity.java:26)
at android.app.Activity.performCreate(Activity.java:6221)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723) 
at android.app.ActivityThread.access$900(ActivityThread.java:172) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:5832) 
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:1399) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:614)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) 
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:933) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:511) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:415) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:366) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at com.example.riaan.dutchmanners.LoginActivity.onCreate(LoginActivity.java:26) 
at android.app.Activity.performCreate(Activity.java:6221) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723) 
at android.app.ActivityThread.access$900(ActivityThread.java:172) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:5832) 
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:1399) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 
Caused by: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.
at com.facebook.internal.Validate.sdkInitialized(Validate.java:145)
at com.facebook.AccessTokenTracker.<init>(AccessTokenTracker.java:55)
at com.facebook.login.widget.LoginButton$2.<init>(LoginButton.java:563)
at com.facebook.login.widget.LoginButton.configureButton(LoginButton.java:563)
at com.facebook.FacebookButtonBase.<init>(FacebookButtonBase.java:69)
at com.facebook.login.widget.LoginButton.<init>(LoginButton.java:201)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
at android.view.LayoutInflater.createView(LayoutInflater.java:614) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) 
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:933) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:511) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:415) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:366) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at com.example.riaan.dutchmanners.LoginActivity.onCreate(LoginActivity.java:26) 
at android.app.Activity.performCreate(Activity.java:6221) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723) 
at android.app.ActivityThread.access$900(ActivityThread.java:172) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:5832) 
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:1399) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 
If you need anything else besides this let me know!
Thank you for your help!

How to view the entire stack trace in Android Studio?

In Android Studio (and IntelliJ afaik) when there is an error, the stack trace seems to be limited to a certain number of lines. For example:
(I have posted the full stack trace below this explanation and example.)
**MANY MANY LINES BEFORE THIS**
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:631)
... 37
I am not sure what the 37 actually is, but I feel like these editors are cutting off the full stack trace. I say this, because in my code I can prove that a null pointer exception is causing the problem that starts the stack trace. I was lucky to find it this time but it seems to be ignoring the root of my problem for some reason.
Maybe it is because of the way Android works, but the null pointer exception occurs when I inflate a custom view, and the lines is telling me the error is on is not the root of the problem; the problem is in the constructor when the view is created.
Just to reiterate, I know what the problem is this time, but it is not the first time I have had this problem. It makes debugging extremely challenging.
Here is my full stack trace.
06-12 12:59:31.766 31807-31807/
E/AndroidRuntime: FATAL EXCEPTION: main
Process: , PID: 31807
android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class <unknown>
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5228)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4453)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4363)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900)
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1418)
at android.support.v7.widget.RecyclerView.access$400(RecyclerView.java:144)
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:3783)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920)
at android.view.Choreographer.doCallbacks(Choreographer.java:695)
at android.view.Choreographer.doFrame(Choreographer.java:628)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:657)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5228) 
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4453) 
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4363) 
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961) 
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370) 
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333) 
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562) 
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900) 
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1418) 
at android.support.v7.widget.RecyclerView.access$400(RecyclerView.java:144) 
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:3783) 
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920) 
at android.view.Choreographer.doCallbacks(Choreographer.java:695) 
at android.view.Choreographer.doFrame(Choreographer.java:628) 
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7224) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:631)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5228) 
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4453) 
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4363) 
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961) 
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370) 
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333) 
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562) 
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900) 
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1418) 
at android.support.v7.widget.RecyclerView.access$400(RecyclerView.java:144) 
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:3783) 
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920) 
at android.view.Choreographer.doCallbacks(Choreographer.java:695) 
at android.view.Choreographer.doFrame(Choreographer.java:628) 
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7224) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at com.subliroid.subliroidlib.customviews.InfoHeaderCard.init(InfoHeaderCard.java:47)
at com.subliroid.subliroidlib.customviews.InfoHeaderCard.<init>(InfoHeaderCard.java:23)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at android.view.LayoutInflater.createView(LayoutInflater.java:631) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5228) 
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4453) 
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4363) 
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961) 
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370) 
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333) 
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562) 
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900) 
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1418) 
at android.support.v7.widget.RecyclerView.access$400(RecyclerView.java:144) 
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:3783) 
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920) 
at android.view.Choreographer.doCallbacks(Choreographer.java:695) 
at android.view.Choreographer.doFrame(Choreographer.java:628) 
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7224) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class
at android.view.LayoutInflater.createView(LayoutInflater.java:657)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
at com.subliroid.subliroidlib.customviews.InfoHeaderCard.init(InfoHeaderCard.java:47) 
at com.subliroid.subliroidlib.customviews.InfoHeaderCard.<init>(InfoHeaderCard.java:23) 
at java.lang.reflect.Constructor.newInstance(Native Method) 
at android.view.LayoutInflater.createView(LayoutInflater.java:631) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5228) 
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4453) 
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4363) 
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961) 
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370) 
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333) 
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562) 
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900) 
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1418) 
at android.support.v7.widget.RecyclerView.access$400(RecyclerView.java:144) 
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:3783) 
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920) 
at android.view.Choreographer.doCallbacks(Choreographer.java:695) 
at android.view.Choreographer.doFrame(Choreographer.java:628) 
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7224) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:631)
... 37
Sorry for the indentation, but the copy and paste is not perfect coming from the editor is not perfect, and I wanted to omit a few lines because I greatly value my work :). All of the lines I cut have different indentation on the line after, and the lines removed all referred to the same class.
You can use ACRA to see the full stack trace

Unable to start activity ComponentInfo: android.content.res.Resources$NotFoundException

I have a main app which has a dependency to a android libary. I have an activity in android library. I verified the layout file and activity class. Activity class is make a call to right layout file. But I don't know for some reason, I am not able to call the library's activity from main app. Dependency wise, I verified everything. I have another library as well which main app depend on but that library works gr8 without any issues. For this library, I keep getting,
java.lang.RuntimeException: Unable to start activity ComponentInfo{}: android.content.res.Resources$NotFoundException: Resource ID #0x7f03001a
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2389)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2451)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5499)
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:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:737)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f03001a
at android.content.res.Resources.getValue(Resources.java:1266)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2656)
at android.content.res.Resources.getLayout(Resources.java:1082)
at android.view.LayoutInflater.inflate(LayoutInflater.java:412)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at XXXXXXXXXXXX.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1117)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2342)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2451) 
at android.app.ActivityThread.access$800(ActivityThread.java:151) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5499) 
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:942) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:737) 
I imported package specific R file in activity and issue gone. Thanks for everyone for your time.

Categories

Resources