GithubHelp home page GithubHelp logo

kuri65536 / sl4a Goto Github PK

View Code? Open in Web Editor NEW

This project forked from damonkohler/sl4a

281.0 281.0 76.0 263.82 MB

Scripting environment for Android platform

License: Apache License 2.0

Java 83.43% Shell 0.17% JavaScript 0.03% Python 0.22% HTML 15.48% Makefile 0.01% C++ 0.16% C 0.10% XSLT 0.40% Batchfile 0.01%

sl4a's People

Contributors

damonkohler avatar filinep avatar igor-karp avatar jkordani avatar kuri65536 avatar meaneye avatar p5p avatar pdubroy avatar raaaar avatar scrogster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sl4a's Issues

Permission problem with testusbserial.py

I am trying to run testusbserial.py on my Android 4 smartphone running sl4a via the QPython app.

The script runs fine until line 63, then a permission dialog shows up and after i confirm it keeps looping "waiting for connect...".

(I have a CH340 Arduino Nano connected to the USB OTG port, so i changed the lines 45 and 53 with the correct IDs.)

@JavascriptInterface Decoration

Not sure if this is necessary with the current facades but in order to target higher sdks (and possible new facades) we need this in order for SL4A not to break when target sdks are higher than api 17 in the gradle config file. I will be working on this for my SL4A embedded apk project. ( https://github.com/ainsophical/droid-python ) Maybe i can merge this when i get it working.

Using USB Serial Facade

I am using the SL4a 5x04 and Python 2.7.9 onn my Nexus 7 (android 5.1) and am trying to access the USB with the example script given here: https://github.com/kuri65536/sl4a/blob/master/android/USBHostSerialFacade/samplescripts/testpl2303.py

However, android.usbserialGetDeviceList() gives an error saying that the RPC is not recognized. The exact error is:

Result(id=1, result=None, error=u'com.googlecode.android_scripting.rpc.RpcError: Unknown RPC.')

I used the latest releases for both SL4A and Python available on GitHub.
Any hints?

Beep boop bop

  • What device(s) are you experiencing the problem on?
    • ex: Nexus ???
  • What OS version are you running on the device?
    • ex: Andriod ???
  • What version of the product are you using?
    • SL4A r????
    • PythonForAndroid r??
  • What steps will reproduce the problem?
    1.
    2.
    3.
  • What is the expected output? What do you see instead?
    • expected: launch ???
    • see: stop running
  • Please provide any additional information below.

Error when trying to run on emulator

When I try to run this on an Android 6.0 x86 Android emulator, I get the following error in Android Studio.

The currently selected variant "arm-debug" uses split APKs, but none of the 1 split apks are compatible with the current device with density "-1" and ABIs "x86".

The project builds fine, but it won't run on the Android emulator. Attempting to install the generated APK via adb to the same emulator results in INSTALL_FAILED_NO_MATCHING_ABIS.

How to install sl4a on sdcard instead

Hi . i have limited device memory and sl4a is automatically installed and lives on internal momery ! is there a way to install it on the sd card instead? thank you

webViewShow only works with local files

From google group

Hello

I installed the sl4ar6 apk from kuri65536. I tried to show html from
www.Google.com or any website. But it looks like webViewShow only  works with local files.

Someone forked sl4a from kuri65536, and claims to have made great
improvements in UIFacade, including the ability to show html pages
from web sites. But that fork has not been compiled into apk.

https://github.com/miguelpalacio/sl4a

Is it possible for kuri65536 to merge those improvements?

I think fixing webViewShow would be a major step forward for sl4a.

Bye

Numpy and other python libraries Support

Hi,

I was trying to run with numpy, but my file does not show any output.
my code:

import android
import numpy as np
droid = android.Android()
droid.makeToast('Hello Android!')

Without import numpy as np, it shows toast message as Hello Android!
But with numpy, i don't get any output.

Please show some light on it. Thanks.

[Docs] Update README

I used be an avid SL4A user, and am really interested in using this fork, but it's not clear what the project status is, or how to install this version.

In any case, the README should be replaced immediately with a few lines that are at least correct. Even just...

An active fork of Scripting Layer for Android.

...would be better than a ton of incorrect information.

Whenever someone who knows about the project has time, they can add a project status, and some installation instructions etc. If more people are able use the app, we can help document things :)

gradle task ':transformClassesWithDexForArmDebug' failed, java finished with non-zero exit value 2

  • android studio 1.5.1
  • gradle 2.8
  • oracle jdk version "1.8.0_74"

This error occurs often when building the APK with android studio and systematically when building the APK for the first time. Building with 'gradle assembleDebug' gives more details:

:transformClassesWithDexForArmDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/common/annotations/Beta;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
        at com.android.dx.command.dexer.Main.run(Main.java:246)
        at com.android.dx.command.dexer.Main.main(Main.java:215)
        at com.android.dx.command.Main.main(Main.java:106)


 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithDexForArmDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-jdk/bin/java'' finished with non-zero exit value 2
  • The com.google.common.annotations package is part of google guava libraries and the Common and Util subprojects are dependent on guava.
  • Commenting the compile files('libs/guava-r06.jar') statement in the Common build script seems to fix the problem and the APK are built without error the first time now. This would be a regression in gradle since there is nothing wrong with the commented out statement.
  • Anyway, as the Common subproject is dependent on Util, it seems that libs/guava-r06.jar would be better located in Util instead of in Common, so that Common does not depend directly on guava.

build errors with android studio 1.5.1

With a fresh android studio install on archlinux:

  • android studio 1.5.1
  • gradle 2.8
  • OpenJDK java version "1.7.0_95"

1 - The following error occurs when making the project:

Error:Execution failed for task ':TextToSpeechFacade:processDebugAndroidTestManifest'.
> java.lang.RuntimeException: Manifest merger failed : uses-sdk:minSdkVersion 3 cannot be smaller than version 4 declared in library [ScriptingLayerForAndroid:Common:unspecified] /home/xavier/src/sl4a/android/TextToSpeechFacade/build/intermediates/exploded-aar/ScriptingLayerForAndroid/Common/unspecified/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="com.googlecode.android_scripting.common" to force usage

This can be fixed by updating all subprojects build.gradle files with 'minSdkVersion 4'

Another way is to move the subprojects 'android' script block in the root build.gradle file so that minSdkVersion is only defined once. The build.gradle file below (sorry, could not find a way to attach it to the issue) does that and all the subprojects build.gradle files only contain in this case the 'apply' statement and the 'dependencies' script block.

2 - Once this is fixed, another error occurs when building the APK:

/home/xavier/src/sl4a/android/ScriptingLayerForAndroid/res/drawable/atari_small_notice.txt
Error:Error: The file name must end with .xml or .png
:mergeArmDebugResources FAILED

3 - Once this file has been removed, another error occurs when building the APK:

Error:Execution failed for task ':transformClassesWithDexForArmDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk/bin/java'' finished with non-zero exit value 2

But this must be some bug in the ide or gradle since after selecting [Clean Project], [Rebuild Project] or [Build APK] not sure what is the right sequence, then the APK files are built and this error does not appear anymore.

ScriptingLayerForAndroid/build.gradle

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
    }
}

apply plugin: 'com.android.application'

dependencies {
    compile project(':Common')
    compile project(':Utils')
    compile project(':QuickAction')
    compile project(':BluetoothFacade')
    compile project(':SignalStrengthFacade')
    compile project(':TextToSpeechFacade')
    compile project(':WebCamFacade')
    compile project(':USBHostSerialFacade')
    compile project(':ScriptingLayer')
    compile project(':InterpreterForAndroid')
    compile('com.android.support:support-v4:21.0.3') {
        force = true
    }
    compile files('libs/locale_platform.jar')
}

/* rootProject properties (see gradle ExtraPropertiesExtension). */
ext {
    build_tools_version = "21.1.2"
    compile_sdk_version = 21
    min_sdk_version = 4
    target_sdk_version = 4
    com_android_tools_build_gradle = 'com.android.tools.build:gradle:1.5.0'
}

android {
    buildToolsVersion project.build_tools_version
    compileSdkVersion project.compile_sdk_version

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jni.srcDirs = []   // Please build NDK modules outside gradle.
            jniLibs.srcDirs = ['libs']
        }

        instrumentTest.setRoot('tests')
    }
    defaultConfig {
        minSdkVersion project.min_sdk_version
        targetSdkVersion project.target_sdk_version
        versionCode 611
        versionName '6.1.1'
    }
    productFlavors {
        x86 {
            ndk {
                abiFilter "x86"
            }
        }
        mips {
            ndk {
                abiFilter "mips"
            }
        }
        armv7 {
            ndk {
                abiFilter "armeabi-v7a"
            }
        }
        arm {
            ndk {
                abiFilters "armeabi"
            }
        }
    }
    productFlavors {
    }
    dexOptions {
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_7
    }

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def file = output.outputFile
            if (file != null && file.name.endsWith('.apk')) {
                def newName = file.name.replace(
                    "ScriptingLayerForAndroid",
                    "sl4a-r" + defaultConfig.versionName)
                output.outputFile = new File(file.parent, newName)
            }
        }
    }
}

subprojects { subproject ->
    buildscript {
        repositories {
            mavenCentral()
        }

        dependencies {
            classpath rootProject.com_android_tools_build_gradle
        }
    }

    afterEvaluate{
        if((subproject.plugins.hasPlugin('android') ||
                subproject.plugins.hasPlugin('android-library'))) {

            android {
                buildToolsVersion rootProject.build_tools_version
                compileSdkVersion rootProject.compile_sdk_version

                defaultConfig {
                    minSdkVersion rootProject.min_sdk_version
                    targetSdkVersion rootProject.target_sdk_version
                }

                sourceSets {
                    main {
                        manifest.srcFile 'AndroidManifest.xml'
                        java.srcDirs = ['src']
                        resources.srcDirs = ['src']
                        aidl.srcDirs = ['src']
                        renderscript.srcDirs = ['src']
                        res.srcDirs = ['res']
                        assets.srcDirs = ['assets']
                    }
                    instrumentTest.setRoot('tests')
                }
            }

        }
    }
}

How do I install this?

I am trying to figure out how to install this on my Android system. I am currently using Android version 9.

Rhino(javascript) Interpreter Installation

Forgive me if this has been addressed somewhere - I was unable to find it, either in the issues here or in the Google Group.

I'm currently unable to install interpreters - Rhino is the main one I've tried. When trying to install from the SL4A app (using the latest, non-pre-release apk), it tries to open the old Google Code site, so of course it's not going to find anything. I have a version of the Rhino apk I downloaded a long time ago from the Google Code site; trying to run it and install from there simply fails. I've deleted the com.googlecode.rhinoforandroid folder (from my sd card) before each time I try to run the Rhino apk, and it still fails. I tried manually creating the folder on my sd card and adding the rhino jar, scripts zip, and extras zip (from the lang-rhino branch on here), and SL4A doesn't recognize it.

Please help - I absolutely loved SL4A, and was really disappointed to see it die. This seems to be the only active fork of it, and I really don't know where else I can get it set up from. Thanks!

When scanning a barcode, SCAN_RESULT_BYTES is a strange format.

kuri65536/python-for-android#63

SCAN_RESULT_BYTES is not bytes array in python.

  def _rpc(self, method, *args):                                                
    data = {'id': self.id,                                                      
            'method': method,                                                   
            'params': args}                                                     
    request = json.dumps(data)                                                  
    self.client.write(request+'\n')                                             
    self.client.flush()                                                         
    response = self.client.readline()                                           
    self.id += 1                                                                
    result = json.loads(response)                                               
    if result['error'] is not None:

In self.client.readline(), response is already contains the converted string 'SCAN_RESULT_BYTES'.

BluetoothFacade: any way to add BLE Gatt Client / Server

Dear Project Members,
Developping a lot around Bluetooth Low Energy, Bluetooth Facade offcially registred in sl4a does not include the BLE Facade to access a BLE Gatt Client / Server. I have seen .java file but it is still unknown by the RPC interpreter.
I would like to ask you two questions:

  • Is there any way to to have them available in some script.jar or in .apk? I would be really eager to.
  • Is there any way (detailled recipe) to rebuild sl4a? So I could maybe manage my own evolutions.
    Best regards,
    Thierry

Cod

@rpc(description = "Get Memory Statistics By Type")
public float getMemoryStat(@RpcParameter(name = "type") String type) throws InterruptedException {
ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
activityManager.getMemoryInfo(mi);

    long availableMegs = mi.availMem / 1048576L;  // returns percentages

    long percentAvail = mi.availMem / mi.totalMem; // returns percentages

    if (type == "avail") {
        return mi.availMem;
    } else {
        return mi.totalMem;
    }

Tasker

Cant pass variables to tasker

Issue 713 in android-scripting: sl4a is not working with Android 5.1

  • What device(s) are you experiencing the problem on?
    • Lollipop device
  • What firmware version are you running on the device?
    • Andriod 5.1
  • What steps will reproduce the problem?
    1.sl4a and pythonfor andriod apk's are installed.
    2.If i try to run python script blank screen is coming up and keyboard is appearing.
    3.In the notification window it shows script is running but nothing is working
  • What is the expected output? What do you see instead?
    • The python script should execute.
  • What version of the product are you using? On what operating system?
    • Andriod 5.1

Please provide any additional information below.

toggleAirplaneMode() causes NullPointerException

  • What device(s) are you experiencing the problem on?
    • ???
  • What OS version are you running on the device?
    • Android 4.2
  • What version of the product are you using?
    • ???
  • What steps will reproduce the problem?
    • ???
  • What is the expected output? What do you see instead?
    • expected: change to AirPlaneMode
    • see: cause NullPointerException
  • Please provide any additional information below.

Enhancement Request: Server-only APK

I had been looking for a way to do this for a little while without producing any notifications or UI. Basically, I'd like to control SL4A's API server solely via intents, start a private server on a predetermined port as I was looking to do some script integration between my debian chroot and Android. If there's another way to do so with the current version (control the SL4A private server via intents and set a specific port), I'd be open to that too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.