2017-12-27 622 views
1

我正在嘗試用離子建立APK文件。我已經遵守了所有教程和一切正常,直到我試圖用這個命令來生成APK:你好我正在使用離子科爾多瓦

$ ionic cordova build --release android 

,並告訴我這個錯誤 如何解決這一問題? 請幫助

$ ionic cordova build --release android 
    Running app-scripts build: --platform android --target cordova 
    [22:57:28] build dev started ... 
    [22:57:28] clean started ... 
    [22:57:28] clean finished in 9 ms 
    [22:57:28] copy started ... 
    [22:57:30] deeplinks started ... 
    [22:57:31] deeplinks finished in 416 ms 
    [22:57:31] transpile started ... 
    [22:57:38] transpile finished in 7.50 s 
    [22:57:38] preprocess started ... 
    [22:57:38] preprocess finished in less than 1 ms 
    [22:57:38] webpack started ... 
    [22:57:40] copy finished in 11.79 s 
    [22:57:57] webpack finished in 18.34 s 
    [22:57:57] sass started ... 
    [22:57:59] sass finished in 2.21 s 
    [22:57:59] postprocess started ... 
    [22:57:59] postprocess finished in 17 ms 
    [22:57:59] lint started ... 
    [22:57:59] build dev finished in 30.98 s 
    > cordova build android --release 

You have been opted out of telemetry. To change this, run: cordova telemetry on. 
Android Studio project detected 

(node:7784) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'variables' of undefined 
(node:7784) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 

[22:58:05] tslint: ...der (8)/App Source Code/App Source Code/src/providers/shared-data/shared-data.ts, line: 71 
      Property 'push' is declared but never used. 

     L70: public events: Events, 
     L71: private push: Push, 
     L72: public platform: Platform, 

[22:58:05] tslint: ...der (8)/App Source Code/App Source Code/src/providers/shared-data/shared-data.ts, line: 8 
      'PushObject' is declared but never used. 

     L7: import { LoadingProvider } from '../loading/loading'; 
     L8: import { Push, PushObject, PushOptions } from '@ionic-native/push'; 
     L9: import { Device } from '@ionic-native/device'; 

[22:58:05] tslint: ...der (8)/App Source Code/App Source Code/src/providers/shared-data/shared-data.ts, line: 8 
      'PushOptions' is declared but never used. 

     L7: import { LoadingProvider } from '../loading/loading'; 
     L8: import { Push, PushObject, PushOptions } from '@ionic-native/push'; 
     L9: import { Device } from '@ionic-native/device'; 

[22:58:05] tslint: ...der (8)/App Source Code/App Source Code/src/providers/shared-data/shared-data.ts, line: 10 
      All imports are unused. 

     L9: import { Device } from '@ionic-native/device'; 
     L10: import { Facebook } from '@ionic-native/facebook'; 
     L11: import { FCM } from '@ionic-native/fcm'; 

[22:58:05] tslint: ...zm/Desktop/New folder (8)/App Source Code/App Source Code/src/pages/cart/cart.ts, line: 44 
      Property 'storage' is declared but never used. 

     L43: public toast: Toast, 
     L44: private storage: Storage, 
     L45: public events: Events, 

[22:58:05] tslint: ...op/New folder (8)/App Source Code/App Source Code/src/pages/products/products.ts, line: 8 
      All imports are unused. 

     L7: import { TranslateService } from '@ngx-translate/core'; 
     L8: import { share } from 'rxjs/operator/share'; 
     L9: import { CartPage } from '../cart/cart'; 

[22:58:05] lint finished in 6.59 s 

回答

0

構建應用程序比它的服務不同。這是更嚴格的原因,你的應用程序需要尊重你的目標平臺的規範。 所以,你必須糾正你在日誌中看到(如刪除一些變量或進口你的錯誤,你不使用,例如:

`import { Device } from '@ionic-native/device';` 

編輯: 你有未使用的導入雖然它不是。一個錯誤,這是一個錯誤,所以當建立你的應用程序時,你不應該這樣做 你也有一些未使用的私有變量所以請刪除它們 只要閱讀日誌,你就會知道錯誤的位置&什麼刪除。

+0

你怎麼樣n:所以你要麼必須糾正你在日誌中看到的錯誤(例如刪除一些變量或者你沒有使用的導入 - 我給你寫代碼如何糾正錯誤? –

+0

當我刪除此代碼顯示我錯誤您已選擇退出遙測。要更改此設置,請運行:cordova telemetry on。 檢測到Android Studio項目 (節點:9804)UnhandledPromiseRejectionWarning:未處理的承諾拒絕(拒絕ID:1):TypeError:無法讀取未定義的屬性變量 (節點:9804)[DEP0018]棄用警告:不建議使用未處理的承諾拒絕。將來,未處理的承諾拒絕將以非零退出代碼終止Node.js進程。 [01:23:06]皮棉在69.58秒完成 –

+0

是的,我剛剛注意到了。在你的代碼中的某個地方,你有一個未定義的對象,你試圖訪問那個未定義對象的變量。我無法幫助你,你需要再次研究你的代碼。這就是爲什麼強烈建議中/大型應用程序進行測試的原因。 – Melchia