Android apk 发布构建因混淆器而失败
Android apk release build fails with proguard
我的 APK 在调试和发布变体中构建良好,并安装在我的测试设备上,按预期工作,但在为 Playstore 发布签署 APK 时,它就 ProGuard 部分而言,并抱怨 Cordova XWalk插件。
> ProGuard, version 5.2.1
Reading input...
Reading program jar [/home/Evil_Wizard/Projects/Taxicode/App/Android/build/intermediates/exploded-aar/org.xwalk/xwalk_core_library/14.43.343.25/jars/classes.jar] (filtered)
Reading program jar [/home/Evil_Wizard/Projects/Taxicode/App/Android/build/intermediates/exploded-aar/Android/CordovaLib/unspecified/release/jars/classes.jar] (filtered)
Reading program directory [/home/Evil_Wizard/Projects/Taxicode/App/Android/build/intermediates/classes/armv7/release] (filtered)
Reading library jar [/home/Evil_Wizard/Android/Sdk/platforms/android-21/android.jar]
Initializing...
Warning: org.apache.cordova.CordovaInterfaceImpl: can't find referenced method 'void requestPermissions(java.lang.String[],int)' in library class android.app.Activity
Warning: org.apache.cordova.CordovaInterfaceImpl: can't find referenced method 'int checkSelfPermission(java.lang.String)' in library class android.app.Activity
Note: org.chromium.base.library_loader.Linker calls '(org.chromium.base.library_loader.Linker$TestRunner)Class.forName(variable).newInstance()'
Note: org.chromium.net.DefaultAndroidKeyStore: can't find dynamically referenced class org.apache.harmony.xnet.provider.jsse.OpenSSLRSAPrivateKey
Note: org.chromium.net.DefaultAndroidKeyStore: can't find dynamically referenced class org.apache.harmony.xnet.provider.jsse.OpenSSLEngine
Note: org.chromium.media.MediaPlayerBridge accesses a field 'PAUSE_AVAILABLE' dynamically
Note: org.chromium.media.MediaPlayerBridge accesses a field 'SEEK_FORWARD_AVAILABLE' dynamically
Note: org.chromium.media.MediaPlayerBridge accesses a field 'SEEK_BACKWARD_AVAILABLE' dynamically
Note: the configuration keeps the entry point 'org.chromium.base.library_loader.Linker { boolean nativeLoadLibrary(java.lang.String,long,org.chromium.base.library_loader.Linker$LibInfo); }', but not the descriptor class 'org.chromium.base.library_loader.Linker$LibInfo'
Note: the configuration keeps the entry point 'org.chromium.base.library_loader.Linker { boolean nativeLoadLibraryInZipFile(java.lang.String,java.lang.String,long,org.chromium.base.library_loader.Linker$LibInfo); }', but not the descriptor class 'org.chromium.base.library_loader.Linker$LibInfo'
Note: the configuration keeps the entry point 'org.chromium.base.library_loader.Linker { boolean nativeCreateSharedRelro(java.lang.String,long,org.chromium.base.library_loader.Linker$LibInfo); }', but not the descriptor class 'org.chromium.base.library_loader.Linker$LibInfo'
Note: the configuration keeps the entry point 'org.chromium.base.library_loader.Linker { boolean nativeUseSharedRelro(java.lang.String,org.chromium.base.library_loader.Linker$LibInfo); }', but not the descriptor class 'org.chromium.base.library_loader.Linker$LibInfo'
Note: the configuration keeps the entry point 'org.chromium.content.browser.ContentViewCore { long nativeInit(org.chromium.content_public.browser.WebContents,org.chromium.ui.base.ViewAndroid,long,java.util.HashSet); }', but not the descriptor class 'org.chromium.content_public.browser.WebContents'
Note: the configuration keeps the entry point 'org.chromium.content.browser.ContentViewCore { long nativeInit(org.chromium.content_public.browser.WebContents,org.chromium.ui.base.ViewAndroid,long,java.util.HashSet); }', but not the descriptor class 'org.chromium.ui.base.ViewAndroid'
Note: the configuration keeps the entry point 'org.chromium.content.browser.ContentViewCore { org.chromium.content.browser.ContentViewCore nativeFromWebContentsAndroid(org.chromium.content_public.browser.WebContents); }', but not the descriptor class 'org.chromium.content_public.browser.WebContents'
Note: the configuration keeps the entry point 'org.chromium.content.browser.MediaDrmCredentialManager { void nativeResetCredentials(org.chromium.content.browser.MediaDrmCredentialManager$MediaDrmCredentialManagerCallback); }', but not the descriptor class 'org.chromium.content.browser.MediaDrmCredentialManager$MediaDrmCredentialManagerCallback'
Note: the configuration keeps the entry point 'org.chromium.content.browser.ServiceRegistry { void nativeAddService(long,org.chromium.mojo.bindings.Interface$Manager,org.chromium.content.browser.ServiceRegistry$ImplementationFactory,java.lang.String); }', but not the descriptor class 'org.chromium.mojo.bindings.Interface$Manager'
Note: the configuration keeps the entry point 'org.chromium.content.browser.ServiceRegistry { void nativeAddService(long,org.chromium.mojo.bindings.Interface$Manager,org.chromium.content.browser.ServiceRegistry$ImplementationFactory,java.lang.String); }', but not the descriptor class 'org.chromium.content.browser.ServiceRegistry$ImplementationFactory'
Note: the configuration keeps the entry point 'org.chromium.content.browser.framehost.NavigationControllerImpl { void nativeGetDirectedNavigationHistory(long,org.chromium.content_public.browser.NavigationHistory,boolean,int); }', but not the descriptor class 'org.chromium.content_public.browser.NavigationHistory'
Note: the configuration keeps the entry point 'org.chromium.content.browser.webcontents.WebContentsImpl { void nativeEvaluateJavaScript(long,java.lang.String,org.chromium.content_public.browser.JavaScriptCallback); }', but not the descriptor class 'org.chromium.content_public.browser.JavaScriptCallback'
Note: the configuration keeps the entry point 'org.chromium.mojo.system.impl.CoreImpl { org.chromium.mojo.system.impl.CoreImpl$AsyncWaiterCancellableImpl nativeAsyncWait(int,int,long,org.chromium.mojo.system.AsyncWaiter$Callback); }', but not the descriptor class 'org.chromium.mojo.system.AsyncWaiter$Callback'
Note: the configuration keeps the entry point 'org.xwalk.core.internal.XWalkContent { void nativeSetJavaPeers(long,org.xwalk.core.internal.XWalkContent,org.xwalk.core.internal.XWalkWebContentsDelegateAdapter,org.xwalk.core.internal.XWalkContentsClientBridge,org.xwalk.core.internal.XWalkContentsIoThreadClient,org.chromium.components.navigation_interception.InterceptNavigationDelegate); }', but not the descriptor class 'org.xwalk.core.internal.XWalkWebContentsDelegateAdapter'
Note: the configuration keeps the entry point 'org.xwalk.core.internal.XWalkContent { void nativeSetJavaPeers(long,org.xwalk.core.internal.XWalkContent,org.xwalk.core.internal.XWalkWebContentsDelegateAdapter,org.xwalk.core.internal.XWalkContentsClientBridge,org.xwalk.core.internal.XWalkContentsIoThreadClient,org.chromium.components.navigation_interception.InterceptNavigationDelegate); }', but not the descriptor class 'org.xwalk.core.internal.XWalkContentsIoThreadClient'
Note: the configuration keeps the entry point 'org.xwalk.core.internal.XWalkContent { void nativeSetJavaPeers(long,org.xwalk.core.internal.XWalkContent,org.xwalk.core.internal.XWalkWebContentsDelegateAdapter,org.xwalk.core.internal.XWalkContentsClientBridge,org.xwalk.core.internal.XWalkContentsIoThreadClient,org.chromium.components.navigation_interception.InterceptNavigationDelegate); }', but not the descriptor class 'org.chromium.components.navigation_interception.InterceptNavigationDelegate'
Note: the configuration keeps the entry point 'org.xwalk.core.internal.XWalkSettings { long nativeInit(org.chromium.content_public.browser.WebContents); }', but not the descriptor class 'org.chromium.content_public.browser.WebContents'
Note: there were 17 unkept descriptor classes in kept class members.
You should consider explicitly keeping the mentioned classes
(using '-keep').
>Note: there were 2 unresolved dynamic references to classes or interfaces.
You should check if you need to specify additional program jars.
>Note: there were 1 class casts of dynamically created class instances.
You might consider explicitly keeping the mentioned classes and/or
their implementations (using '-keep').
>Note: there were 3 accesses to class members by means of introspection.
You should consider explicitly keeping the mentioned class members
(using '-keep' or '-keepclassmembers').
>Warning: there were 2 unresolved references to library class members.
You probably need to update the library versions.
>Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
:transformClassesAndResourcesWithProguardForArmv7Release FAILED
>FAILURE: Build failed with an exception.
>*What went wrong:
>Execution failed for task ':transformClassesAndResourcesWithProguardForArmv7Release'.
java.io.IOException: Please correct the above warnings first.
>*Try:
>Run with --stacktrace option to get the stack trace. Run with --info or -
debug option to get more log output.
>BUILD FAILED
>Total time: 1 mins 31.84 secs
由于我是应用程序开发的新手,在我知道如何使用/配置 ProGuard 之前,我可以以某种方式禁用它吗?或者我是否必须在设置这些数字的许多地方之一的某个地方使用更高的 SDK 版本号重建?
只是 ProGuard minifyEnabled 标志设置为 true 导致了问题。将标志设置为 false 允许对构建进行签名并将其发布到 playstore。一旦我知道如何调试它的问题,我肯定会重新启用它。
build.gradle
buildTypes {
debug {
debuggable true
jniDebuggable false
renderscriptDebuggable true
zipAlignEnabled true
}
release {
debuggable false
jniDebuggable false
renderscriptDebuggable false
renderscriptOptimLevel 3
minifyEnabled false
pseudoLocalesEnabled false
zipAlignEnabled true
}
}
android studio 中的默认设置是 运行 proguard only on release APK。
你可以像那样在构建文件中更改它
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
并且您还尝试在您的 proguard-rules -keep class !my.package.** { *; }
中写入以保留所有库 类
我的 APK 在调试和发布变体中构建良好,并安装在我的测试设备上,按预期工作,但在为 Playstore 发布签署 APK 时,它就 ProGuard 部分而言,并抱怨 Cordova XWalk插件。
> ProGuard, version 5.2.1
Reading input...
Reading program jar [/home/Evil_Wizard/Projects/Taxicode/App/Android/build/intermediates/exploded-aar/org.xwalk/xwalk_core_library/14.43.343.25/jars/classes.jar] (filtered)
Reading program jar [/home/Evil_Wizard/Projects/Taxicode/App/Android/build/intermediates/exploded-aar/Android/CordovaLib/unspecified/release/jars/classes.jar] (filtered)
Reading program directory [/home/Evil_Wizard/Projects/Taxicode/App/Android/build/intermediates/classes/armv7/release] (filtered)
Reading library jar [/home/Evil_Wizard/Android/Sdk/platforms/android-21/android.jar]
Initializing...
Warning: org.apache.cordova.CordovaInterfaceImpl: can't find referenced method 'void requestPermissions(java.lang.String[],int)' in library class android.app.Activity
Warning: org.apache.cordova.CordovaInterfaceImpl: can't find referenced method 'int checkSelfPermission(java.lang.String)' in library class android.app.Activity
Note: org.chromium.base.library_loader.Linker calls '(org.chromium.base.library_loader.Linker$TestRunner)Class.forName(variable).newInstance()'
Note: org.chromium.net.DefaultAndroidKeyStore: can't find dynamically referenced class org.apache.harmony.xnet.provider.jsse.OpenSSLRSAPrivateKey
Note: org.chromium.net.DefaultAndroidKeyStore: can't find dynamically referenced class org.apache.harmony.xnet.provider.jsse.OpenSSLEngine
Note: org.chromium.media.MediaPlayerBridge accesses a field 'PAUSE_AVAILABLE' dynamically
Note: org.chromium.media.MediaPlayerBridge accesses a field 'SEEK_FORWARD_AVAILABLE' dynamically
Note: org.chromium.media.MediaPlayerBridge accesses a field 'SEEK_BACKWARD_AVAILABLE' dynamically
Note: the configuration keeps the entry point 'org.chromium.base.library_loader.Linker { boolean nativeLoadLibrary(java.lang.String,long,org.chromium.base.library_loader.Linker$LibInfo); }', but not the descriptor class 'org.chromium.base.library_loader.Linker$LibInfo'
Note: the configuration keeps the entry point 'org.chromium.base.library_loader.Linker { boolean nativeLoadLibraryInZipFile(java.lang.String,java.lang.String,long,org.chromium.base.library_loader.Linker$LibInfo); }', but not the descriptor class 'org.chromium.base.library_loader.Linker$LibInfo'
Note: the configuration keeps the entry point 'org.chromium.base.library_loader.Linker { boolean nativeCreateSharedRelro(java.lang.String,long,org.chromium.base.library_loader.Linker$LibInfo); }', but not the descriptor class 'org.chromium.base.library_loader.Linker$LibInfo'
Note: the configuration keeps the entry point 'org.chromium.base.library_loader.Linker { boolean nativeUseSharedRelro(java.lang.String,org.chromium.base.library_loader.Linker$LibInfo); }', but not the descriptor class 'org.chromium.base.library_loader.Linker$LibInfo'
Note: the configuration keeps the entry point 'org.chromium.content.browser.ContentViewCore { long nativeInit(org.chromium.content_public.browser.WebContents,org.chromium.ui.base.ViewAndroid,long,java.util.HashSet); }', but not the descriptor class 'org.chromium.content_public.browser.WebContents'
Note: the configuration keeps the entry point 'org.chromium.content.browser.ContentViewCore { long nativeInit(org.chromium.content_public.browser.WebContents,org.chromium.ui.base.ViewAndroid,long,java.util.HashSet); }', but not the descriptor class 'org.chromium.ui.base.ViewAndroid'
Note: the configuration keeps the entry point 'org.chromium.content.browser.ContentViewCore { org.chromium.content.browser.ContentViewCore nativeFromWebContentsAndroid(org.chromium.content_public.browser.WebContents); }', but not the descriptor class 'org.chromium.content_public.browser.WebContents'
Note: the configuration keeps the entry point 'org.chromium.content.browser.MediaDrmCredentialManager { void nativeResetCredentials(org.chromium.content.browser.MediaDrmCredentialManager$MediaDrmCredentialManagerCallback); }', but not the descriptor class 'org.chromium.content.browser.MediaDrmCredentialManager$MediaDrmCredentialManagerCallback'
Note: the configuration keeps the entry point 'org.chromium.content.browser.ServiceRegistry { void nativeAddService(long,org.chromium.mojo.bindings.Interface$Manager,org.chromium.content.browser.ServiceRegistry$ImplementationFactory,java.lang.String); }', but not the descriptor class 'org.chromium.mojo.bindings.Interface$Manager'
Note: the configuration keeps the entry point 'org.chromium.content.browser.ServiceRegistry { void nativeAddService(long,org.chromium.mojo.bindings.Interface$Manager,org.chromium.content.browser.ServiceRegistry$ImplementationFactory,java.lang.String); }', but not the descriptor class 'org.chromium.content.browser.ServiceRegistry$ImplementationFactory'
Note: the configuration keeps the entry point 'org.chromium.content.browser.framehost.NavigationControllerImpl { void nativeGetDirectedNavigationHistory(long,org.chromium.content_public.browser.NavigationHistory,boolean,int); }', but not the descriptor class 'org.chromium.content_public.browser.NavigationHistory'
Note: the configuration keeps the entry point 'org.chromium.content.browser.webcontents.WebContentsImpl { void nativeEvaluateJavaScript(long,java.lang.String,org.chromium.content_public.browser.JavaScriptCallback); }', but not the descriptor class 'org.chromium.content_public.browser.JavaScriptCallback'
Note: the configuration keeps the entry point 'org.chromium.mojo.system.impl.CoreImpl { org.chromium.mojo.system.impl.CoreImpl$AsyncWaiterCancellableImpl nativeAsyncWait(int,int,long,org.chromium.mojo.system.AsyncWaiter$Callback); }', but not the descriptor class 'org.chromium.mojo.system.AsyncWaiter$Callback'
Note: the configuration keeps the entry point 'org.xwalk.core.internal.XWalkContent { void nativeSetJavaPeers(long,org.xwalk.core.internal.XWalkContent,org.xwalk.core.internal.XWalkWebContentsDelegateAdapter,org.xwalk.core.internal.XWalkContentsClientBridge,org.xwalk.core.internal.XWalkContentsIoThreadClient,org.chromium.components.navigation_interception.InterceptNavigationDelegate); }', but not the descriptor class 'org.xwalk.core.internal.XWalkWebContentsDelegateAdapter'
Note: the configuration keeps the entry point 'org.xwalk.core.internal.XWalkContent { void nativeSetJavaPeers(long,org.xwalk.core.internal.XWalkContent,org.xwalk.core.internal.XWalkWebContentsDelegateAdapter,org.xwalk.core.internal.XWalkContentsClientBridge,org.xwalk.core.internal.XWalkContentsIoThreadClient,org.chromium.components.navigation_interception.InterceptNavigationDelegate); }', but not the descriptor class 'org.xwalk.core.internal.XWalkContentsIoThreadClient'
Note: the configuration keeps the entry point 'org.xwalk.core.internal.XWalkContent { void nativeSetJavaPeers(long,org.xwalk.core.internal.XWalkContent,org.xwalk.core.internal.XWalkWebContentsDelegateAdapter,org.xwalk.core.internal.XWalkContentsClientBridge,org.xwalk.core.internal.XWalkContentsIoThreadClient,org.chromium.components.navigation_interception.InterceptNavigationDelegate); }', but not the descriptor class 'org.chromium.components.navigation_interception.InterceptNavigationDelegate'
Note: the configuration keeps the entry point 'org.xwalk.core.internal.XWalkSettings { long nativeInit(org.chromium.content_public.browser.WebContents); }', but not the descriptor class 'org.chromium.content_public.browser.WebContents'
Note: there were 17 unkept descriptor classes in kept class members.
You should consider explicitly keeping the mentioned classes
(using '-keep').
>Note: there were 2 unresolved dynamic references to classes or interfaces.
You should check if you need to specify additional program jars.
>Note: there were 1 class casts of dynamically created class instances.
You might consider explicitly keeping the mentioned classes and/or
their implementations (using '-keep').
>Note: there were 3 accesses to class members by means of introspection.
You should consider explicitly keeping the mentioned class members
(using '-keep' or '-keepclassmembers').
>Warning: there were 2 unresolved references to library class members.
You probably need to update the library versions.
>Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
:transformClassesAndResourcesWithProguardForArmv7Release FAILED
>FAILURE: Build failed with an exception.
>*What went wrong:
>Execution failed for task ':transformClassesAndResourcesWithProguardForArmv7Release'.
java.io.IOException: Please correct the above warnings first.
>*Try:
>Run with --stacktrace option to get the stack trace. Run with --info or -
debug option to get more log output.
>BUILD FAILED
>Total time: 1 mins 31.84 secs
由于我是应用程序开发的新手,在我知道如何使用/配置 ProGuard 之前,我可以以某种方式禁用它吗?或者我是否必须在设置这些数字的许多地方之一的某个地方使用更高的 SDK 版本号重建?
只是 ProGuard minifyEnabled 标志设置为 true 导致了问题。将标志设置为 false 允许对构建进行签名并将其发布到 playstore。一旦我知道如何调试它的问题,我肯定会重新启用它。
build.gradle
buildTypes {
debug {
debuggable true
jniDebuggable false
renderscriptDebuggable true
zipAlignEnabled true
}
release {
debuggable false
jniDebuggable false
renderscriptDebuggable false
renderscriptOptimLevel 3
minifyEnabled false
pseudoLocalesEnabled false
zipAlignEnabled true
}
}
android studio 中的默认设置是 运行 proguard only on release APK。
你可以像那样在构建文件中更改它
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
并且您还尝试在您的 proguard-rules -keep class !my.package.** { *; }
中写入以保留所有库 类