我正在使用Ionic构建一个混合应用程序。我最近尝试将Ionic应用程序构建到Android应用程序中,但在连接设备的情况下运行ionic run android
时出现以下错误:
Running command: /Users/USERNAME/Sites/PROJECT/egenius-client-application/hooks/after_prepare/010_add_platform_class.js /Users/USERNAME/Sites/PROJECT/egenius-client- application
add to body class: platform-android
ANDROID_HOME=/Users/USERNAME/Library/Developer/android-sdk-macosx
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
No target specified, deploying to device 'F7NPFP131245'.
:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:compileLint
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugRenderscript
:CordovaLib:generateDebugResValues
:CordovaLib:generateDebugResources
:CordovaLib:packageDebugResources
:CordovaLib:compileDebugAidl
:CordovaLib:generateDebugBuildConfig
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets
:CordovaLib:processDebugManifest
:CordovaLib:processDebugResources
:CordovaLib:generateDebugSources
:CordovaLib:compileDebugJavaWithJavacNote: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForDebug
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug
:CordovaLib:mergeDebugJniLibFolders
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug
:CordovaLib:bundleDebug
:prepareAndroidCordovaLibUnspecifiedDebugLibrary
:prepareDebugDependencies
:compileDebugAidl
:compileDebugRenderscript
:generateDebugBuildConfig
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets
:generateDebugResValues
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResourceszs
:generateDebugSources
:compileDebugJavaWithJavacNote: /Users/alexandermcintosh/Sites/eGenius/egenius-client-application/platforms/android/src/org/apache/cordova/splashscreen/SplashScreen. java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:compileDebugNdk UP-TO-DATE
:compileDebugSources
:transformClassesWithDexForDebug
:mergeDebugJniLibFolders
:transformNative_libsWithMergeJniLibsForDebug
:processDebugJavaRes UP-TO-DATE
:transformResourcesWithMergeJavaResForDebug
:validateDebugSigning
:packageDebug
:zipalignDebugUnable to open '/Users/USERNAME/Sites/PROJECT/egenius-client-application/platforms/android/build/outputs/apk/android-debug-unaligned.apk' as zip archive
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':zipalignDebug'.
> Process 'command '/Users/USERNAME/Library/Developer/android-sdk-macosx/build-tools/23.0.2/zipalign'' finished with non-zero exit value 1
* 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: 2 mins 35.63 secs
ERROR running one or more of the platforms: Error code 1 for command: /Users/USERNAME/Sites/PROJECT/egenius-client-application/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/USERNAME/Sites/PROJECT/egenius-client-application/platforms/android/build.gradle,-PcdvBuildArch=x86,-Dorg.gradle.daemon=true,-Pandroid. useDeprecatedNdk=true
You may not have the required environment or OS to run this project
看起来我可以很好地构建,运行ionic build android --release
管理工作没有问题,这是当我必须使用ZipAlign工具。
手动运行该工具,如下所示:~/Library/Developer/android-sdk-macosx/build-tools/23.0.2/zipalign -v 4 android-release-unsigned.apk egenius-app.apk
告诉我:Unable to open 'android-release-unsigned.apk' as zip archive
.
我试过将我的SDK降级到不同的版本,卸载和重新安装插件,我没有卡住,在线查找并没有提供很多帮助。
有人知道我错过了什么吗?
谢谢你,亚历克斯。
UPDATE当我删除依赖Angular Material Design Icons时,应用程序成功构建并签名。
6条答案
按热度按时间krugob8w1#
当未签名的apk与zipalign文件不在同一目录时,我遇到了错误。
我修复了这个问题,把未签名apk的文件路径
pxq42qpu2#
尝试
然后重新运行build、keytool和jarsigner
55ooxyrt3#
我遇到了同样的问题,并尝试使用以下命令
用户名/密码/用户名/密码/用户名/密码
drnojrws4#
你必须先和jarsigner签个字,然后你才能把它对齐。
快速解释:
首先,系统会提示你为密钥库创建一个密码,然后,回答nice工具的其余问题,完成后,你应该在当前目录下创建了一个名为my-release-key.keystore的文件。
完成此过程后,您应该能够:
tsm1rwdh5#
今天,我得到了同样的问题,在我的Mac操作系统,我解决了它采取以下步骤.
1.首先,我从路径复制了
android-release-unsigned.apk
:到我当前的Ionic项目文件夹,即
1.之后,我运行以下命令:-
1.之后,我运行下面的命令,给出完整的路径zipalign如下:-
我的APK成功生成后,采取上述步骤.
希望它能在未来对某人有所帮助。
dwthyt8l6#
我遇到了同样的问题,它使用完整路径工作。
例如:
zipalign -v 4 /用户/rafaelsantiago/应用程序/平台/android/应用程序/构建/输出/apk/发布/应用程序-发布-未签名.apk