说一下我碰到的问题,我自己创建的vue项目利用cordova打包是没有问题的,可以生成akp文件,但是公司的项目按照之前的办法始终不行,报如下错误:
1 error; aborting
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
cordova文件里面打开cmd 输入命令:cordova requirements显示:
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed
Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
Cannot read property 'version' of undefined
这里说一下,我的androidSDK是已经安装了的,不然之前的项目也不能打包成功,自己的项目里输入:cordova requirements显示:
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-28,android-25,android-24,android-23
Gradle: installed C:\Program Files\Gradle\gradle-5.6.3\bin\gradle
然后就在这个问题上困扰了很久,尝试过降低android版本,反正就是不行。
最后的解决办法就是单独把公司醒目的android文件夹拎出来在android Studio 上面运行了一下,之后再cordova目录下载输入命令:cordova run android 就打包成功生成apk文件了
Total time: 3.179 secs
Built the following apk(s):
C:/file/demo/yz_science_bar/frontend/learn-cordova/platforms/android/build/outputs/apk/android-debug.apk
至此算是解决了:不过当我再次输入cordova requirements命令查看的时候还是和上面一样的提示,不过apk文件已经生成了,就不深究了,(反正也没有搞懂~~~~~~~~)。QAQ