Closed alexma01 closed 6 years ago
ok i solved problem adding in vendor.android.ts
require("app/notifications/FirebaseInstanceIDServiceCustom");
when i run
tns run android --bundle --env.uglify --env.aot --env.snapshot
its OK but when i run
tns run android --bundle --env.uglify --env.aot --env.snapshot --release ........
i have this error:
Unable to instantiate service com.tns.notifications.FirebaseInstanceIDServiceCustom: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/notifications/FirebaseInstanceIDServiceCustom'
I'm running into a similar error and found that either removing --release
OR --env.snapshot
resolves the error. Can you confirm that @alexma01 ?
Hi @Burgov , hi added a java classes into webpack.config.ts and REMOVED from vendor.android.ts
if (snapshot) {
config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({
chunk: "vendor",
projectRoot,
webpackConfig: config,
targetArchs: ["arm", "arm64", "ia32"],
tnsJavaClassesOptions: {
packages: ["tns-core-modules" ],
modules: [
'app/notifications/FirebaseInstanceIDServiceCustom.js',
'app/notifications/FirebaseMessagingServiceCustom.js',
'app/notifications/NotificationsReceiverCustom.js'
]
},
useLibs: false
}));
}
and i solved problem.
Now i can run tns run android --bundle --env.uglify --env.aot --env.snapshot --release ........
Issue Checklist
Tell us about the problem
Hi, i have this class:
and this service in AndroidManifest.xml:
but when i run tns run android --bundle i have this error:
System.err: java.lang.RuntimeException: Unable to instantiate service com.tns.notifications.FirebaseInstanceIDServiceCustom: com.tns.NativeScriptException: System.err: System.err: Error: com.tns.NativeScriptException: Failed to find module: "app/notifications/FirebaseInstanceIDServiceCustom.js", relative to: app//
in my com.tns.notifications.FirebaseInstanceIDServiceCustom.java:
Local environment
Project data
const webpack = require("webpack"); const nsWebpack = require("nativescript-dev-webpack"); const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target"); const CleanWebpackPlugin = require("clean-webpack-plugin"); const CopyWebpackPlugin = require("copy-webpack-plugin"); const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
module.exports = env => { const platform = env && (env.android && "android" || env.ios && "ios"); if (!platform) { throw new Error("You need to provide a target platform!"); }
};