Please Fixed this Error

167 views
Skip to first unread message

Soni Kumari

unread,
May 1, 2025, 4:13:42 AMMay 1
to DroidScript
I have just purchased DS premium 
And write code the code work full on DS Environment 
I'm using latest DS 5.77 and I also tried 2.76 latest apkbuilder as well.
But when I build apk then show black and show
Web page not available
The web page at http://127.0.0.1:3033/_main_.html could not be loaded because:

net::ERR_CACHE_MISS

And when I run the code on DS ENVIRONMENT then work fully
Here are my codes:
Main.js

// MainApp.js

var svc = null, txtStatus = null; // Service handle and text control

function OnStart() {
    // Create a vertical layout to hold controls.
    var lay = app.CreateLayout("linear", "VCenter,FillXY");

    // Create a Text control to display messages from the service.
    txtStatus = app.CreateText("Waiting for service message...", 0.8, 0.1);
    lay.AddChild(txtStatus);

    // Create a button to send the "change" message to the service.
    var btnChange = app.CreateButton("Send 'change'", 0.6, 0.1);
    btnChange.SetOnTouch(btnChange_OnTouch);
    lay.AddChild(btnChange);

    // Create a button to stop the service.
    var btnStop = app.CreateButton("Stop Service", 0.6, 0.1);
    btnStop.SetOnTouch(btnStop_OnTouch);
    lay.AddChild(btnStop);

    // Add the layout to the app UI.
    app.AddLayout(lay);

    // Start/connect to the background service. OnServiceReady is called when ready.
    svc = app.CreateService("this", "this", OnServiceReady);

    // Register callback for messages from the service.
    svc.SetOnMessage(OnServiceMessage);
}

function OnServiceReady() {
    // Called when the service has started. We can show a notification if needed.
    app.ShowPopup("Service started");
}

function btnChange_OnTouch() {
    if (svc) {
        // Send the "change" message to the service.
        svc.SendMessage("change");
    }
}

function btnStop_OnTouch() {
    if (svc) {
        // Stop the background service.
        svc.Stop();
        app.ShowPopup("Service stopped");
    }
}

function OnServiceMessage(msg) {
    // Display the incoming message from the service in the text control.
    txtStatus.SetText("Service says: " + msg);
}

Service.js

// Service.js

// Global state
var g_ = {
    counter: 0,
    direction: 1,
    interval: null,
    notify: null
};

// Called when the service starts
function OnStart()
{
    // Put service in foreground (for Android 8+)
    app.SetInForeground("Counter Service", "Service is running", "", "", "high");

    // Create notification listener
    g_.notify = app.CreateNotification();
    g_.notify.SetOnNotify(notify_OnNotify);
    g_.notify.Listen();

    // Start periodic work: call DoWork every second
    g_.interval = setInterval(DoWork, 1000);
}

// Periodic task: update counter and send to main app
function DoWork()
{
    g_.counter += g_.direction;
    app.SendMessage(g_.counter);
}

// Handle messages from the main app
function OnMessage(msg)
{
    console.log("Service received message: " + msg);
    if (msg == "change") {
        // Change counting direction
        g_.direction *= -1;
    }
}

// Handle received notifications
// Parameters may be: (packageName, title, text, id) depending on implementation
function notify_OnNotify(title, text)
{
    // Show popup when a notification is received
    var message = "Notification received: " + title;
    if (text) message += " - " + text;
    app.ShowPopup(message);
}

// Clean up when service stops
function OnStop()
{
    if (g_.interval) {
        clearInterval(g_.interval);
        g_.interval = null;
    }
    if (g_.notify) {
        g_.notify.Release();
        g_.notify = null;
    }
}

Here is the errors msg:
Screenshot_2025-05-01-13-36-38-52_580f2e340988d17103de57accd4ef8da.jpg

Cemal

unread,
May 1, 2025, 11:47:03 AMMay 1
to DroidScript
I'm not sure, but it may see your project as a web page.
Create an empty Native project and try to convert it to APK. If there is no problem, copy and paste your codes into the project you just created.

Soni Kumari

unread,
May 1, 2025, 2:41:48 PMMay 1
to DroidScript
I Tried before, but when I add the notification listener code in Service.js only then happened 
I will work on DS Ide but in apk , show like that, when I remove the code notification listener from the Service.js code and build apk the run code perfectly

Soni Kumari

unread,
May 2, 2025, 4:08:43 AMMay 2
to DroidScript
Why Everyone quiet here?
It is the Droidscript forum where get solution?
Or I visited something else.
I'm currently using 2.77 DS + Premium of 1 month 

Cemal

unread,
May 2, 2025, 7:15:54 AMMay 2
to DroidScript
Using this line in the current version of DS causes it to behave like an html application:
g_.notify.Listen();
I will report this error.

You can try a workaround right now:
- g_.notify.Listen();
+ g_.notify["Listen"]();

This prevents the DS from detecting this line.

Main.js
var svc = null, txtStatus = null; // Service handle and text control

cfg.Dark

function OnStart() {
// Create a vertical layout to hold controls.
var lay = app.CreateLayout("linear", "VCenter,FillXY");

// Create a Text control to display messages from the service.
txtStatus = app.CreateText("Waiting for service message...", 0.8, 0.1);
lay.AddChild(txtStatus);

// Create a button to send the "change" message to the service.
var btnChange = app.CreateButton("Send 'change'", 0.6, 0.1);
btnChange.SetOnTouch(btnChange_OnTouch);
lay.AddChild(btnChange);

// Create a button to stop the service.
var btnStop = app.CreateButton("Stop Service", 0.6, 0.1);
btnStop.SetOnTouch(btnStop_OnTouch);
lay.AddChild(btnStop);
var btnPerm = app.CreateButton("Show Permission", 0.6, 0.1);
btnPerm.SetOnTouch(btnPerm_OnTouch);
lay.AddChild(btnPerm);

// Add the layout to the app UI.
app.AddLayout(lay);

// Start/connect to the background service. OnServiceReady is called when ready.
svc = app.CreateService("this", "this", OnServiceReady);

// Register callback for messages from the service.
svc.SetOnMessage(OnServiceMessage);
}

function OnServiceReady() {
// Called when the service has started. We can show a notification if needed.
app.ShowPopup("Service started");
}

function btnChange_OnTouch() {
if (svc) {
// Send the "change" message to the service.
svc.SendMessage("change");
}
}

function btnStop_OnTouch() {
if (svc) {
// Stop the background service.
svc.Stop();
app.ShowPopup("Service stopped");
}
}

function btnPerm_OnTouch() {
app.SendIntent(null,null,"android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS" )
}

function OnServiceMessage(msg) {
// Display the incoming message from the service in the text control.
txtStatus.SetText("Service says: " + msg);
}

Service.js

// Global state
var g_ = {
counter: 0,
direction: 1,
interval: null,
notify: null
};

// Called when the service starts
function OnStart()
{
// Put service in foreground (for Android 8+)
app.SetInForeground("Counter Service", "Service is running", "", "", "high");

// Create notification listener
g_.notify = app.CreateNotification();
g_.notify.SetOnNotify(notify_OnNotify);
g_.notify["Listen"]();

Alan Hendry

unread,
May 8, 2025, 5:31:50 AMMay 8
to DroidScript
HI,
When you pay for premium 
you should get an email with a link to the premium Google Grou
 If you didn't get one then send a request to sup...@droidscript.org
Regards, ah
Reply all
Reply to author
Forward
0 new messages