因此,我的应用程序在虚拟设备上运行时可以完美运行。当我尝试构建签名的apk时,出现以下错误:
//define the incrementing function
incrementer = function(property) {
value = mixpanel.get_property(property);
update = {}
//Ensure that 'value' has a type = number
if(value && typeof(value) == 'number') {
update[property] = value +1;
}
else {
update[property] = 1
}
mixpanel.register(update);
};
因此我将其添加到了我的proguard文件中:
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
现在apk可以成功构建,但是在我启动应用程序后,它因该错误而崩溃。当我的应用在虚拟设备上运行正常时,为什么会发生这种情况?
即使阅读其他答案,我似乎也找不到问题。这是我的xml代码:
-dontwarn android.support.v4.**
Logcat:
<?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>
答案 0 :(得分:1)
我想当您将minifyEnabled设置为false时,它将起作用。如果是这样,似乎您的proguard存在问题。 尝试添加此行:
-keep class android.support.v7.widget.** { *; }
答案 1 :(得分:0)
一切正常:
<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"
/>
问题在这里:
android:padding="5sp"
Only you just need to change this thing android:padding="5dp"
答案 2 :(得分:0)
我收到这些警告,并将这些行添加到我的proguard-rules.pro文件中:
-dontwarn androidx.**
-keep class androidx.** { *; }
-keep interface androidx.** { *; }