gpt4 book ai didi

Android Studio 1.0.2 "minifyEnabled true"使签名版本 apk 崩溃

转载 作者:IT老高 更新时间:2023-10-28 23:36:42 25 4
gpt4 key购买 nike

升级到 Android Studio 1.0.2 会导致签名的发布 apk 文件在应用程序启动后立即崩溃(调试 apk 工作正常)。

将 **minifiyEnabled 设置为 false ** 可修复签名发布 apk 文件中的崩溃问题。

build.gradle(Module:app) 文件的 buildTypes 部分如下所示

   buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}

getDefaultProguardFile 似乎是嫌疑犯,因为 android studio 显示下划线 getDefaultProguardFile 并且当将鼠标悬停在它上面时显示警告 Cannot resolve symbol getDefaultProguardFile.

以下是build.gradle(project)文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}

allprojects {
repositories {
mavenCentral()
}
}

以下是build.gradle(app)文件内容

apply plugin: 'android'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
minSdkVersion 9
targetSdkVersion 17
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}

dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:6.1.+'

}

更新 1:

There are some warning in the gradle build
Executing tasks: [:app:assembleRelease]

Configuration on demand is an incubating feature.
:app:preBuild
:app:preReleaseBuild
:app:checkReleaseManifest
:app:preDebugBuild
:app:prepareComAndroidSupportAppcompatV72103Library
:app:prepareComAndroidSupportSupportV42103Library
:app:prepareComGoogleAndroidGmsPlayServices6171Library
:app:prepareReleaseDependencies
:app:compileReleaseAidl
:app:compileReleaseRenderscript
:app:generateReleaseBuildConfig
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets
:app:generateReleaseResValues
:app:generateReleaseResources
:app:mergeReleaseResources
/home/hhk/src/android_project/govinda_suprabhatam_alarm/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/drawable-xhdpi/abc_ab_share_pack_holo_light.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
/home/hhk/src/android_project/govinda_suprabhatam_alarm/app/src/main/res/drawable/bell_48_48.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
/home/hhk/src/android_project/govinda_suprabhatam_alarm/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/drawable-hdpi/abc_spinner_mtrl_am_alpha.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
/home/hhk/src/android_project/govinda_suprabhatam_alarm/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/drawable-hdpi/abc_ab_share_pack_holo_dark.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
/home/hhk/src/android_project/govinda_suprabhatam_alarm/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/drawable-hdpi/abc_ab_share_pack_holo_light.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
/home/hhk/src/android_project/govinda_suprabhatam_alarm/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/drawable-xhdpi/abc_ab_share_pack_holo_dark.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
/home/hhk/src/android_project/govinda_suprabhatam_alarm/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/drawable-mdpi/abc_ab_share_pack_holo_dark.9.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited

:app:processReleaseManifest
:app:processReleaseResources
:app:generateReleaseSources
:app:compileReleaseJava
Note: /home/hhk/src/android_project/govinda_suprabhatam_alarm/app/src/main/java/com/suprabhatam/alarm/MainActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

:app:lintVitalRelease
:app:compileReleaseNdk
:app:preDexRelease
:app:dexRelease
:app:processReleaseJavaRes UP-TO-DATE
:app:validateExternalOverrideSigning
:app:packageRelease
:app:zipalignRelease
:app:assembleRelease

BUILD SUCCESSFUL

Total time: 41.768 secs

adb logcat的相关错误信息如下

D/dalvikvm(  326): threadid=1: interp stack at 0x41c23000
E/AndroidRuntime(32767): FATAL EXCEPTION: main
E/AndroidRuntime(32767): java.lang.NullPointerException
E/AndroidRuntime(32767): at com.suprabhatam.alarm.MainActivity.onCreateOptionsMenu(Unknown Source)
E/AndroidRuntime(32767): at android.app.Activity.onCreatePanelMenu(Activity.java:2508)
E/AndroidRuntime(32767): at android.support.v4.app.o.onCreatePanelMenu(Unknown Source)
E/AndroidRuntime(32767): at android.support.v7.app.e.a(Unknown Source)
E/AndroidRuntime(32767): at android.support.v7.app.g.a(Unknown Source)
E/AndroidRuntime(32767): at android.support.v7.app.ActionBarActivityDelegateBase.b(Unknown Source)
E/AndroidRuntime(32767): at android.support.v7.app.ActionBarActivityDelegateBase.d(Unknown Source)
E/AndroidRuntime(32767): at android.support.v7.app.ActionBarActivityDelegateBase.a(Unknown Source)
E/AndroidRuntime(32767): at android.support.v7.app.h.run(Unknown Source)
E/AndroidRuntime(32767): at android.os.Handler.handleCallback(Handler.java:800)
E/AndroidRuntime(32767): at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime(32767): at android.os.Looper.loop(Looper.java:194)
E/AndroidRuntime(32767): at android.app.ActivityThread.main(ActivityThread.java:5391)
E/AndroidRuntime(32767): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(32767): at java.lang.reflect.Method.invoke(Method.java:525)
E/AndroidRuntime(32767): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
E/AndroidRuntime(32767): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
E/AndroidRuntime(32767): at dalvik.system.NativeStart.main(Native Method)
V/Provider/Settings( 554): from settings cache , name = dropbox:data_app_crash , value = null
D/dalvikvm( 554): create interp thread : stack size=128KB

....
....
D/PowerManagerService( 554): updateScreenStateLocked: mDisplayReady=true, newScreenState=2, mWakefulness=1, mWakeLockSummary=0x1, mUserActivitySummary=0x1, mBootCompleted=true
D/PowerManagerService( 554): handleSandman: canDream=true, mWakefulness=Awake
V/Provider/Settings( 554): from settings cache , name = anr_show_background , value = null
V/ActivityManager( 554): Broadcast: Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } ordered=false userid=0 callerApp=ProcessRecord{41c6a9c0 554:system/1000}
D/AES ( 554): ExceptionLog: notify aed
D/AES ( 554): process : com.suprabhatam.alarm
D/AES ( 554): module : com.suprabhatam.alarm v1 (1.0)
D/AES ( 554):
D/AES ( 554): cause : data_app_crash
D/AES ( 554): pid : 32767
D/AEE/LIBAEE( 554): shell: raise_exp(2, 32767, -1361051648, com.suprabhatam.alarm, 0x0x61e05008, 0x0x0)

....
....
D/AEE/AED ( 122): p 4 poll events 1 revents 0
D/AEE/AED ( 122): not know revents:0
D/dalvikvm(32767): DexOpt: --- END 'ads714289260.jar' (success) ---
D/dalvikvm(32767): DEX prep '/data/data/com.suprabhatam.alarm/cache/ads714289260.jar': unzip in 1ms, rewrite 87ms
V/WindowManager( 554): Changing focus from Window{421f4cd0 u0 com.suprabhatam.alarm/com.suprabhatam.alarm.MainActivity} to Window{427208a0 u0 Application Error: com.suprabhatam.alarm}
I/WindowManager( 554): Gaining focus: Window{427208a0 u0 Application Error: com.suprabhatam.alarm}
D/dalvikvm(32767): create interp thread : stack size=128KB

....
....
I/BufferQueue( 129): [unnamed-129-849](this:0x4153dc80,api:0) setSynchronousMode: enabled=1
I/BufferQueue( 129): [unnamed-129-849](this:0x4153dc80,api:0) setDefaultBufferSize: w=1, h=1
I/BufferQueue( 129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:0) setConsumerName: Application Error: com.suprabhatam.alarm
D/KeyguardViewMediator( 554): setHidden false
D/KeyguardUpdateMonitor( 554): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 554): handleKeyguardVisibilityChanged(1)
D/KeyguardViewMediator( 554): handleMessage enter msg name=SET_HIDDEN
D/KeyguardViewMediator( 554): handleMessage exit msg name=SET_HIDDEN
I/BufferQueue( 129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:0) setDefaultBufferSize: w=480, h=220
I/BufferQueue( 129): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41542040,api:0) consumerDisconnect
I/BufferQueue( 129): [com.lenovo.launcher/com.lenovo.launcher2.Launcher](this:0x41542040,api:0) ~BufferQueue
I/GraphicBuffer( 129): free buffer (w:480 h:854 f:1) handle(0x43662f78)
D/KeyguardViewMediator( 554): setHidden false
D/KeyguardUpdateMonitor( 554): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 554): handleKeyguardVisibilityChanged(1)
D/KeyguardViewMediator( 554): handleMessage enter msg name=SET_HIDDEN
D/KeyguardViewMediator( 554): handleMessage exit msg name=SET_HIDDEN
I/BufferQueue( 129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:0) connect: api=2
I/BufferQueue( 129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:2) setSynchronousMode: enabled=1
I/BufferQueue( 129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:2) new GraphicBuffer needed
D/BufferQueue( 129): [OLD] gb:NULL
I/GraphicBuffer( 129): allocate buffer (w:480 h:220 f:1) handle(0x414f7050) err(0)
I/BufferQueue( 129): [NEW] gb=0x41523678, handle=0x414f7050, w=480, h=220, s=480, fmt=1
D/GraphicBuffer( 554): create handle(0x636639d0) (w:480, h:220, f:1)
D/KeyguardViewMediator( 554): setHidden false
D/KeyguardUpdateMonitor( 554): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 554): handleKeyguardVisibilityChanged(1)
D/KeyguardViewMediator( 554): handleMessage enter msg name=SET_HIDDEN
D/KeyguardViewMediator( 554): handleMessage exit msg name=SET_HIDDEN
I/SurfaceTexture( 129): [Application Error: com.suprabhatam.alarm](this:0x41521b80,api:2) [void* android::SurfaceTexture::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&)]

....
....
V/webcore (24597): webkitDraw NEW_PICTURE_MSG_ID
V/webview (24597): NEW_PICTURE_MSG_ID
D/webkit/webview(24597): setNewPicture::start
D/webkit/webview(24597): setNewPicture::processing 111
D/KeyguardViewMediator( 554): setHidden false
D/KeyguardUpdateMonitor( 554): sendKeyguardVisibilityChanged(true)
D/KeyguardUpdateMonitor( 554): handleKeyguardVisibilityChanged(1)
D/KeyguardViewMediator( 554): handleMessage enter msg name=SET_HIDDEN
D/KeyguardViewMediator( 554): handleMessage exit msg name=SET_HIDDEN
W/ActivityManager( 554): Activity pause timeout for ActivityRecord{41c6b7a8 u0 com.suprabhatam.alarm/.MainActivity}
V/ActivityManager( 554): Enqueueing pending finish: ActivityRecord{41c6b7a8 u0 com.suprabhatam.alarm/.MainActivity}

....
....
I/alpha ( 804): AppContentView == draw +++1.0
I/BufferQueue( 129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:2) new GraphicBuffer needed
D/BufferQueue( 129): [OLD] gb:NULL
I/GraphicBuffer( 129): allocate buffer (w:480 h:220 f:1) handle(0x41543e88) err(0)
I/BufferQueue( 129): [NEW] gb=0x43661a98, handle=0x41543e88, w=480, h=220, s=480, fmt=1
D/GraphicBuffer( 554): create handle(0x65525ad8) (w:480, h:220, f:1)
I/alpha ( 804): AppContentView == draw +++1.0
I/zdx2 ( 804): ----------------Workspace.updateChildrenLayersEnabled----true
I/zdx2 ( 804): ----------------Workspace.updateChildrenLayersEnabled----true
I/SurfaceTexture( 129): [Application Error: com.suprabhatam.alarm](this:0x41521b80,api:2) [void* android::SurfaceTexture::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&)]
D/SurfaceTexture( 129): GraphicBuffer: gb=0x43661a98 handle=0x41543e88
D/SurfaceTexture( 129): EGLImage: dpy=0x1, img=0x1000000b
I/alpha ( 804): AppContentView == draw +++1.0
D/MsensorDaemon( 333): Msensor deamon statr!!!!!!!!!!!!
D/MsensorDaemon( 333): open demon attr err = No such file or directory
I/alpha ( 804): AppContentView == draw +++1.0
I/alpha ( 804): AppContentView == draw +++1.0

....
....
D/SignalClusterViewGemini( 647): apply(). mIsAirplaneMode is false
D/NetworkControllerGemini( 647): PhoneStateListener:onDataActivity, sim0 after.
I/BufferQueue( 129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:2) new GraphicBuffer needed
D/BufferQueue( 129): [OLD] gb:NULL
I/GraphicBuffer( 129): allocate buffer (w:480 h:220 f:1) handle(0x43661bf0) err(0)
I/BufferQueue( 129): [NEW] gb=0x41526478, handle=0x43661bf0, w=480, h=220, s=480, fmt=1
D/GraphicBuffer( 554): create handle(0x6294fd48) (w:480, h:220, f:1)
I/SurfaceTextureClient( 554): [STC::queueBuffer] (this:0x639270a0) fps:1.66, dur:1201.78, max:974.38, min:227.40
I/BufferQueue( 129): [Application Error: com.suprabhatam.alarm](this:0x4153dc80,api:2) [queue] fps:1.66, dur:1201.87, max:974.35, min:227.53
I/SurfaceTexture( 129): [Application Error: com.suprabhatam.alarm](this:0x41521b80,api:2) [void* android::SurfaceTexture::createImage(EGLDisplay, const android::sp<android::GraphicBuffer>&)]

MainActivity::onCreateOptionMenu方法定义为

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);

MenuItem item = (MenuItem) menu.findItem(R.id.action_share);
ShareActionProvider shareAction = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
Intent shareIntent = new Intent(Intent.ACTION_SEND)
.putExtra(Intent.EXTRA_TEXT, "text")
.setType("text/plain");

shareAction.setShareIntent(shareIntent);

return true;
}

最佳答案

将以下规则添加到您的 proguard-rules.pro 文件中。

-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class android.support.v7.app.** { *; }
-keep interface android.support.v7.app.** { *; }

如果该文件不存在,您可以在 app/proguard-rules.pro 下创建它。请注意,如果您将 Android Studio 设置为“Android” View ,则该文件可能不会显示。您可能需要暂时切换到“项目” View 才能找到它。

关于Android Studio 1.0.2 "minifyEnabled true"使签名版本 apk 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28199527/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com