Stackoverflow Ionic
您好,
我绝望地尝试在我的Ubuntu 14.04平台上进行离子工作,但我总是遇到一些错误。
以下是我的设置:
echo $ANT_HOME
/usr/share/ant
echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk-amd64
echo $ANDROID_HOME
/opt/adt-bundle-linux-x86_64-20131030/sdk/
我的所作所为:
cd /home/hugo/bin
ionic start myApp blank
cd myApp
ionic platform add android
ionic build android
问题开始了:
Creating android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.ionicframework.myapp869163
Name: myApp
Android target: android-19
Copying template files...
Project successfully created.
Running command: /home/hugo/bin/myApp/hooks/after_prepare/010_add_platform_class.js /home/hugo/bin/myApp
add to body class: platform-android
Installing "com.ionic.keyboard" for android
Installing "org.apache.cordova.console" for android
Installing "org.apache.cordova.device" for android
hugo@hugo-N55SL:~/bin/myApp$ ionic build android
Running command: /home/hugo/bin/myApp/hooks/after_prepare/010_add_platform_class.js /home/hugo/bin/myApp
add to body class: platform-android
Running command: /home/hugo/bin/myApp/platforms/android/cordova/build
Buildfile: /home/hugo/bin/myApp/platforms/android/build.xml
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 24.0.2
[checkenv] Installed at /opt/adt-bundle-linux-x86_64-20131030/sdk
-setup:
[echo] Project Name: CordovaApp
[gettype] Project Type: Application
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools] Using latest Build Tools: 21.1.2
[echo] Resolving Build Target for CordovaApp...
[gettarget] Project Target: Android 4.4.2
[gettarget] API level: 19
[echo] ----------
[echo] Creating output directories if needed...
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/ant-build
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/ant-build/res
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/ant-build/rsObj
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/ant-build/rsLibs
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/ant-gen
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/ant-build/classes
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/ant-build/dexedLibs
[echo] ----------
[echo] Resolving Dependencies for CordovaApp...
[dependency] Library dependencies:
[dependency]
[dependency] ------------------
[dependency] Ordered libraries:
[dependency]
[dependency] ------------------
[echo] ----------
[echo] Building Libraries with 'debug'...
nodeps:
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 24.0.2
[checkenv] Installed at /opt/adt-bundle-linux-x86_64-20131030/sdk
-setup:
[echo] Project Name: CordovaApp
[gettype] Project Type: Android Library
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools] Using latest Build Tools: 21.1.2
[echo] Resolving Build Target for CordovaApp...
[gettarget] Project Target: Android 4.4.2
[gettarget] API level: 19
[echo] ----------
[echo] Creating output directories if needed...
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/CordovaLib/res
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/CordovaLib/libs
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/CordovaLib/ant-build
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/CordovaLib/ant-build/res
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/CordovaLib/ant-build/rsObj
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/CordovaLib/ant-build/rsLibs
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/CordovaLib/ant-gen
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/CordovaLib/ant-build/classes
[mkdir] Created dir: /home/hugo/bin/myApp/platforms/android/CordovaLib/ant-build/dexedLibs
[echo] ----------
[echo] Resolving Dependencies for CordovaApp...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] Generating resource IDs...
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.
-pre-compile:
-compile:
[javac] Compiling 93 source files to /home/hugo/bin/myApp/platforms/android/CordovaLib/ant-build/classes
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[echo] Creating library output jar file...
[jar] Building jar: /home/hugo/bin/myApp/platforms/android/CordovaLib/ant-build/classes.jar
-post-compile:
-obfuscate:
-dex:
[echo] Library project: do not convert bytecode...
-crunch:
[crunch] Crunching PNG Files in source dir: /home/hugo/bin/myApp/platforms/android/CordovaLib/res
[crunch] To destination dir: /home/hugo/bin/myApp/platforms/android/CordovaLib/ant-build/res
[crunch] Crunched 0 PNG files to update cache
-package-resources:
[echo] Library project: do not package resources...
-package:
[echo] Library project: do not package apk...
-post-package:
-do-debug:
[echo] Library project: do not create apk...
[propertyfile] Creating new property file: /home/hugo/bin/myApp/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /home/hugo/bin/myApp/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /home/hugo/bin/myApp/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /home/hugo/bin/myApp/platforms/android/CordovaLib/ant-build/build.prop
-post-build:
debug:
-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] Generating resource IDs...
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.
-pre-compile:
[echo] Set jars path to: /home/hugo/ant-build/myApp/platforms/android/CordovaLib/ant-build/classes.jar
-compile:
[javac] Compiling 5 source files to /home/hugo/bin/myApp/platforms/android/ant-build/classes
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:3: error: cannot find symbol
[javac] import org.apache.cordova.CallbackContext;
[javac] ^
[javac] symbol: class CallbackContext
[javac] location: package org.apache.cordova
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:4: error: cannot find symbol
[javac] import org.apache.cordova.CordovaInterface;
[javac] ^
[javac] symbol: class CordovaInterface
[javac] location: package org.apache.cordova
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:5: error: cannot find symbol
[javac] import org.apache.cordova.CordovaPlugin;
[javac] ^
[javac] symbol: class CordovaPlugin
[javac] location: package org.apache.cordova
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:6: error: cannot find symbol
[javac] import org.apache.cordova.CordovaWebView;
[javac] ^
[javac] symbol: class CordovaWebView
[javac] location: package org.apache.cordova
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:7: error: package org.apache.cordova.PluginResult does not exist
[javac] import org.apache.cordova.PluginResult.Status;
[javac] ^
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:18: error: cannot find symbol
[javac] public class IonicKeyboard extends CordovaPlugin{
[javac] ^
[javac] symbol: class CordovaPlugin
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:20: error: cannot find symbol
[javac] public void initialize(CordovaInterface cordova, CordovaWebView webView) {
[javac] ^
[javac] symbol: class CordovaInterface
[javac] location: class IonicKeyboard
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:20: error: cannot find symbol
[javac] public void initialize(CordovaInterface cordova, CordovaWebView webView) {
[javac] ^
[javac] symbol: class CordovaWebView
[javac] location: class IonicKeyboard
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:64: error: cannot find symbol
[javac] public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
[javac] ^
[javac] symbol: class CallbackContext
[javac] location: class IonicKeyboard
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionicframework/myapp869163/CordovaApp.java:25: error: cannot find symbol
[javac] public class CordovaApp extends CordovaActivity
[javac] ^
[javac] symbol: class CordovaActivity
[javac] /home/hugo/bin/myApp/platforms/android/src/org/apache/cordova/device/Device.java:23: error: cannot find symbol
[javac] import org.apache.cordova.CordovaWebView;
[javac] ^
[javac] symbol: class CordovaWebView
[javac] location: package org.apache.cordova
[javac] /home/hugo/bin/myApp/platforms/android/src/org/apache/cordova/device/Device.java:24: error: cannot find symbol
[javac] import org.apache.cordova.CallbackContext;
[javac] ^
[javac] symbol: class CallbackContext
[javac] location: package org.apache.cordova
[javac] /home/hugo/bin/myApp/platforms/android/src/org/apache/cordova/device/Device.java:25: error: cannot find symbol
[javac] import org.apache.cordova.CordovaPlugin;
[javac] ^
[javac] symbol: class CordovaPlugin
[javac] location: package org.apache.cordova
[javac] /home/hugo/bin/myApp/platforms/android/src/org/apache/cordova/device/Device.java:26: error: cannot find symbol
[javac] import org.apache.cordova.CordovaInterface;
[javac] ^
[javac] symbol: class CordovaInterface
[javac] location: package org.apache.cordova
[javac] /home/hugo/bin/myApp/platforms/android/src/org/apache/cordova/device/Device.java:33: error: cannot find symbol
[javac] public class Device extends CordovaPlugin {
[javac] ^
[javac] symbol: class CordovaPlugin
[javac] /home/hugo/bin/myApp/platforms/android/src/org/apache/cordova/device/Device.java:56: error: cannot find symbol
[javac] public void initialize(CordovaInterface cordova, CordovaWebView webView) {
[javac] ^
[javac] symbol: class CordovaInterface
[javac] location: class Device
[javac] /home/hugo/bin/myApp/platforms/android/src/org/apache/cordova/device/Device.java:56: error: cannot find symbol
[javac] public void initialize(CordovaInterface cordova, CordovaWebView webView) {
[javac] ^
[javac] symbol: class CordovaWebView
[javac] location: class Device
[javac] /home/hugo/bin/myApp/platforms/android/src/org/apache/cordova/device/Device.java:69: error: cannot find symbol
[javac] public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
[javac] ^
[javac] symbol: class CallbackContext
[javac] location: class Device
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:21: error: cannot find symbol
[javac] super.initialize(cordova, webView);
[javac] ^
[javac] symbol: variable super
[javac] location: class IonicKeyboard
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:29: error: cannot find symbol
[javac] final CordovaWebView appView = webView;
[javac] ^
[javac] symbol: class CordovaWebView
[javac] location: class IonicKeyboard
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:69: error: cannot find symbol
[javac] InputMethodManager inputManager = (InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
[javac] ^
[javac] symbol: variable cordova
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:70: error: cannot find symbol
[javac] View v = cordova.getActivity().getCurrentFocus();
[javac] ^
[javac] symbol: variable cordova
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:66: error: cannot find symbol
[javac] cordova.getThreadPool().execute(new Runnable() {
[javac] ^
[javac] symbol: variable cordova
[javac] location: class IonicKeyboard
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:84: error: cannot find symbol
[javac] ((InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY);
[javac] ^
[javac] symbol: variable cordova
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java:82: error: cannot find symbol
[javac] cordova.getThreadPool().execute(new Runnable() {
[javac] ^
[javac] symbol: variable cordova
[javac] location: class IonicKeyboard
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionicframework/myapp869163/CordovaApp.java:30: error: cannot find symbol
[javac] super.onCreate(savedInstanceState);
[javac] ^
[javac] symbol: variable super
[javac] location: class CordovaApp
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionicframework/myapp869163/CordovaApp.java:31: error: cannot find symbol
[javac] super.init();
[javac] ^
[javac] symbol: variable super
[javac] location: class CordovaApp
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionicframework/myapp869163/CordovaApp.java:33: error: cannot find symbol
[javac] loadUrl(launchUrl);
[javac] ^
[javac] symbol: variable launchUrl
[javac] location: class CordovaApp
[javac] /home/hugo/bin/myApp/platforms/android/src/com/ionicframework/myapp869163/CordovaApp.java:27: error: method does not override or implement a method from a supertype
[javac] @Override
[javac] ^
[javac] /home/hugo/bin/myApp/platforms/android/src/org/apache/cordova/device/Device.java:57: error: cannot find symbol
[javac] super.initialize(cordova, webView);
[javac] ^
[javac] symbol: variable super
[javac] location: class Device
[javac] /home/hugo/bin/myApp/platforms/android/src/org/apache/cordova/device/Device.java:109: error: cannot find symbol
[javac] String uuid = Settings.Secure.getString(this.cordova.getActivity().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
[javac] ^
[javac] symbol: variable cordova
[javac] 31 errors
BUILD FAILED
/opt/adt-bundle-linux-x86_64-20131030/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/opt/adt-bundle-linux-x86_64-20131030/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.
Total time: 4 seconds
/home/hugo/bin/myApp/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: ant with args: debug,-f,/home/hugo/bin/myApp/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /home/hugo/bin/myApp/platforms/android/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:755:16)
at Process.ChildProcess._handle.onexit (child_process.js:822:5)
在stackoverflow上阅读类似的问题,我可以通过编辑删除4个javac编译错误
nano -w /home/hugo/bin/myApp/platforms/android/src/com/ionic/keyboard/IonicKeyboard.java
并替换
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
通过
import org.apache.cordova.*;
因为几乎所有的错误都是“找不到符号”,我猜想找到cordova包有一些问题。 我不得不通过以下方式安装cordova:
sudo npm install -g cordova
因为没有sudo我有一些EACCES错误,它可能来自那个吗?
我是否必须手动编辑大量java文件才能摆脱所有错误或者我错过了一些配置?
感谢您的建议和帮助!
答案 0 :(得分:0)
我在14.04使用ionic没有问题。有时我有类似的问题,必须通过
删除Android平台ionic platform remove android
并使用
重新添加ionic platform add android
答案 1 :(得分:0)
AppGyver的Steroids CLI与Linux兼容且works with your Ionic project直接无需修改任何文件。您可以使用配套应用程序进行开发,并使用云构建服务来创建独立构建,因此无需在本地编译。
(免责声明:我是AppGyver的程序员。)