Ionic-cli: native-run searching for unsigned apk while apk is already signed

Created on 23 Mar 2020  路  11Comments  路  Source: ionic-team/ionic-cli

Version:


0.3.0

Description:


This happened after I upgraded to ionic 5, angular 9 etc. (Basically a full upgrade of my npm modules, ionic modules and cordova + plugins)
While running ionic cordova run android -- device --prod --release I get an error because native-run can't find the unsigned version of my apk. As you can see below my app is being built and signed afterwards. But native-run THEN tries to look for the unsigned apk in that same directory which obviously can't be found at that moment. Debug build and even prod build are running fine but the release build won't push to device and while I can manually install the apk to my device there seems to be issues.

Command Output:

`BUILD SUCCESSFUL in 20s
43 actionable tasks: 41 executed, 2 up-to-date

C:\Users{User}\Repos{MyApp}>if "0" == "0" goto mainEnd

C:\Users{User}\Repos{MyApp}>if "Windows_NT" == "Windows_NT" endlocal
Command finished with error code 0: C:\Users{User}\Repos{MyApp}\platforms\android\gradlew cdvBuildRelease,-b,C:\Users{User}\Repos{MyApp}\platforms\android\build.gradle
Built the following apk(s):
C:\Users{User}\Repos{MyApp}\platforms\android\app\build\outputs\apk\release\app-release.apk
No scripts found for hook "after_compile".
No scripts found for hook "after_build".

native-run.cmd android --app platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk --device --verbose
[native-run] 2020-03-23T14:46:40.272Z native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_HOME
[native-run] 2020-03-23T14:46:40.277Z native-run:android:utils:sdk:resolveSDKRoot Using $ANDROID_HOME at C:\Users{User}\AppData\Local\Android\Sdk
[native-run] 2020-03-23T14:46:40.277Z native-run:android:utils:sdk:resolveEmulatorHome Looking for $ANDROID_EMULATOR_HOME
[native-run] 2020-03-23T14:46:40.277Z native-run:android:utils:sdk:resolveEmulatorHome Looking at $HOME/.android
[native-run] 2020-03-23T14:46:40.277Z native-run:android:utils:sdk:resolveEmulatorHome Using $HOME/.android/ at C:\Users{User}.android
[native-run] 2020-03-23T14:46:40.278Z native-run:android:utils:sdk:resolveAVDHome Looking for $ANDROID_AVD_HOME
[native-run] 2020-03-23T14:46:40.278Z native-run:android:utils:sdk:resolveAVDHome Looking at $HOME/.android/avd
[native-run] 2020-03-23T14:46:40.278Z native-run:android:utils:sdk:resolveAVDHome Using $HOME/.android/avd/ at C:\Users{User}.android\avd
[native-run] 2020-03-23T14:46:40.279Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users{User}\AppData\Local\Android\Sdk\platform-tools\package.xml
[native-run] 2020-03-23T14:46:40.314Z native-run:android:utils:adb:getDevices Invoking adb: 'C:\Users\{User}\AppData\Local\Android\Sdk\platform-tools\adb' [ 'devices', '-l' ]
[native-run] 2020-03-23T14:46:40.369Z native-run:android:utils:adb:parseAdbDevices Parsing adb devices from output lines: [
[native-run] 'List of devices attached',
[native-run] '290b70e17d1c7ece device product:star2ltexx model:SM_G965F device:star2lte transport_id:1',
[native-run] '',
[native-run] ''
[native-run] ]
[native-run] 2020-03-23T14:46:40.370Z native-run:android:utils:adb:getDeviceProperties Invoking adb: 'C:\Users\{User}\AppData\Local\Android\Sdk\platform-tools\adb' [ '-s',
'290b70e17d1c7ece', 'shell', 'getprop' ]
[native-run] 2020-03-23T14:46:40.490Z native-run:android:utils:adb:getDevices Found adb devices: [
[native-run] {
[native-run] serial: '{Serial}',
[native-run] state: 'device',
[native-run] type: 'hardware',
[native-run] connection: null,
[native-run] properties: {
[native-run] product: 'star2ltexx',
[native-run] model: 'SM_G965F',
[native-run] device: 'star2lte',
[native-run] transport_id: '1'
[native-run] },
[native-run] manufacturer: 'samsung',
[native-run] model: 'SM-G965F',
[native-run] product: 'star2ltexx',
[native-run] sdkVersion: '29'
[native-run] }
[native-run] ]
[native-run] Selected hardware device {Device}
[native-run] Error: ENOENT: no such file or directory, open 'C:\Users{User}\Repos{MyApp}\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk'
[native-run] 2020-03-23T14:46:40.491Z native-run:android:utils:avd:getAVDINIs Discovered AVD ini files: []
[native-run] 2020-03-23T14:46:40.503Z native-run Caught fatal error: [Error: ENOENT: no such file or directory, open 'C:\Users{User}\Repos{MyApp}\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk'] {
[native-run] errno: -4058,
[native-run] code: 'ENOENT',
[native-run] syscall: 'open',
[native-run] path: 'C:\Users\{User}\Repos\{MyApp}\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk'
[native-run] }
[ERROR] An error occurred while running subprocess native-run.

native-run.cmd android --app platforms\android\app\build\outputs\apk\release\app... exited with exit code 1.`

SDK Info:

`Ionic:

Ionic CLI : 6.3.0 (C:\Users{User}\AppData\Roaming\npm\node_modules\@ionic\cli)
Ionic Framework : @ionic/angular 5.0.5
@angular-devkit/build-angular : 0.900.7
@angular-devkit/schematics : 9.0.7
@angular/cli : 9.0.7
@ionic/angular-toolkit : 2.2.0

Cordova:

Cordova CLI : 9.0.0 ([email protected])
Cordova Platforms : android 8.1.0
Cordova Plugins : cordova-plugin-ionic-webview 4.1.3, (and 7 other plugins)

Utility:

cordova-res : 0.10.0
native-run : 0.3.0

System:

NodeJS : v12.16.1 (C:\Program Files\nodejs\node.exe)
npm : 6.14.3
OS : Windows 10`

`SDK Location: C:\Users{User}\AppData\Local\Android\Sdk
AVD Home: C:\Users{User}.android\avd

API Level: 29
Packages: Android SDK Platform 29 platforms;android-29 4
Google APIs Intel x86 Atom System Image system-images;android-29;google_apis;x86 9
Google Play Intel x86 Atom System Image system-images;android-29;google_apis_playstore;x86 8
Sources for Android 29 sources;android-29 1

API Level: 28
Packages: Android SDK Platform 28 platforms;android-28 6
Google APIs Intel x86 Atom System Image system-images;android-28;google_apis;x86 10
Google Play Intel x86 Atom System Image system-images;android-28;google_apis_playstore;x86 9
Sources for Android 28 sources;android-28 1

API Level: 19
Packages: Android SDK Platform 19 platforms;android-19 4
Sources for Android 19 sources;android-19 2

Tools:

Android Emulator emulator 30.0.0
Android SDK Build-Tools 19.1 build-tools;19.1.0 19.1.0
Android SDK Build-Tools 28.0.3 build-tools;28.0.3 28.0.3
Android SDK Build-Tools 29.0.3 build-tools;29.0.3 29.0.3
Android SDK Build-Tools 30-rc2 build-tools;30.0.0-rc2 30.0.0
Android SDK Platform-Tools platform-tools 29.0.6
SDK Patch Applier v4 patcher;v4 1`

Already tried:

  • reinstalling angular
  • reinstalling android (studio, sdk, etc.)
  • reinstalling cordova
  • reinstalling ionic
  • reinstalling cordova-android (+ plugins one at a time)

And everytime I could build I deleted my node_modules platforms, www and plugins folder.

bug

All 11 comments

This is also happening on our project. Did you find a solution for this?

This is actually an Ionic CLI bug. We need to improve this function to account for signed releases, and potentially other outputs: https://github.com/ionic-team/ionic-cli/blob/5dabc152408236973ff457f5d6cd358f6afd7dcf/packages/%40ionic/cli/src/lib/integrations/cordova/project.ts#L28-L46

Should be fixed in Ionic CLI 6.4.1--let me know! Thanks for the report!

Should be fixed in Ionic CLI 6.4.1--let me know! Thanks for the report!

Thanks alot, it worked.

This issue still appears in Ionic CLI 6.12.1

I'm running Ionic cordova run android --release

but the native run is looking for unsigned apk
Ionic Info

`Ionic:

Ionic CLI : 5.4.16
Ionic Framework : @ionic/angular 5.3.1
@angular-devkit/build-angular : 0.1002.0
@angular-devkit/schematics : 8.3.12
@angular/cli : 10.0.5
@ionic/angular-toolkit : 2.3.3

Cordova:

Cordova CLI : 10.0.0
Cordova Platforms : android 9.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 3.1.2, (and 19 other plugins)

Utility:

cordova-res : not installed
native-run : 1.2.2

System:

NodeJS : v12.19.0 (C:\Program Files\nodejs\node.exe)
npm : 6.14.8
OS : Windows 10`

@omkarachary could you post the contents of platforms/android/app/build/outputs/apk/debug/output.json? or output-metadata.json if it exists

Yes Please find the output.json file contents

{
  "version": 1,
  "artifactType": {
    "type": "APK",
    "kind": "Directory"
  },
  "applicationId": "com.Hlt.learnerapp",
  "variantName": "release",
  "elements": [
    {
      "type": "SINGLE",
      "filters": [],
      "properties": [],
      "versionCode": 200106,
      "versionName": "200106",
      "enabled": true,
      "outputFile": "app-release.apk"
    }
  ]
}

@omkarachary I just noticed you're using a very old version of Ionic CLI. Update it and see if you still have the issue.

I did upgrade with npm i @ionic/cli -g

But my Ionic info still shows same info

`
Ionic:

Ionic CLI : 5.4.16
Ionic Framework : @ionic/angular 5.3.1
@angular-devkit/build-angular : 0.1002.0
@angular-devkit/schematics : 8.3.12
@angular/cli : 10.0.5
@ionic/angular-toolkit : 2.3.3

Cordova:

Cordova CLI : 10.0.0
Cordova Platforms : android 9.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 3.1.2, (and 20 other plugins)

Utility:

cordova-res : not installed
native-run : 1.2.2

System:

NodeJS : v12.19.0 (C:\Program Files\nodejs\node.exe)
npm : 6.14.8
OS : Windows 10`

@dwieeb I updated the Cli version multiple times but the ionic info shows Ionic CLI : 5.4.16
But if i checked in package.json and the file structure the version is very recent

Please help Im stuck

Thanks for the support everyone there was an ionic folder in Nodemodules folder referring to very old version of @ionic/CLi(previously called as just ionic) after deleting it. Ionic started referencing from the global 6.12 version.

Appreciate your help @dwieeb @wellwoller

Was this page helpful?
0 / 5 - 0 ratings