How to Build APK and Install APK

本文详细介绍了如何解决使用Maven构建APK文件时遇到的问题,包括更新Maven版本、解决构建错误、使用Eclipse相关工具生成APK文件,并解决了安装APK时出现的冲突和证书不一致问题。

How to Build APK and Install APK

First thing, I upgrade my maven to the latest version, so I have problem to build the apk file.

Error Message:
[INFO] --- android-maven-plugin:3.6.0:generate-sources (default-generate-sources) @ google-play-services --- [WARNING] Error injecting: com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo java.lang.NoClassDefFoundError: Lorg/sonatype/aether/RepositorySystem;        at java.lang.Class.getDeclaredFields0(Native Method)        at java.lang.Class.privateGetDeclaredFields(Class.java:2387)        at java.lang.Class.getDeclaredFields(Class.java:1796)        at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:661)        at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:366)        at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies(ConstructorBindingImpl.java:165)        at com.google.inject.internal.InjectorImpl.getInternalDependencies(InjectorImpl.java:609)        at com.google.inject.internal.InjectorImpl.cleanup(InjectorImpl.java:565)
        at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:551)

Solution:
The solution is that the latest version does not mean the best version. So I roll back my maven to 3.0.5 version. It works.

The I try the eclipse related tool to generate the apk file like this.
[Android Tool] —> [Export Signed Android Application]

But when I try to install the APK, I use command.
adb install -r ./LocalpointTester_Android.apk
adb install ./LocalpointTester_Android.apk

If I run the command without -r option, I got Error Message:
Failure [INSTALL_FAILED_ALREADY_EXISTS]

If I run the command with -r option, I got Error Message:
Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]

Because the signature is different from different developers. So I uninstall the app from the device- application manager.

It works fine then.

And the APK file is automatically generated under [Project Name] —> [bin] directory.

Or we can generate from Menu [ Build ] ——> [Generate Signed APK]

References:
http://stackoverflow.com/questions/17293940/soap-enabler-maven-build-failure
http://maven.apache.org/download.cgi

C:\Users\qusg>appium-doctor --android WARN AppiumDoctor [Deprecated] Please use appium-doctor installed with "npm install @appium/doctor --location=global" info AppiumDoctor Appium Doctor v.1.16.2 info AppiumDoctor ### Diagnostic for necessary dependencies starting ### info AppiumDoctor ✔ The Node.js binary was found at: C:\own\app\Node\node.EXE info AppiumDoctor ✔ Node version is 22.18.0 info AppiumDoctor ✔ ANDROID_HOME is set to: C:\Users\qusg\AppData\Local\Android\Sdk info AppiumDoctor ✔ JAVA_HOME is set to: C:\own\app\JDK info AppiumDoctor Checking adb, android, emulator, apkanalyzer.bat info AppiumDoctor 'adb' is in C:\Users\qusg\AppData\Local\Android\Sdk\platform-tools\adb.exe info AppiumDoctor 'emulator' is in C:\Users\qusg\AppData\Local\Android\Sdk\emulator\emulator.exe WARN AppiumDoctor ✖ android, apkanalyzer.bat could NOT be found in C:\Users\qusg\AppData\Local\Android\Sdk! info AppiumDoctor ✔ 'bin' subfolder exists under 'C:\own\app\JDK' info AppiumDoctor ### Diagnostic for necessary dependencies completed, one fix needed. ### info AppiumDoctor info AppiumDoctor ### Diagnostic for optional dependencies starting ### WARN AppiumDoctor ✖ opencv4nodejs cannot be found. WARN AppiumDoctor ✖ ffmpeg cannot be found WARN AppiumDoctor ✖ mjpeg-consumer cannot be found. WARN AppiumDoctor ✖ bundletool.jar cannot be found WARN AppiumDoctor ✖ gst-launch-1.0.exe and/or gst-inspect-1.0.exe cannot be found info AppiumDoctor ### Diagnostic for optional dependencies completed, 5 fixes possible. ### info AppiumDoctor info AppiumDoctor ### Manual Fixes Needed ### info AppiumDoctor The configuration cannot be automatically fixed, please do the following first: WARN AppiumDoctor ➜ Manually install android, apkanalyzer.bat and add it to PATH. https://developer.android.com/studio#cmdline-tools and https://developer.android.com/studio/intro/update#sdk-manager may help to setup. info AppiumDoctor info AppiumDoctor ### Optional Manual Fixes ### info AppiumDoctor The configuration can install optionally. Please do the following manually: WARN AppiumDoctor ➜ Why opencv4nodejs is needed and how to install it: http://appium.io/docs/en/writing-running-appium/image-comparison/ WARN AppiumDoctor ➜ ffmpeg is needed to record screen features. Please read https://www.ffmpeg.org/ to install it WARN AppiumDoctor ➜ mjpeg-consumer module is required to use MJPEG-over-HTTP features. Please install it with 'npm i -g mjpeg-consumer'. WARN AppiumDoctor ➜ bundletool.jar is used to handle Android App Bundle. Please read http://appium.io/docs/en/writing-running-appium/android/android-appbundle/ to install it. Also consider adding the ".jar" extension into your PATHEXT environment variable in order to fix the problem for Windows WARN AppiumDoctor ➜ gst-launch-1.0.exe and gst-inspect-1.0.exe are used to stream the screen of the device under test. Please read https://appium.io/docs/en/writing-running-appium/android/android-screen-streaming/ to install them and for more details info AppiumDoctor info AppiumDoctor ### info AppiumDoctor info AppiumDoctor Bye! Run appium-doctor again when all manual fixes have been applied! info AppiumDoctor
最新发布
10-14
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值