将 Cordova 6.1.2-Project 导入 Eclipse:Android 依赖项中缺少 cordovalib.jar
Posted
技术标签:
【中文标题】将 Cordova 6.1.2-Project 导入 Eclipse:Android 依赖项中缺少 cordovalib.jar【英文标题】:Importing Cordova 6.1.2-Project to Eclipse: cordovalib.jar missing in Android Dependencies 【发布时间】:2017-08-10 03:21:53 【问题描述】:我创建了一个 cordova 项目并像这样构建它:
cordova create /my_folder/FlugbuchFPG com.MyName.FlugbuchFPG FlugbuchFPG
cd /my_folder/FlugbuchFPG
cordova platform add android --save
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.MyName.FlugbuchFPG
Name: FlugbuchFPG
Activity: MainActivity
Android target: android-25
Subproject Path: CordovaLib
Android project created with cordova-android@6.1.2
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
Fetching plugin "cordova-plugin-whitelist@1" via npm
Installing "cordova-plugin-whitelist" for android
This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.
Saved plugin info for "cordova-plugin-whitelist" to config.xml
--save flag or autosave detected
Saving android@~6.1.2 into config.xml file ...
Installed platforms:
android 6.1.2
Available platforms:
amazon-fireos ~3.6.3 (deprecated)
blackberry10 ~3.8.0
browser ~4.1.0
firefoxos ~3.6.3
ios ~4.3.0
osx ~4.0.1
webos ~3.7.0
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-17,android-18,android-19,android-20,android-21,android-22,android-23,android-N,android-25,Google Inc.:Google APIs:17,Google Inc.:Google APIs:18,Google Inc.:Glass Development Kit Preview:19,Google Inc.:Google APIs (x86 System Image):19,Google Inc.:Google APIs:19,Google Inc.:Google APIs:21,Google Inc.:Google APIs:22,Google Inc.:Google APIs:23
Gradle: installed
cordova build
ANDROID_HOME=/Users/myname/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home
Subproject Path: CordovaLib
Starting a new Gradle Daemon for this build (subsequent builds will be faster).
Incremental java compilation is an incubating feature.
:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:compileLint
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugShaders
:CordovaLib:compileDebugShaders
:CordovaLib:generateDebugAssets
:CordovaLib:mergeDebugAssets
:CordovaLib:mergeDebugProguardFiles
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:compileDebugRenderscript
:CordovaLib:generateDebugResValues
:CordovaLib:generateDebugResources
:CordovaLib:packageDebugResources
:CordovaLib:processDebugManifest
:CordovaLib:generateDebugBuildConfig
:CordovaLib:processDebugResources
:CordovaLib:generateDebugSources
:CordovaLib:incrementalDebugJavaCompilationSafeguard
:CordovaLib:compileDebugJavaWithJavac
:CordovaLib:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
Note: 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
:generateDebugResValues
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResources
:generateDebugSources
:incrementalDebugJavaCompilationSafeguard
:compileDebugJavaWithJavac
:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:compileDebugNdk UP-TO-DATE
:compileDebugSources
:mergeDebugShaders
:compileDebugShaders
:generateDebugAssets
:mergeDebugAssets
:transformClassesWithDexForDebug
:mergeDebugJniLibFolders
:transformNative_libsWithMergeJniLibsForDebug
:processDebugJavaRes UP-TO-DATE
:transformResourcesWithMergeJavaResForDebug
:validateSigningDebug
:packageDebug
:assembleDebug
:cdvBuildDebug
BUILD SUCCESSFUL
Total time: 19.753 secs
Built the following apk(s):
/my_folder/FlugbuchFPG/platforms/android/build/outputs/apk/android-debug.apk
我将 android-debug.apk 下载到我的 Android 设备,它工作正常。
然后我尝试将项目导入 Eclipse 4.4.2。我选择 -> File -> Import... -> Android -> Existing Android Code into Workspace
Eclipse 为我提供了 6 个软件包。我只选择“MainActivity”和“CordovaLib”,因为所有其他的路径或名称中都有“debug”一词。我将“MainAvtivity”重命名为我的应用程序的名称,将“CordovaLib”重命名为“ProjectnameCordovaLib”。
导入运行,但由于错误,项目被标记为红色。当我转到“右键单击-> 属性-> Java 构建路径-> Android 依赖项”时,它告诉我 bin 文件夹中缺少 cordovalib.jar。实际上 bin-Folder 是完全空的。
当我从 Android 依赖项中删除该条目时,会出现其他错误。所以这似乎不是解决方案。那么如何创建 oder 以获取丢失的 cordovalib.jar 或以不同的方式解决此问题?谢谢。
【问题讨论】:
【参考方案1】:万一其他人有这个问题:
最后,我从硬盘中删除了所有 cordova 项目,卸载了 eclipse,下载了新版本的 eclipse 并且 - 重要! - 选择与以前不同的目录作为工作区。如果您使用相同的工作区,似乎只是卸载并重新安装 eclipse 并没有帮助,因为 eclipse 会以某种方式记住旧的工作区并且再次发生错误。选择新的工作区目录后,我重新生成了 cordova 项目并将它们导入到 eclispe,现在错误消失了,我可以构建应用程序了。
【讨论】:
以上是关于将 Cordova 6.1.2-Project 导入 Eclipse:Android 依赖项中缺少 cordovalib.jar的主要内容,如果未能解决你的问题,请参考以下文章
Cordova与现有框架的结合,Cordova插件使用教程,Cordova自定义插件,框架集成Cordova,将Cordova集成到现有框架中
使用cordova将图片从android画廊分享到cordova应用程序
Angular 6 - Cordova - 如何将当前的 Angular 项目转换为基于 Cordova 的项目?