当前位置: 首页 > 知识库问答 >
问题:

离子运行Android似乎可以工作,但是应用程序没有在手机上启动,为什么?

秦阳旭
2023-03-14

我的手机已打开并处于调试模式,我已经使用adb设备-l确认了这一点。当我运行ionic run android时,我得到的输出如下,Ionic声称应用程序已启动,但手机上什么也没发生。我使用的是带有android 4.4.4的Nexus 5。

$ ionic run android
add to body class: platform-android
Running command: /Users/kristoffer/web/photoApp/platforms/android/cordova/run 
Buildfile: /Users/kristoffer/web/photoApp/platforms/android/build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 22.6.2
 [checkenv] Installed at /Development/adt-bundle/sdk

-setup:
     [echo] Project Name: KvittoScanner
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 19.0.3
     [echo] Resolving Build Target for KvittoScanner...
[gettarget] Project Target:   Android 4.4.2
[gettarget] API level:        19
     [echo] ----------
     [echo] Creating output directories if needed...
     [echo] ----------
     [echo] Resolving Dependencies for KvittoScanner...
[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 22.6.2
 [checkenv] Installed at /Development/adt-bundle/sdk

-setup:
     [echo] Project Name: CordovaLib
  [gettype] Project Type: Android Library

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 19.0.3
     [echo] Resolving Build Target for CordovaLib...
[gettarget] Project Target:   Android 4.4.2
[gettarget] API level:        19
     [echo] ----------
     [echo] Creating output directories if needed...
     [echo] ----------
     [echo] Resolving Dependencies for CordovaLib...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency] 
[dependency] ------------------

-code-gen:
[mergemanifest] Found Deleted Target File
[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] Found modified input file
     [aapt] Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] No need to generate new BuildConfig.

-pre-compile:

-compile:
     [echo] Creating library output jar file...

-post-compile:

-obfuscate:

-dex:
     [echo] Library project: do not convert bytecode...

-crunch:
   [crunch] Crunching PNG Files in source dir: /Users/kristoffer/web/photoApp/platforms/android/CordovaLib/res
   [crunch] To destination dir: /Users/kristoffer/web/photoApp/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] Updating property file: /Users/kristoffer/web/photoApp/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /Users/kristoffer/web/photoApp/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /Users/kristoffer/web/photoApp/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: 

    /Users/kristoffer/web/photoApp/platforms/android/CordovaLib/ant-build/build.prop

    -post-build:

    debug:

    -code-gen:
    [mergemanifest] Found Deleted Target File
    [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] Found modified input file
         [aapt] Generating resource IDs...
         [echo] ----------
         [echo] Handling BuildConfig class...
    [buildconfig] No need to generate new BuildConfig.

    -pre-compile:
         [echo] Set jars path to: /Users/kristoffer/web/photoApp/platforms/android/CordovaLib/ant-build/classes.jar

    -compile:
        [javac] Compiling 2 source files to /Users/kristoffer/web/photoApp/platforms/android/ant-build/classes

    -post-compile:

    -obfuscate:

    -dex:
          [dex] input: /Users/kristoffer/web/photoApp/platforms/android/ant-build/classes
          [dex] input: /Users/kristoffer/web/photoApp/platforms/android/CordovaLib/ant-build/classes.jar
          [dex] Using Pre-Dexed classes-d889c6bd0911025d0e9120cf57234197.jar <- /Users/kristoffer/web/photoApp/platforms/android/CordovaLib/ant-build/classes.jar
          [dex] Found modified input file
          [dex] Converting compiled files and external libraries into /Users/kristoffer/web/photoApp/platforms/android/ant-build/classes.dex...
           [dx] Merged dex A (14 defs/28.2KiB) with dex B (206 defs/314.1KiB). Result is 220 defs/415.6KiB. Took 0.3s

    -crunch:
       [crunch] Crunching PNG Files in source dir: /Users/kristoffer/web/photoApp/platforms/android/res
       [crunch] To destination dir: /Users/kristoffer/web/photoApp/platforms/android/ant-build/res
       [crunch] Crunched 0 PNG files to update cache

    -package-resources:
         [aapt] Found modified input file
         [aapt] Creating full resource package...
         [aapt]     (skipping file '.bower.json' due to ANDROID_AAPT_IGNORE pattern '.*')
         [aapt]     (skipping file '.bower.json' due to ANDROID_AAPT_IGNORE pattern '.*')
         [aapt]     (skipping file '.bower.json' due to ANDROID_AAPT_IGNORE pattern '.*')
         [aapt]     (skipping file '.bower.json' due to ANDROID_AAPT_IGNORE pattern '.*')
         [aapt]     (skipping file '.bower.json' due to ANDROID_AAPT_IGNORE pattern '.*')
         [aapt] Warning: AndroidManifest.xml already defines debuggable (in http://schemas.android.com/apk/res/android); using existing value in manifest.

    -package:
    [apkbuilder] Found modified input file
    [apkbuilder] Creating KvittoScanner-debug-unaligned.apk and signing it with a debug key...

    -post-package:

    -do-debug:
     [zipalign] Running zip align on final apk...
         [echo] Debug Package: /Users/kristoffer/web/photoApp/platforms/android/ant-build/KvittoScanner-debug.apk
    [propertyfile] Updating property file: /Users/kristoffer/web/photoApp/platforms/android/ant-build/build.prop
    [propertyfile] Updating property file: /Users/kristoffer/web/photoApp/platforms/android/ant-build/build.prop
    [propertyfile] Updating property file: /Users/kristoffer/web/photoApp/platforms/android/ant-build/build.prop
    [propertyfile] Updating property file: /Users/kristoffer/web/photoApp/platforms/android/ant-build/build.prop

    -post-build:
         [move] Moving 1 file to /Users/kristoffer/web/photoApp/platforms/android/ant-build
         [move] Moving 1 file to /Users/kristoffer/web/photoApp/platforms/android/CordovaLib/ant-build

    debug:

    BUILD SUCCESSFUL
    Total time: 5 seconds
    WARNING : No target specified, deploying to device '05f2fdad3444ea60'.
    Using apk: /Users/kristoffer/web/photoApp/platforms/android/ant-build/KvittoScanner-debug-unaligned.apk
    Installing app on device...
    Launching application...
    LAUNCH SUCCESS

index.html在android应用程序:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <!-- ngCordova -->
    <script src="lib/ng-cordova.min.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/services.js"></script>
  </head>
  <body ng-app="starter" animation="slide-left-right-ios7" class="platform-android platform-cordova platform-webview">
    <!-- 
      The nav bar that will be updated as we navigate between views.
    -->
    <ion-nav-bar class="bar-stable nav-title-slide-ios7">
      <ion-nav-back-button class="button-icon icon  ion-ios7-arrow-back">
        Back
      </ion-nav-back-button>
    </ion-nav-bar>
    <!-- 
      The views will be rendered in the <ion-nav-view> directive below
      Templates are in the /templates folder (but you could also
      have templates inline in this html file if you'd like).
    -->
    <ion-nav-view></ion-nav-view>
  </body>
</html>

共有3个答案

后焕
2023-03-14

不久前我也遇到过同样的问题。原因是我在www/文件夹中的源文件没有cordova.js包含在index.html.如果有人遇到这个问题,请确保在源文件中添加cordova.js,例如

<script src="cordova.js"></script>
施靖
2023-03-14

尝试禁用计算机上的防火墙。它为我工作,我有和你一样的配置

何涵畅
2023-03-14

键入ionic info并检查您安装的Cordova版本。如果您的v5.0.0现在需要一个新插件,否则所有http请求都会被阻止。

最近,cordova发布了cordova-android 4.0和最新版本的cordova-cli。默认情况下,cordova android中的更改会阻止任何http请求。关于这个问题已经有一些帖子了。要解决这个问题,您只需添加cordova白名单插件。离子插件添加cordova插件白名单https://github.com/apache/cordova-plugin-whitelist
参见参考:https://forum.ionicframework.com/t/build-proccess-changed-and-now-cannot-call-to-api/25103

快乐的黑客:)

 类似资料:
  • 问题内容: 我正在尝试构建一个android应用程序,此应用程序的主要功能之一是使其能够在手机启动时自动启动活动,我在手机上看到一些应用程序已经执行了此操作,因此任何帮助都将非常有用。我可以至少通过sdk对此进行更好的研究,谢谢! 问题答案: 您需要像这样实现BroadCastreceiver: 在清单中添加以下内容: 添加权限:

  • 编辑3:添加包含错误的代码的一部分 编辑4:更多代码。下面是onCreate()方法。对checkForNewBooking()方法的调用来自于此。

  • 我的应用程序在emulator上运行得很好,但当我导出后在我的智能手机(galaxy s3)上运行它时,它会在这个活动中崩溃,因为有HTTP连接!问题出在哪里?代码还是导出?当我点击连接按钮时,它崩溃了。

  • 因此,正如一个人在之前的帖子中所说的,我会使用: 包括行末的“我的文件”。 由于未使用,我想我应该在标准输出中接收操作的结果。然后执行它并获得(注意,我使用而不是只是为了查看是否可以根据需要修改文件,因为在本例中,文件已经有了所需的行): 所以如您所见,文件没有更改。我做错了什么? 感谢阅读

  • 我正试图在我的测试环境中部署一个基于3个节点的: 1个名称节点(主节点:172.30.10.64) 2个数据节点(slave1:172.30.10.72和slave2:172.30.10.62) 我在namenode中配置了主属性文件,在datananodes中配置了从属性文件。 主持人: hdfs站点。xml: 核心站点。xml: yarn-site.xml: mapred-site.xml:

  • 我创建了一个openjdk-11高山docker映像并将我的jar复制到其中。我的Dockerfile是这样的: 如果我运行: 然后 但如果: 然后我可以直接在shell中执行: 而且有效。 为什么作为ENTRYPOINT运行会使libjli.so库阴影并尝试重新定位JLI*?