I am trying to get this example project to work: http://simonmacdonald.blogspot.co.uk/2012/10/barcode-scanner-example-projects.html
I have imported both the projects and made the library project a library etc and i have it running but when i run it and click the scan button i get:
Uncaught TypeError: Object [object Object] has no method 'exec' at file://android_asset/www/cordova.js:863
I have changed the target version to 17 (the latest) which allowed me to run it but i cannot seem to get it to work am i missing something?
I would like to run this on my Google Nexus 4 if this info helps.
Here is a zip of all the code i am using: https://dl.dropboxusercontent.com/u/1099165/bc-code.zip
Also i am using Eclipse to run this (ADT)
Because your barcodescanner.js is using old API call. There is no longer cordova.exec. You need to use the latest barcodescanner.js: https://github.com/phonegap/phonegap-plugins/blob/master/Android/BarcodeScanner/2.2.0/assets/www/barcodescanner.js
After Noogen's answer it got me thinking if Cordova needed to be updated so i grabbed the latest phonegap files and replaced the cordova.js file and the 2.8.1 jar file and then did a clean and build - it worked!
Related
Hello I am new to flutter and i want to do native function calls using flutter, i wrote an sample native code app and it is working as expected. Now i want to use some packages on my android code, which is platform specific.
I have added my dependcies in my build.gradle file and it the gradle build is success,
But i cannot use the package there,
say for example: i have added the dependency for the com.squareup.okhttp3:okhttp:3.4.2 and gradle build is success and now icannot access their methods and other stuffs. Please let me know to what to do with it. Thanks in advance.enter image description here
Finally it worked, i opened the android project as an new android project in android studio which resolved the issue.
I've followed this stack overflow answer to try and get OpenCV android working in Android Studio. I have followed the directions with the following caveats:
The build tools version in the opencv build.gradle is 19.1.0 instead of 19.0.1
Instead of looking like the picture provided after a gradle sync, my project structure looks like this:
When I open the module dialog, opencv appears as a model, as well as app
The project builds and autocompletes fine. However, I get the following error when the code that requires OpenCV is called:
java.lang.UnsatisfiedLinkError: Native method not found: org.opencv.core.Mat.n_Mat:()
I have no idea what I am doing wrong. Any help is appreciated.
You have to explicitly load libs with LoadLibrary:
http://developer.android.com/reference/java/lang/System.html
I am using phonegap-2.9.0 with file plugin. When I build project for android platform it creates two packages within the src/ folder:
org.apache.cordova.file
org.apache.cordova.filetransfer
I get below errors within these two packages:
1 - org.apache.cordova.file.FileUtils
Method testSaveLocationExists() from the type DirectoryManager is not visible
Method getFreeDiskSpace() from the type DirectoryManager is not visible
Method testFileExists() from the type DirectoryManager is not visible
2 - org.apache.cordova.filetransfer.FileTransfer
import org.apache.cordova.CordovaResourceApi unresolved
import org.apache.cordova.CordovaResourceApi.OpenForReadResult unresolved
Could someone please tell me what I should do to resolve these?
Thanks.
You have two problems.
1) Version of Phonegap is outdated
2) The way to install a plugin is:
-> phonegap plugin add "urlofplugin" or "/path""
-> phonegap platform add android
-> phonegap prepare
-> phonegap build
sometimes the plugin has a different default installation, the files need to change the platform.
Well, I dont know if I can help you, but I had similar problems. When I installed exactly those two plugins I got an error too. A different one, which I dont perticularly remember, something to do with a missing file that I can easily find in the file manager. Anyway, what helped me was:
I updated to a more recent version, if you are able to I advice for it.
After installing the plugins through cordova cmd api (.nodejs command prompt ... you know what I mean) I was forgetting to build in the api itself. It sounds stupid but I was using wp8 and thus using a template for visual studio. The studio gave me the error, the building process (in cmd) also gave errors, but it was fixed by updating to the newer version.
You need to configure you build path and then add library from external source and select the library then it will resolve or u can make copy and paste cordova library .jar file in your lib folder. then it will remove, if not happen then tell me .......
I am not sure if that will work but first uninstall these plugins using phonegap/cordova CLI and than reinstall it in the root of application folder using the CLI only like this:
phonegap local plugin add <required plugin>
This worked for me after reinstallation.
I am new to Android development. I have succesfully installed eclipse with Android Developer Tool plugin and many of the samples work fine.
But Android samples - Accelerometer and APIDemos do not build. I see many build errors notifying to fix the errors in code. I dont think Google has released APIDemo sample with build errors.
Thanks in advance, please advice how to fix these errors, or if any configuration/setting is required.
I have set the Java compiler compliance level to 1.6.
Error information(for acceralometer sample):
The project contains error(s) in application. Please fix them before running
Error details:
The method onAccuracyChanged(Sensor, int) of type AccelerometerPlayActivity.SimulationView must override a superclass method
AccelerometerPlayActivity.java /AccelerometerPlay/src/com/example/android/accelerometerplay line 456
Java Problem
Call requires API level 8 (current min is 5):
android.view.Display#getRotation AccelerometerPlayActivity.java /AccelerometerPlay/src/com/example/android/accelerometerplay
line 389 Android Lint Problem
Regards,
Jai
Look for the line androidminSdkVersion ="5" in your android.manifest file
and change its value from 5 to 8 or anything more than 8
Alternative is
Go to project properties by right clicking on you project,
thereafter look for Android in properties.
You have to select the build target here equivalent to the api for which it the sample project is build for
Refer Image
Say if you are using the sample from folder android-12 then you have to check the same option(ie API Level 12) here in properties
A possible reason can be a slow PC, which does not build in time. Then errors occur due to absence of R.java
In that case (errors are with something like R.id.stuff), build the project and wait.
I found the fix myself!
Earlier I tried with Andriod version 4.0. Now I just tried ApiDemos sample with Android version 4.1.2. It worked fine. I also deployed the apk in my mobile. It just works fine.
Based on PlatformLibrary sample code in the SDK, I have created a small hello world library, the eventual goal of the library is to add capability for 3rd part developers to develop for my custom Android image.
I am currently stuck at the point on how to deploy the same so that developers can start using it, I am unable to find any pointers, please help if you have any information.
Ok, I figured out based on for 4.0.3
Create a new sample device, based on the the existing one located at
<SDK-ROOT>/device/sample
build the sdk-addon
<SDK-ROOT>$ . build/envsetup.sh
<SDK-ROOT>$ make -j8 PRODUCT-<your-sdk-addon-name>-sdk_addon
Once the SDK is build you will get the sdk addon archive located at
<SDK-ROOT>/out/host/linux-x86/sdk-addon/<sdkname>.zip
I copied the ZIP to the http server directory, so that it has a link I can refer in Android SDK manager.
Created new SDK XML configuration file and put it in the http server (I used the one located at http://android-sdk-addons.motodevupdate.com/addons.xml for reference)
Went to Android SDK manager, added path to new add on XML created on #5 and OK
Install the new SDK On listed in the android SDK manager, after the installation is done, you can get check the add-ons directory of ur developer SDK to find the add-on.
Also bits and pieces from marakana.com/s/remixing_android,1044/index.html helped.
Looks like you resolved your own issue, but just FYI - to simplify/automate your step #5 above, you can use the mk_sdk_repo_xml.sh script provided under platform/development/build/tools to build the add-on repository.
This is actually used by the phony 'sdk_repo' target (platform/development/build/tools/sdk_repo.mk), so you can take a look to see what the intended usage is. It has the benefit of managing all the packaging/checksum generation etc for you.
Note that it's supposed to provide some automagic behaviour based on the ADDON_SDK_ZIP which is defined by the sdk_addon build task, but that never worked on our customized gingerbread platform, so I ended up putting in an explicit call like this:
$(shell $(TOPDIR)development/build/tools/mk_sdk_repo_xml.sh \
$(TOPDIR)out/host/linux-x86/sdk_addon/addon.xml \
$(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-1.xsd \
add-on any $(TOPDIR)out/host/linux-x86/sdk_addon/LIBRARY_NAME-eng-linux-x86.zip:sdk-repo-any-addon-LIBRARY_NAME.zip )
I figured out based on 4.4.2 and Andrdoid Studio 1.4, and it doesn't need put sdk add on xml to web server.
1.Create a new sample device, based on the the existing one located at
<ANDROID-ROOT>/device/<your-sdk-addon-name>
2.build the sdk-addon
<ANDROID-ROOT>$ . build/envsetup.sh
<ANDROID-ROOT>$ make -j8 PRODUCT-<your-sdk-addon-name>-sdk_addon
3.Once the SDK is build you will get the sdk addon archive located at
<ANDROID-ROOT>/out/host/linux-x86/sdk-addon/<sdkname>.zip
4.Extract .zip to
<SDK-ROOT>\add-ons\<your-sdk-addon-name>
5.Copy
<ANDROID-ROOT>\device\<your-sdk-addon-name>\sdk_addon\manifest.ini
to
<SDK-ROOT>\add-ons\<your-sdk-addon-name>
Create new file source.properties to <SDK-ROOT>\add-ons\<your-sdk-addon-name>
Addon.NameId=your-sdk-addon-name
Pkg.Desc=Provides the oem APIs to 3rd party apk developer
Addon.VendorId=your-sdk-addon-vendor-name
Archive.Arch=ANY
Addon.NameDisplay=your-sdk-addon-name
Addon.VendorDisplay=your-sdk-addon-vendor-name
Archive.Os=ANY
Pkg.Revision=1
AndroidVersion.ApiLevel=19
Open SDK Manager, your will see your SDK add on listed
New a Android Studio project, edit build.gradle file:
android {
compileSdkVersion "<your-sdk-addon-vendor-name>:<your-sdk-addon-name>:<sdk-api-level>"
...
}
Build the project, your add on jar will be loaded to External Libraries in Android Studio