Android 带有选项卡的活动在调试中工作,但在发布时不工作
我正在使用一个带有3个选项卡的活动,这在调试中非常有效,但是当我发布应用程序并生成签名的APK时,我的应用程序正在崩溃 我的布局Android 带有选项卡的活动在调试中工作,但在发布时不工作,android,layout,release,Android,Layout,Release,我正在使用一个带有3个选项卡的活动,这在调试中非常有效,但是当我发布应用程序并生成签名的APK时,我的应用程序正在崩溃 我的布局 <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
app:layout_scrollFlags="enterAlways"
app:navigationIcon="@drawable/ic_launcher"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMode="fixed" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
请帮忙,谢谢。
我不明白为什么它在开发(调试)中工作,但在生产(发布生成的APK)中不工作
已编辑的渐变(不工作)
最后我发现了错误。
我尝试在build.gradle set minifyEnabled false中禁用ProGuard生成APK,如下所示:
buildTypes {
release {
minifyEnabled false
}
}
我生成APK并在minifyEnabled为false时完美运行,但当minifyEnabled为true时,我的应用程序失败
见此帖:
我的解决方案设置为启用minifyEnabled true:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
并在proguard-project.txt中添加一行
-keep class org.xmlpull.v1.** { *; }
请尝试删除此
compile'com.android.support:support-v4:27.0.2'
…以及您的buildToolVersion
。?我的buildToolVersion android{compileSdkVersion 27 buildToolsVersion'27.0.2'useLibrary'org.apache.http.legacy'我正在尝试删除“compile'com.android.support:support-v4:27.0.2''但不起作用我不确定27.0.2
是否是一个稳定的版本……尝试降级buildToolsVersion“26.0.1”
,并编译'com.android.support:appcompat-v7:26.0.1'
——只是一个建议,尝试使用27.0.2,但不起作用
buildTypes {
release {
minifyEnabled false
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
-keep class org.xmlpull.v1.** { *; }