Open dpdragnev opened 3 years ago
I have the same problem. The v7 docs also seem to be incorrect / outdated.
tns clean
was the main solution for me. It seems like there are other issues I needed to workaround.
Here is my webpack.config.js:
const webpack = require('@nativescript/webpack')
const { resolve } = require('node:path')
module.exports = env => {
env.appComponents = [
'@nativescript/core/ui/frame',
'@nativescript/core/ui/frame/activity',
resolve(__dirname, 'app/activity.android')
]
webpack.init(env)
// Learn how to customize:
// https://docs.nativescript.org/webpack
const config = webpack.resolveConfig()
config.entry = {
...config.entry,
application: resolve(__dirname, 'app/application.android')
}
return config
}
NativeClass()
should possibly be added above the @JavaProxy
line in the activity and application .android.ts files.
And there were some type issues with the activity.android.ts code in the docs. Here are the changes I made:
public isNativeScriptActivity: boolean = false;
private _callbacks!: AndroidActivityCallbacks;
// I changed `undefined` to `() => {}` here
this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, () => {}/*TODO: Enable if needed*/);
Not sure if you are looking at the latest docs, but this is documented here: https://docs.nativescript.org/guide/extending-classes-and-implementing-interfaces-android#extending-android-application
Not sure if you are looking at the latest docs, but this is documented here: https://docs.nativescript.org/guide/extending-classes-and-implementing-interfaces-android#extending-android-application
You're right! It seems like I was looking at old docs after all. I thought I had specifically checked this and clicked to view the latest, but I must have messed it up somehow.
I am using NS 6.5 Core and I am following the example from https://v6.docs.nativescript.org/core-concepts/android-runtime/advanced-topics/extend-application-activity#extending-activity.
I have cleaned up my project, deleting the platforms, hooks, and node_modules folders. When I build the app, I get the following error: Class "org.myApp.MainActivity" not found.
Here is my code:
activity.android.ts:
webpack.config.js:
AndroidManifest.xml:
Any suggestions on how to proceed?