5

My app have a problem with some devices (namely Asus Zenfone 5 (Intel based processor)). It's keep forced close when opening it. This is the log from the devices:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.coolappz.FitPartners/com.coolappz.FitPartners.ui.MainActivity}: android.view.InflateException: Binary XML file line #42: Error inflating class com.coolappz.FitPartners.ui.custom.CustomFontEditText
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2320)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2380)
 at android.app.ActivityThread.access$800(ActivityThread.java:151)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1285)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:135)
 at android.app.ActivityThread.main(ActivityThread.java:5289)
 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:898)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
Caused by: android.view.InflateException: Binary XML file line #42: Error inflating class com.coolappz.FitPartners.ui.custom.CustomFontEditText
 at android.view.LayoutInflater.createView(LayoutInflater.java:633)
 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
 at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
 at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
 at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
 at com.coolappz.FitPartners.ui.MainActivity.onCreate(MainActivity.java:165)
 at android.app.Activity.performCreate(Activity.java:6018)
 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2273)
 ... 10 more
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:607)
 ... 22 more
Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 96
 at android.content.res.TypedArray.getColor(TypedArray.java:401)
 at android.widget.TextView.<init>(TextView.java:717)
 at android.widget.EditText.<init>(EditText.java:65)
 at android.widget.EditText.<init>(EditText.java:61)
 at android.widget.EditText.<init>(EditText.java:57)
 at com.coolappz.FitPartners.ui.custom.CustomFontEditText.<init>(CustomFontEditText.java:18)
 ... 25 more

The problem is, it's only error on that devices. I've tried the app in emulators (ARM based and x86 based) and other devices, and it's work fine.

Did anyone have same problem? I use android studio with gradle 2.2.0.

This is the customFontEditText class, and I forgot to mention, when I change the CustomFontEditText to normal EditText, it's still forced close

import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.EditText;

/**
 * Created by harto on 4/22/2016.
 */
public class CustomFontEditText extends EditText {
    public CustomFontEditText(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }

    public CustomFontEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public CustomFontEditText(Context context) {
        super(context);
        init();
    }

    private void init() {
        if (!isInEditMode()) {
            Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "fonts/SourceSansPro-Regular.otf");
            setTypeface(tf);
        }
    }
}

I use gradle v2.1.0 when I first build this and it's forced close when I first build it

  • Please add the code of your custom edittext class. – Sudip Podder Oct 03 '16 at 09:45
  • Sorry for the late reply. I already edited the question with some additional information and the edittext class. And I already tried changing the custom edittext with normal edittext but to no avail. – Tommy Hart'no Oct 10 '16 at 16:53
  • Can you add your whole activity code where you're setting/initializing the edittext view? – Sudip Podder Oct 10 '16 at 19:33
  • Well, it's on the MainActivity and I used Butterknife to initialize so it's just @Bind(the id) CustomFontEditText variableName and then onCreate ButterKnife.bind(this); That's all – Tommy Hart'no Oct 11 '16 at 13:50
  • Interesting. I just came across this crash for an ASUS_Z00AD using Android v5.0. Same index number 96, same stack trace. No fix as of yet. – Richard Le Mesurier Nov 25 '16 at 08:02
  • Hey Tommy, did you find the solution? I'm having the some problem but no luck to find an answer. – AMarones Jul 01 '17 at 19:09
  • @AMarones Ah, sorry. I haven't found it yet. Though, now I haven't touch native android since I already change job – Tommy Hart'no Sep 04 '17 at 04:25

1 Answers1

0

Downgrading might worth a try:

dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'
}
Dinesh Saini
  • 335
  • 1
  • 12
  • I use gradle build 2.1.0 when I first build this app. I upgrade it to gradle 2.2.0 when I read that it could be a bug in the stackoverflow. Sorry, I forgot to mention it. – Tommy Hart'no Oct 03 '16 at 10:20