Blank App not working on Android device - ERR: Uncaught reflect-metadata shim is required when using class decorators

Facing the same problem on my app but thought it may be because of some plugin etc.; but was able to simulate the same on blank starter app.
Here are details:

  1. System Info:
    _Dhavals-MacBook-Pro:testingReflectErr dhavalpersonal$ ionic info

Your system information:

Cordova CLI: 6.1.1
Ionic Framework Version: 2.0.0-beta.11
Ionic CLI Version: 2.0.0-beta.37
Ionic App Lib Version: 2.0.0-beta.20
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Mac OS X Yosemite
Node Version: v5.10.1
_Xcode version: Xcode 5.1 Build version 5B130a _

******************************************************
_ Dependency warning - for the CLI to run correctly, _
_ it is highly recommended to install/upgrade the following: _

_ Install ios-sim to deploy iOS applications.npm install -g ios-sim (may require sudo)_
_ Install ios-deploy to deploy iOS applications to devices. npm install -g ios-deploy (may require sudo)_

******************************************************
Dhavals-MacBook-Pro:testingReflectErr dhavalpersonal$_

  1. Steps that i performed:
    Dhavals-MacBook-Pro:Sample_Projects dhavalpersonal$ ionic start testingReflectErr blank --v2 --ts
    Creating Ionic app in folder /Users/dhavalpersonal/Sample_Projects/testingReflectErr based on blank project
    Downloading: https://github.com/driftyco/ionic2-app-base/archive/master.zip
    [=============================] 100% 0.0s
    Downloading: https://github.com/driftyco/ionic2-starter-blank/archive/master.zip
    [=============================] 100% 0.0s
    Installing npm packages…

Adding initial native plugins
[=============================] 100% 0.0s

Adding in iOS application by default
add to body class: platform-ios
Saving your Ionic app state of platforms and plugins
Saved platform
Saved plugins
Saved package.json

♬ ♫ ♬ ♫ Your Ionic app is ready to go! ♬ ♫ ♬ ♫

  1. Trying to run on device with

Dhavals-MacBook-Pro:testingReflectErr dhavalpersonal$ ionic run android -l -c -s
Running ‘run:before’ gulp task before run
[21:11:03] Starting ‘clean’…
[21:11:03] Finished ‘clean’ after 9.97 ms
[21:11:03] Starting ‘watch’…
[21:11:03] Starting ‘sass’…
[21:11:03] Starting ‘html’…
[21:11:03] Starting ‘fonts’…
[21:11:03] Starting ‘scripts’…
[21:11:04] Finished ‘html’ after 135 ms
[21:11:04] Finished ‘scripts’ after 642 ms
[21:11:04] Finished ‘fonts’ after 749 ms
[21:11:08] Finished ‘sass’ after 4.55 s
9.1 MB bytes written (9.07 seconds)
[21:11:28] Finished ‘watch’ after 25 s
[21:11:28] Starting ‘run:before’…
[21:11:28] Finished ‘run:before’ after 15 μs
• You’re trying to build for android but don’t have the platform installed yet.
∆ Installing android for you.
√ Installed platform android
Setup Live Reload


BUILD SUCCESSFUL
Total time: 26.747 secs
Built the following apk(s): _
_ /Users/dhavalpersonal/Sample_Projects/testingReflectErr/platforms/android/build/outputs/apk/android-debug.apk

Using apk: /Users/dhavalpersonal/Sample_Projects/testingReflectErr/platforms/android/build/outputs/apk/android-debug.apk
LAUNCH SUCCESS
Ionic server commands, enter:
_ restart or r to restart the client app from the root_
_ goto or g and a url to have the app navigate to the given url_
_ consolelogs or c to enable/disable console log output_
_ serverlogs or s to enable/disable server log output_
_ quit or q to shutdown the server and exit_
0 337331 error Uncaught TypeError: Cannot read property ‘6’ of undefined, http://192.168.1.5:8100/build/js/Reflect.js, Line: 894
1 338592 error Uncaught reflect-metadata shim is required when using class decorators, http://192.168.1.5:8100/build/js/app.bundle.js, Line: 36710

The App (both blank & my build) works on browser (chrome & safari)

Any help/pointer appreciated

Regards
Dhaval Shah

Snippet of Reflect.js:

876 function FillRandomBytes(buffer, size) {
877 for (var i = 0; i < size; ++i)
878 buffer[i] = Math.random() * 0xff | 0;
879 return buffer;
880 }
881 function GenRandomBytes(size) {
882 if (typeof Uint8Array === “function”) {
883 if (typeof crypto !== “undefined”)
884 return crypto.getRandomValues(new Uint8Array(size));
885 if (typeof msCrypto !== “undefined”)
886 return msCrypto.getRandomValues(new Uint8Array(size));
887 return FillRandomBytes(new Uint8Array(size), size);
888 }
889 return FillRandomBytes(new Array(size), size);
890 }
891 function CreateUUID() {
892 var data = GenRandomBytes(UUID_SIZE);
893 // mark as random - RFC 4122 § 4.4
894 data[6] = data[6] & 0x4f | 0x40;
895 data[8] = data[8] & 0xbf | 0x80;
896 var result = “”;
897 for (var offset = 0; offset < UUID_SIZE; ++offset) {
898 var byte = data[offset];
899 if (offset === 4 || offset === 6 || offset === 8)
900 result += “-”;
901 if (byte < 16)
902 result += “0”;
903 result += byte.toString(16).toLowerCase();
904 }
905 return result;
906 }

Seems GenRandomBytes is not returning the data

Also snippet of app.bundle.js
36704 exports.Class = Class;
36705 var Reflect = lang_1.global.Reflect;
36706 // Throw statement at top-level is disallowed by closure compiler in ES6 input.
36707 // Wrap in an IIFE as a work-around.
36708 (function checkReflect() {
36709 if (!(Reflect && Reflect.getMetadata)) {
36710 throw ‘reflect-metadata shim is required when using class decorators’;
36711 }
36712 })();

Rgds
Dhaval Shah

Downgrading reflect-metadata to 0.1.5 helped me.

1 Like

Thanks vasiluy_kondr, I downgrade to reflect-metadata 0.1.5 and it works now.