Custom extended Activity not working on Nativescript 7 - nativescript

Months before, same code worked fine and I was able to start custom activity (and custom application) but I don't know what happened.
I tried on new projects to reproduce steps but I always get the same error:
Unable to create application com.tns.NativeScriptApplication:
com.tns.NativeScriptException: Error calling module function
System.err: Error:
com.tns.system.classes.loading.LookedUpClassNotFound: Class
"a.b.NativeScriptActivity" not found. System.err: File:
(/data/data/org.nativescript.testing/files/internal/ts_helpers.js:154:25)
System.err: System.err: StackTrace: System.err:
(/data/data/org.nativescript.testing/files/internal/ts_helpers.js:154:26)
System.err: at
__decorate(/data/data/org.nativescript.testing/files/internal/ts_helpers.js:13:19)
System.err: at ./app/core/android/activity.ts(file:
src/app/core/android/activity.android.ts:5:25)...
Activity ts file is activity.android.ts.
I put on JavaProxy decorator "a.b.NativeScriptActivity". Same on Android Maifest.
Also added entry on AppComponents array on webpack.config.js
UPDATE: I gave up with Nativescript a long time ago (moved to Flutter).

For Nativescript 7 you must add following decorator :
#NativeClass()
example:
#NativeClass()
#JavaProxy("com.lanmis.app.BackgroundJobService")
class BackgroundService extends android.app.job.JobService {
}
In nativescript 6 :
The first solution :
If importHelpers: true exists in tsconfig.json you must change it to :
importHelpers: false
The second solution :
Instead of following block :
#JavaProxy("com.lanmis.app.BackgroundJobService")
class BackgroundService extends android.app.job.JobService {
//Code
}
Use :
android.app.job.JobService.extend("com.lanmis.app.BackgroundJobService", {
//Code
})

Lookedup class error occurs due to the activity path issue...check your webpack file for
If appPath ="src" ,
const appComponents = [
resolve(__dirname, "src/app/activity.android.ts")
]
or
If appPath appPath = "app"
const appComponents = [
resolve(__dirname, "app/activity.android.ts")
]

Related

Run Time Error: perhaps its code was not linked in, or the class wasn't registered with Register_Class()/Define_Module()/Define_Channel()?

I have already declared Define_Module(veins:: TraCIDateDissemination) and go through with various suggestions provided but getting this error again. Any suggestion is welcome. please help.
How to register a new class (new application) in Omnet++
Error in module during network setup:
Class "simpleModule" not found in omnetpp
https://doc.omnetpp.org/omnetpp/manual/
In manual I checked -
7.12.3 Class Registration
You should also use the Register_Class() macro to register the new class. It is used by the createOne() factory function, which can create any object given the class name as a string. createOne() is used by the Envir library to implement omnetpp.ini options such as rng-class="..." or scheduler-class="...". (see Chapter [17])
But not able to understand. pls help.
A runtime error occurred:
Class "TraCIDataDissemination" not found -- perhaps its code was not linked in, or the class wasn't registered with Register_Class(), or in the case of modules and channels, with Define_Module()/Define_Channel() -- in module (omnetpp::cModule) RSUExampleScenario.node[0] (id=13), at t=1s, event #2
Launch a debugger with the following command?
nemiver --attach=20070 &
OMNET.INI
##########################################################
# App Layer #
##########################################################
#*.node[*].applType = "TraCIDemo11p"
*.node[*].applType = "TraCIDataDissemination"
*.node[*].appl.headerLength = 80 bit
TraCIDataDissemination.h
namespace veins {
class TraCIDataDissemination : public DemoBaseApplLayer {
public:
{
//my code
}
}
TraCIDataDissemination.cc
#include "veins/modules/application/traci/TraCIDataDissemination.h"
#include<math.h>
using namespace veins;
Define_Module(veins::TraCIDataDissemination);
//code
TraCIDataDissemination.ned
package org.car2x.veins.modules.application.traci;
import org.car2x.veins.modules.application.ieee80211p.DemoBaseApplLayer;
simple TraCIDataDissemination extends DemoBaseApplLayer
{
#class(TraCIDataDissemination);
#display("i=block/app2");
}
Please Help!!

NativeScript & SocketIO: Can't find variable: SocketManager

I'm trying to integrate Backendless JS-SDK into the NativeScript application.
The JS-SDK is dependent on socket.io.client module which is not supported in the NS environment.
So, the first problem with the socket.io.client module I've solved by adding an alias in the custom webpack.json
const webpackConfig = require("./webpack.config");
module.exports = (env) => {
env = env || {};
env.alias = Object.assign({}, env.alias, {
'socket.io-client': 'nativescript-socketio'
});
return webpackConfig(env);
}
but after that, I started receiving another error: Object is not a function (near '...io...')
and I tried to change initializing SocketIO instance as it described here nativescript-socket.io
and now I get another error: Can't find variable: SocketManager, after some investigation I found the code line where the error comes from, ``:
socketio.ios.js#130
Has anybody got this error?
Thanks in advance for any help!

NativeView catches Exception: TypeError after returning back to the app

I have a function inside my Component_1 :
methods: {
interactBoxToggel () {
let page = this.$refs.Home.nativeView;
let interactBox = page.getViewById( 'interactBox' );
console.log( interactBox );
}
} ,
mounted () {
bus.$on( 'interactBoxToggel' , this.interactBoxToggel )
}
It always work if it triggered from inside Component_1,
Now I port it to the Component_2:
methods: {
buttonCotrol( buttonName ) {
bus.$emit( 'interactBoxToggel' );
console.log(buttonName);
}
}
It works too, but if I exit the app by "swipe to close" (Android 9 Fullscreen Gesture) and come back again to the app and call it from inside Component_2, I will get error:
System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onTouch failed
System.err: TypeError: Cannot read property 'nativeView' of undefined
System.err:
...
Why this happens? How can I solve it?
You are adding event listener every time on mounted callback. When app is closed the component will be destroyed and mounted again on resume, so you will have 2 active listeners but only one will be valid for the session. As many times you close and open, you will have as many listeners added.
You must remove the listener when it's destroyed.
destroyed() {
bus.$off("interactBoxToggel", this.interactBoxToggel);
}

Error in executing the Xamarin.UITest for some reason

I am trying to do UI Testing using the Xamarin.UITest framework. I am trying to follow the procedure using the links that is given on their website.The application is named 'CreditCardValidator'. I downloaded the app and then did stuffs like upgrading the UITest package and not the NUnit package. As the tutorial mentions that the code that is to be mentioned is
using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
using Xamarin.UITest;
using Xamarin.UITest.iOS;
using Xamarin.UITest.Queries;
namespace CreditCardValidator.iOS.UITests
{
[TestFixture]
public class Tests
{
iOSApp app;
[SetUp]
public void BeforeEachTest()
{
Console.WriteLine ("Starting the function");
app = ConfigureApp.iOS.StartApp();
// app = ConfigureApp.iOS.AppBundle("/Users/admin/Library/Developer/CoreSimulator/Devices/57DBB268-714A-473F-A7D3-C3B4BB2BB138/data/Containers/Bundle/Application/A9151B5D-7B9C-4F9A-9EF2-F153AC994170").StartApp();
Console.WriteLine ("ending the function ");
}
[Test]
public void CreditCardNumber_TooShort_DisplayErrorMessage()
{
Console.WriteLine ("Starting the function");
app.WaitForElement(c=>c.Class("UINavigationBar").Marked("Simple Credit Card Validator"));
app.EnterText(c=>c.Class("UITextField"), new string('9', 15));
Console.WriteLine ("ending the function ");
}
}
}
MY PROBLEM :
The simulator is not opening and the tests are failing for no reason. The StartApp() functions documentation says that it LAUNCHES the app on the simulator. The error I am getting in the Test Results pad is
SetUp : System.NullReferenceException : Object reference not set to an instance of an object
They are failing at the line : app = ConfigureApp.iOS.StartApp();
I tried to replace this line with the compiled version of the app which is commented out in the code. But for that still the simulator is not opening and the error I am getting is
SetUp : System.Exception : App bundle directory doesn't contain a valid app bundle. Still the error is at the Startup function line
MORE INFO : In the second attempt I found that my .app file has a 'STOP' image on it. Could this be the reason ?
Please ask if more information is required.

Warning include TestCase phpunit in Magento project

I'm using phpunit for testing in a magento's project.
The issues is that I got this directory inside magento:
magento/
-tests/
--integration/bootstrap.php
---Training/
----Example/
-----Helper/DataTest.php
So, I got a bootstrap.php, inside this file I turn off warnings for my testing:
require_once __DIR__ . '/../../app/Mage.php';
Mage::setIsDeveloperMode(true);
Mage::app();
$handler = set_error_handler(function () {});
set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($handler)
{
if (E_WARNING === $errno
&& 0 === strpos($errstr, 'include(')
&& substr($errfile, -19) == 'Varien/Autoload.php'
) {
return null;
}
return call_user_func($handler, $errno, $errstr, $errfile, $errline);
});
If this code is inside of DataTest.php inside the function setUpBeforeClass(), everything is ok, but when I create bootstrap.php and execute in console:
phpunit --bootstrap tests/integration/bootstrap.php tests/integration/
I got the following answer:
Fatal error: Uncaught exception 'Exception' with message 'Warning: include(PHPUnit\Extensions\Story\TestCase.php): failed to open stream: No such file or directory in C:\wamp\www\magento\lib\Varien\Autoload.php on line 94' in C:\wamp\www\magento\app\code\core\Mage\Core\functions.php on line 245
Exception: Warning: include(PHPUnit\Extensions\Story\TestCase.php): failed to open stream: No such file or directory in C:\wamp\www\magento\lib\Varien\Autoload.php on line 94 in C:\wamp\www\magento\app\code\core\Mage\Core\functions.php on line 245
I got phpunit in my local server in bin\php\php5.5.12 (in Windows) and I can access in any directory.
So, I don't understand what's going on... because I do not need to modify the core of magento to disable warnings.
Someone can help me to understand?
Thanks for all!!
:)
Your autoloader is trying to load classes it is not responsible for.

Resources