0

So my application works perfectly while running it on the virtual device. When I tried to build a signed apk I got these errors like these:

Warning: androidx.media.AudioAttributesCompatParcelizer: can't find referenced field 'android.support.v4.media.AudioAttributesImpl mImpl' in program class android.support.v4.media.AudioAttributesCompat
Warning: androidx.media.AudioAttributesImplApi21Parcelizer: can't find referenced field 'android.media.AudioAttributes mAudioAttributes' in program class android.support.v4.media.AudioAttributesImplApi21
Warning: androidx.media.AudioAttributesImplApi21Parcelizer: can't find referenced field 'int mLegacyStreamType' in program class android.support.v4.media.AudioAttributesImplApi21
Warning: androidx.media.AudioAttributesImplBaseParcelizer: can't find referenced field 'int mUsage' in program class android.support.v4.media.AudioAttributesImplBase
Warning: androidx.media.AudioAttributesImplBaseParcelizer: can't find referenced field 'int mFlags' in program class android.support.v4.media.AudioAttributesImplBase
Warning: androidx.media.AudioAttributesImplBaseParcelizer: can't find referenced field 'int mLegacyStream' in program class android.support.v4.media.AudioAttributesImplBase

So I added this to my proguard file:

-dontwarn android.support.v4.**

And now the apk is building successfully but after I start my application it crashes with this error. Why does this happen when my app works fine on running on virtual device?

I can't seem to find the problem even after reading other answers. Here is my xml code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/azureColorPrimary"
    android:minHeight="?attr/actionBarSize">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        android:background="@color/azureColorPrimary">


    </LinearLayout>

</android.support.v7.widget.Toolbar>

<TextView
    android:id="@+id/title_1"
    android:layout_width="277dp"
    android:layout_height="50dp"
    android:padding="5sp"
    android:paddingStart="10sp"
    android:text="@string/title"
    android:textColor="#ffffff"

    android:textSize="25sp"
    tools:ignore="RtlSymmetry" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true">

    <ListView
        android:id="@+id/record_list"
        android:layout_width="match_parent"
        android:layout_height="567dp"
        android:layout_marginTop="50sp"
        android:paddingTop="10sp"
        android:scrollbars="vertical" />

</LinearLayout>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"

    android:layout_marginBottom="12dp"
    android:clickable="true"
    android:focusable="true"
    app:srcCompat="@drawable/ic_add"
    app:backgroundTint="@color/azureColorPrimary"
    tools:layout_editor_absoluteX="310dp"
    tools:layout_editor_absoluteY="494dp" />

<ImageView
    android:id="@+id/guide"
    android:layout_width="wrap_content"
    android:layout_height="22dp"
    android:layout_alignParentTop="true"
    android:layout_alignParentEnd="true"
    android:layout_marginTop="17dp"
    android:layout_marginEnd="30dp"
    app:srcCompat="@android:drawable/ic_dialog_info" />

<ImageView
    android:id="@+id/show_tutorial"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/guide"
    android:layout_alignParentEnd="true"
    android:layout_marginEnd="73dp"
    app:srcCompat="@drawable/ic_tut" />


</RelativeLayout>

Logcat:

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.arahasya.sap.forwardkey/com.arahasya.sap.forwardkey.MainActivity}: android.view.InflateException: Binary XML file line #27: Binary XML file line #27: Error inflating class TextView
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2984)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
    at android.app.ActivityThread.-wrap14(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6776)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
 Caused by: android.view.InflateException: Binary XML file line #27: Binary XML file line #27: Error inflating class TextView
 Caused by: android.view.InflateException: Binary XML file line #27: Error inflating class TextView
 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.support.v7.widget.bk.d()' on a null object reference
    at android.support.v7.widget.bm.onTextChanged(Unknown Source)
    at android.widget.TextView.setText(TextView.java:5133)
    at android.widget.TextView.setText(TextView.java:4954)
    at android.widget.TextView.<init>(TextView.java:1825)
    at android.widget.TextView.<init>(TextView.java:1035)
    at android.support.v7.widget.bm.<init>(Unknown Source)
    at android.support.v7.widget.bm.<init>(Unknown Source)
    at android.support.v7.app.AppCompatViewInflater.a(Unknown Source)
    at android.support.v7.app.r.a(Unknown Source)
    at android.support.v7.app.r.onCreateView(Unknown Source)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:525)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:378)
    at android.support.v7.app.r.b(Unknown Source)
    at android.support.v7.app.o.setContentView(Unknown Source)
    at com.arahasya.sap.forwardkey.MainActivity.onCreate(Unknown Source)
    at android.app.Activity.performCreate(Activity.java:6955)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
    at android.app.ActivityThread.-wrap14(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6776)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
2018-10-24 01:25:52.356 4679-24128/? E/NetworkScheduler: Invalid component specified.
2
  • Open your gradle.properties and add android.enableAapt2=false Commented Oct 23, 2018 at 20:27
  • Still app crashing with same error Commented Oct 24, 2018 at 3:59

3 Answers 3

1

I suppose that when you set minifyEnabled to false it will work. If it's the case, It seems that you have an issue with proguard. Try to add this line :

-keep class android.support.v7.widget.** { *; }
Sign up to request clarification or add additional context in comments.

2 Comments

yes minifyEnabled to false did the work. I did this before your comment but as you are right I will mark it as accepted.
Still have the warnings with -keep class android.support.v7.widget.** { *; }
0

All things working fine :

<TextView
  android:id="@+id/title_1"
  android:layout_width="277dp"
  android:layout_height="50dp"
  android:padding="5sp"
  android:paddingStart="10sp"
  android:text="@string/title"
  android:textColor="#ffffff"
  android:textSize="25sp"
  tools:ignore="RtlSymmetry"
 />

Problem is here :

  android:padding="5sp"
  Only you just need to change this thing android:padding="5dp"

Comments

0

I had these warnings and I added these lines to my proguard-rules.pro file :

-dontwarn androidx.**
-keep class androidx.** { *; }
-keep interface androidx.** { *; }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.