gpt4 book ai didi

android - 无法使用 Visual Studio 在 Android 上构建(运行)Cordova 应用程序

转载 作者:太空宇宙 更新时间:2023-11-03 11:47:42 26 4
gpt4 key购买 nike

我创建了新的 BlankCordovaApp,只是无法在 Andorid 上运行它,在 Windows 上运行它没有问题。此外,我可以通过 cmd 手动构建和运行它:

 cordova run android

Visual studio output:

1>  ------ Build configuration options: --debug
1> Executing "before_compile" hook for all plugins.
1> ANDROID_HOME=C:\Users\dima-\AppData\Local\Android\sdk
1> JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_55
1> Reading build config file: E:\dima-\Documents\Visual Studio 2015\Projects\BlankCordovaApp1\BlankCordovaApp1\build.json
1>MSBUILD : cordova-build warning : Note: Some input files use or override a deprecated API.
1> Note: Some input files use or override a deprecated API.
1>MSBUILD : cordova-build warning : Note: Recompile with -Xlint:deprecation for details.
1> Note: Recompile with -Xlint:deprecation for details.
1>MSBUILD : cordova-build error : java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
1> java.lang.UnsupportedClassVersionError com/android/dx/command/Main : Unsupported major.minor version 52.0
1>MSBUILD : cordova-build error : at java.lang.ClassLoader.defineClass1(Native Method)
1> at java.lang.ClassLoader.defineClass1(Native Method)
1>MSBUILD : cordova-build error : at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
1> at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
1> :transformClassesWithDexForDebug FAILED
1>
1> BUILD FAILED
1>
1> Total time: 5.112 secs
1>MSBUILD : cordova-build error : at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
1> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
1>MSBUILD : cordova-build error : at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
1> at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
1>MSBUILD : cordova-build error : at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
1> at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
1>MSBUILD : cordova-build error : at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
1> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
1>MSBUILD : cordova-build error : at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
1> at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
1>MSBUILD : cordova-build error : at java.security.AccessController.doPrivileged(Native Method)
1> at java.security.AccessController.doPrivileged(Native Method)
1>MSBUILD : cordova-build error : at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
1> at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
1>MSBUILD : cordova-build error : at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
1> at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
1>MSBUILD : cordova-build error : at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
1> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
1>MSBUILD : cordova-build error : at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
1> at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
1>MSBUILD : cordova-build error : at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
1> at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
1>MSBUILD : cordova-build error : Picked up _JAVA_OPTIONS: -Xmx512M
1> Picked up _JAVA_OPTIONS: -Xmx512M
1>MSBUILD : cordova-build error : Exception in thread "main"
1> Exception in thread "main"
1>MSBUILD : cordova-build error : java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
1> java.lang.UnsupportedClassVersionError com/android/dx/command/Main : Unsupported major.minor version 52.0
1>MSBUILD : cordova-build error : at java.lang.ClassLoader.defineClass1(Native Method)
1> at java.lang.ClassLoader.defineClass1(Native Method)
1>MSBUILD : cordova-build error : at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
1> at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
1>MSBUILD : cordova-build error : at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
1> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
1>MSBUILD : cordova-build error : at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
1> at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
1>MSBUILD : cordova-build error : at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
1> at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
1>MSBUILD : cordova-build error : at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
1> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
1>MSBUILD : cordova-build error : at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
1> at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
1>MSBUILD : cordova-build error : at java.security.AccessController.doPrivileged(Native Method)
1> at java.security.AccessController.doPrivileged(Native Method)
1>MSBUILD : cordova-build error : at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
1> at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
1>MSBUILD : cordova-build error : at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
1> at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
1>MSBUILD : cordova-build error : at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
1> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
1>MSBUILD : cordova-build error : at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
1> at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
1>MSBUILD : cordova-build error : at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
1> at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
1>MSBUILD : cordova-build error : Picked up _JAVA_OPTIONS: -Xmx512M
1> Picked up _JAVA_OPTIONS: -Xmx512M
1>MSBUILD : cordova-build error : Exception in thread "main"
1> Exception in thread "main"
1>
1>MSBUILD : cordova-build error : FAILURE: Build failed with an exception.
1> FAILURE: Build failed with an exception.
1>
1>MSBUILD : cordova-build error : * What went wrong:
1> * What went wrong:
1>MSBUILD : cordova-build error : Execution failed for task ':transformClassesWithDexForDebug'.
1> Execution failed for task ':transformClassesWithDexForDebug'.
1>MSBUILD : cordova-build error : > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.7.0_55\bin\java.exe'' finished with non-zero exit value 1
1> > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.7.0_55\bin\java.exe'' finished with non-zero exit value 1

命令输出:

    E:\dima-\Documents\Visual Studio 2015\Projects\BlankCordovaApp1\BlankCordovaApp1>cordova run android    ANDROID_HOME=C:\Users\dima-\AppData\Local\Android\sdk    JAVA_HOME=C:\Program Files\java\jdk1.8.0_92    No target specified, deploying to device 'LGH818fdb0daf3'.    Reading build config file: E:\dima-\Documents\Visual Studio 2015\Projects\BlankCordovaApp1\BlankCordovaApp1\build.json========================//////////////////////========================    BUILD SUCCESSFUL    Total time: 5.313 secs    Built the following apk(s):            E:/dima-/Documents/Visual Studio 2015/Projects/BlankCordovaApp1/BlankCordovaApp1/platforms/android/build/outputs/apk/android-debug.apk    Using apk: E:/dima-/Documents/Visual Studio 2015/Projects/BlankCordovaApp1/BlankCordovaApp1/platforms/android/build/outputs/apk/android-debug.apk    LAUNCH SUCCESS

最佳答案

安装 Java JDK 8。

然后,转到“工具”->“选项”->“Apache Cordova 工具”->“环境变量覆盖”并将 JDK 的路径设置为“C:\Program Files\java\jdk1.8.0_92”以获取 Java 8 而不是Java 7。

关于android - 无法使用 Visual Studio 在 Android 上构建(运行)Cordova 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38138380/

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