Applaud & Phonegap on Android - android

My issue is regarding PhoneGap and Android development using the Eclipse Applaud plugin. I downloaded and installed the Applaud plugin successfully. I can create a new project using the Applaud wizard (via the Eclipse toolbar icon), and the demo runs on the device fine. However, when I overwrite the existing html & js (only main.js, not phonegap.js) files, then build it to the device, the non device functionality works fine (button clicks/ui update/etc), but the PhoneGap commands such as (device.version/device.platform/etc) does not seem to work.
I have tried hooking this into the onDeviceReady event as well as making sure the .jar library is included, but I still have the same issue. So I guess my question is; when creating a PhoneGap solution using Applaud, does Eclipse need to compile and library, such as PhoneGap? and if so, how could someone go about doing such things?
Error Log:
01-24 14:59:44.567: W/KeyCharacterMap(5453): No keyboard for id 131074
01-24 14:59:44.567: W/KeyCharacterMap(5453): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
01-24 14:59:59.917: I/Web Console(5453): Failed to run constructor: TypeError: object is not a function at file:///android_asset/www/resources/js/phonegap-1.3.0.js:210
01-24 14:59:59.927: I/Web Console(5453): Failed to run constructor: TypeError: Cannot read property 'capture' of undefined at file:///android_asset/www/resources/js/phonegap-1.3.0.js:210
01-24 14:59:59.927: I/Database(5453): sqlite returned: error code = 14, msg = cannot open file at source line 25467
01-24 15:00:00.057: D/dalvikvm(5453): GC_CONCURRENT freed 1185K, 55% free 3188K/6983K, external 2630K/2814K, paused 2ms+3ms

So I'm back and have somehow fixed the issue I had (most likely by luck). When I started this project, I thought the best approach would be make this application as modular as possible; each functionality (web requests, file reading/writing, etc.) to be separated from one another. Thus I created lots of separate js files, each tagged with the appropriate name (network, device, language, etc.), and then included them in my index.html page which is then ran by phonegap.
In some of these files, I took the following approach:
var Device = {
// Returns the Device Name as a string.
Name: function() {
return window.device.name;
}
};
As a result, I could then access this functionality using the dot operator (which I prefer). However by doing so, resulted in many files relying one on another, making it difficult to track down my issue. After spending some time commenting and un-commenting functionality, It seems by using a combination of the above approach (dot operator) and my bad choice of naming conventions. The Device.Name() implementation above seemed to (not entirely certain on why/how) conflict with the PhoneGap libraries, consequently resulting in js errors on the device.
After changing the above name from "Device" to "Handset", my issue went away. A simple and maybe obvious solution to a painful afternoon.

I'll answer your question, but I don't think it is your problem:
Whether or not the AppLaud wizard just uses phonegap.jar or rebuilds its components depends upon how you use the project creation wizard.
If you use its "Built-in Phonegap" or point at a downloaded official release ("Enter path to installed PhoneGap"), it will just point at the phonegap.jar from that release. If you point at a directory with an unzipped github PhoneGap version, phonegap.jar will not be used and the PhoneGap Java sources will be built into your project. This makes for easy debugging of the PhoneGap implementation.
Regarding your problem, you likely have something wrong with your index.html file, like a misspelling of phonegap{...}.js. As ghostCoder says in the comments, you may need to share your code to get help on it.

Related

NativeScript Build - Error executing Static Binding Generator: Class not found android.support.v4.view.ViewPager.OnPageChangeListener

I'm new to NativeScript and took over a project recently upgraded from NativeScript 4 to 6. Here is my environment detials:
Windows 10
Node v16.6.1
NativeScript 8.0.2
Android Studio 11 (with al
the recommended updates to date)
VS Code 1.58.2
I can create a new Native script project with "tns create" and build/run it in the simulator just fine. However, when I try to run the project the build throws the following error:
java.lang.RuntimeException: Class not found android.support.v4.view.ViewPager.OnPageChangeListener
at org.nativescript.staticbindinggenerator.Generator.getClass(Generator.java:551)
at org.nativescript.staticbindinggenerator.Generator.getInterfacesFromCache(Generator.java:534)
at org.nativescript.staticbindinggenerator.Generator.writeBinding(Generator.java:283)
at org.nativescript.staticbindinggenerator.Generator.generateBinding(Generator.java:171)
at org.nativescript.staticbindinggenerator.Generator.processRows(Generator.java:234)
at org.nativescript.staticbindinggenerator.Generator.generateBindings(Generator.java:121)
at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:97)
at org.nativescript.staticbindinggenerator.Main.main(Main.java:55)
Here is the run command I'm using: "tns run android --emulator"
I have tried tons of things and searches but no luck resolving this issue.
So I had an idea and searched with a different search engine than I normally use. I did find some ideas which helped me resolved the issue.
I had previously searched in VSCode for variations on "android.support.v4.view.ViewPager.OnPageChangeListener", but only found the log file with the error. Then I learned you have to change the filter options of the find in file search otherwise the files you are looking for can be excluded from the search results. I also used Baregrep to confirm I was getting everything.
I fixed the issue by replacing all occurrences of:
android.support.v4.view.ViewPager with androidx.viewpager.widget.ViewPager
Also you may need to install widgets:npm i tns-core-modules-widgets
Since the files where I made the changes were all non-project files (many of them in the node_modules directory) there is probably something else that involves updating Node or NativeScript that may solve this as well.
If someone else figures that out, I'll be watching this thread for updates, and thanks in advance!
Fissh

API Change error when building AOSP 5.1

Currently trying to build android-5.1.0_r5. I've checked out the sources and made no modifications. However, when compiling I get the following error.
Checking API: checkpublicapi-current
out/target/common/obj/PACKAGING/public_api.txt:20: error 5: Added public field android.Manifest.permission.BACKUP
out/target/common/obj/PACKAGING/public_api.txt:82: error 5: Added public field android.Manifest.permission.INVOKE_CARRIER_SETUP
out/target/common/obj/PACKAGING/public_api.txt:106: error 5: Added public field android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE
out/target/common/obj/PACKAGING/public_api.txt:116: error 5: Added public field android.Manifest.permission.RECEIVE_EMERGENCY_BROADCAST
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1) You can add "#hide" javadoc comments to the methods, etc. listed in the
errors above.
2) You can update current.txt by executing the following command:
make update-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
And diffing the public api txt files does indeed show a difference.
diff frameworks/base/api/current.txt out/target/common/obj/PACKAGING/public_api.txt
19a20
> field public static final java.lang.String BACKUP = "android.permission.BACKUP";
80a82
> field public static final java.lang.String INVOKE_CARRIER_SETUP = "android.permission.INVOKE_CARRIER_SETUP";
103a106
> field public static final java.lang.String READ_PRIVILEGED_PHONE_STATE = "android.permission.READ_PRIVILEGED_PHONE_STATE";
112a116
> field public static final java.lang.String RECEIVE_EMERGENCY_BROADCAST = "android.permission.RECEIVE_EMERGENCY_BROADCAST";
However, I cant figure out where those additional Public Fields are coming from. Any ideas?
Don't do 'make update-api' if you didn't touch anything. There additional apis came form frameworks/base/res/AndroidManifest.xml badly parsed by aapt that uses buggy system/core/libcore/String8.cpp##removeAll() they use memcpy but should be memmove for overlapping strings in memory.
This is issue on latest Debian (sid) or Ubuntu (16 maybe 15) build machines.
It's a google bug in libcore/String8.cpp. Fix is here:
https://android.googlesource.com/platform/system/core/+/dd060f01f68ee0e633e9cae24c4e565cda2032bd
This man found it (Michael Scott) and maybe some other people too. Here is his investigation: https://plus.google.com/+hashcode0f/posts/URHo3hBmfHY
Living on the Edge (of Ubuntu) ... can be painful!
I've been running Ubuntu 15.04 for a while now. It's been great
having a very current kernel alongside the latest improvements from
Ubuntu and Debian. (My past post on using zRAM ramdisk is one
example).
However, having the newest greatest toys also has it's downsides. I
recently spent 4 days troubleshooting a build break in Android which
started some time after March 25th. I'm guessing I updated packages
or inadvertently changed my glibc version.
The outcome was a build error during the checkapi stage of Android
build:
Install: /out/mydroid-ara/host/linux-x86/bin/apicheck Checking API:
checkpublicapi-last Checking API: checkpublicapi-current
/out/mydroid-ara/target/common/obj/PACKAGING/public_api.txt:20: error
5: Added public field android.Manifest.permission.BACKUP
/out/mydroid-ara/target/common/obj/PACKAGING/public_api.txt:82: error
5: Added public field android.Manifest.permission.INVOKE_CARRIER_SETUP
/out/mydroid-ara/target/common/obj/PACKAGING/public_api.txt:106: error
5: Added public field
android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE
/out/mydroid-ara/target/common/obj/PACKAGING/public_api.txt:116: error
5: Added public field
android.Manifest.permission.RECEIVE_EMERGENCY_BROADCAST
**************************** You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices: 1) You can add
"#hide" javadoc comments to the methods, etc. listed in the
errors above.
2) You can update current.txt by executing the following command:
make update-api
To submit the revised current.txt to the main Android repository,
you will need approval.
This occurred on both of my Ubuntu 15.04 boxes and was present when
when build AOSP android-5.0.2_r1 and android-5.1.0_r1.
For those of you who are unfamiliar with this portion of the Android
build, the Android framework exports all of the public portions of the
API and makes sure that the current build matches up with what's
located under frameworks/base/api/current.txt. It does this by
parsing frameworks/base/res/AndroidManifest.xml and any of the current
device's overlay .xml files and processes items marked with various
flags in the comments above them:#SystemApi, #hide, etc. This
parsing and processing portion of the checkapi stage is done by a
binary "aapt" (Android Asset Packagng Tool). It's source is located
under frameworks/base/tools/aapt.
I started by checking for upstream fixes to the platform/build or
platform/frameworks/base projects. After striking out, I began
debugging the android build via the use of: "make checkapi
showcommands" and then manually running the commands with "strace" to
see how each binary was involved and what output it generated.
After the first few hours of debugging, it became apparent that
out/target/common/obj/APPS/frameworks-res_intermediates/src/android/Manifest.java
file had comments which were being corrupted when aapt was generating
it. I was able to make some manual changes to the AndroidManifest.xml
file and get the build to pass (removing extra portions of the
comments).
Digging deeper via strace and then looking at various static link
sources, I found that during the AndroidManifest.xml comments
processing the #SystemApi token was being filtered out via a
String8.removeAll("#SystemApi") function call. Experimentally, I
removed this part of the processing. Lo and Behold! The build
worked. Taking a closer look at the removeAll function, I was able to
pin point a memcpy function as the part of the function which was
causing corruption.
I then researched memcpy a bit and noted that you are not supposed to
use memcpy on overlapping memory addresses, instead memmove was
preferred, because it makes a copy of the source prior to any changes
being made to the destination. After changing the use of memcpy to
memmove the build was fixed and all was well with the world!
As a good player in the open source world, I immediately thought I
should upstream this incredible feat of debugging to the master branch
of system/core. BUT, alas! The fix has been in the master branch
since November 11th 2014! And hasn't been brought into any of the
current development tags! grumble
https://android.googlesource.com/platform/system/core/+/dd060f01f68ee0e633e9cae24c4e565cda2032bd
I've since contacted the Google team about this change and let them
know of my experience in hopes that we may yet see this patch in
future release tags of Android.
Conclusion: apparently glibc is undergoeing some changes and some of
those have now filtered onto my Ubuntu boxes. Where previously the
memcpy usage was incorrect but still usable, it now causes the build
break I was seeing.
If you see this kind of error in your Android builds, and you're on a
newish version of Ubuntu or Debian distrobution, you may want to try
this simple patch and see if it helps.
Hash
Big up himself!
I do see the entries in my r8 code so you are probably safe running make update-api, and when that finishes then run your make command as normal.

ServiceLoader.load is not finding the META-INF/services

So I want to build an extensible android application where developers can add 'CustomDevice' classes and the main program will run them automatically without editing existing code.
I've read about Service Provider interface and thought that would be a nice way to go about it.
So I tested it and created an interface called 'ICustomDevice' which custom device classes are expected to implement.
I've created a class called 'DummyDevice' that implements ICustomDevice.
Both DummyDevice and ICustomDevice are in the same package "CustomDevicePackage".
So in my main program I run the following.
ServiceLoader<ICustomDevice> loader = ServiceLoader.load(ICustomDevice.class);
Iterator<ICustomDevice> devices = loader.iterator();
System.out.println("Does it have devices? " + devices.hasNext());
It always returns false, which means it's not finding the 'DummyDevice'
In my eclipse project I created a folder at 'src' called META-INF and under it, a subfolder called 'services'.
'Services' has a file named 'CustomDevicePackage.ICustomDevice' with a line of content 'CustomDevicePackage.DummyDevice'.
Am I doing it right? Every example I see about SPI is about loading JARS.
I'm not loading a JAR, I'm trying to run a class in the same Project. Does this method only works for loading JARs? I want my program to support loading local subclasses and external JARs alike.
I am adding this as an answer but leaving the prior "answer" to provide extended code detail for this workaround. I am working on reporting the prior answer results as a bug to Google.
Because the Android implementation of java.util.ServiceLoader is broken (always populating internal java.security.AccessControlContext field with AccessController.getContext() even if System.getSecurityManager() == null), the workaround is to create your own ServiceLoader class by copying the code found at OpenJDK for Java 8 into your class, add specific imports required from java.util without using import java.util.*;, and call that ServiceLoader in your code (you will have to fully reference the ServiceLoader you created to over ambiguity).
This isn't elegant but it is a functional workaround that works! Also, you will need to use a ClassLoader in your ServiceLoader.load() call. That ClassLoader will either have to be YourClass.class.getClassLoader() or a child ClassLoader of the class' ClassLoader.
Though it's an old post, This may be still be of some help to others:
When I was running or debugging a project that contained a ServiceLoader Class, I had to put the META-INF/services folder into the src/ folder in Eclipse.
If I tried to export the project as Runnable jar and tried to use the class with the service loader, it never worked.
When I checked the jar, unzipping it, I found the folder under src/META-INF/services though.
Only when I also added the META-INF folder directly in the root directory of the jar, it started to work.
I haven't found a fix though inside Eclipse, that makes sure it gets exported right...maybe an ANT script can solve this issue, but so far no attempts made...
This is an answer:
At some point, Android removed the AccessControlContext field in ServiceLoader and ServiceLoader now works. As my comments indicate, this was reproduceable using the "out-of-the-box" OREO (API 26) Intel Atom x86 emulator with Android Studio (also fresh download). 24 hours later, ServiceLoader no longer contained the acc field (as shown in the Android Studio debugger with the same emulator). The Android SDKs dating back to API 24 do not show the acc field.
Per the Android developer currently maintaining the ServiceLoader code:
He is not aware of ServiceLoader ever having the acc field in Android (it did as we were able to reproduce) and thought the debugger/emulator might have been using JDK code (but I showed the OpenJDK code works correctly). Somewhere along the way, the errant code was updated and I am no longer able to reproduce.
Be sure your OS is up-to-date and you should no longer see this phenomena.

missing a command building android kernel

I have been trying to build an android kernel for a certain device, the Huawei Vitria, they finally uploaded their kernel source about 2 months ago so I try to build it the normal way which fails so I fix the main errors I see and get the kernel to build finally but, then I notice one error while building. I look into this file and see that they are using a weird way of building I think instead of the normal defconfigs, using a generic defconfig then a configuration file to configure their devices ontop of that(they've done this before but not to this extent), which leads me to think I'm missing a command to select the device config ontop of the defconfig to set up the drivers, but don't know what command was used.
So might there be a way to find out the command by looking at these two files
https://raw.githubusercontent.com/KainXS/android_kernel_huawei_y301a2/jellybean/drivers/huawei/hsad/parse_product.pl
https://raw.githubusercontent.com/KainXS/android_kernel_huawei_y301a2/jellybean/drivers/huawei/hsad/parse_product_id.pl
thanks
I'm not sure how much help this is, but the first command seems to want to be called with a parameter of a path to an XML file.
./parse_product.pl /ab/cd/hw_xxy_configs.xml
PRODUCT: xxy
reads: '/ab/cd/hw_xxy_configs.xml'
It pulls out some data from that file and pastes it into a .c file which presumably goes into the build configuration.
So, you're looking for an XML file containing your product-name.
The second file calls the first repeatedly to generate a set of .c files. Now - this second script takes an XML file as an argument, but I'm afraid I can't tell what it might be called. The file looks like it should contain product names and board-ids if that is any help.

Failed to run aapt dump badging:AndroidManifest.xml is corrupt

I am new to android.
i get this error when i try to upload update of my app to google play.
Failed to run aapt dump badging:W/ResourceType(19538): Bad resource table: header size 0x708b or total size 0x2f2432a is larger than data size 0x1ce1c
ERROR: AndroidManifest.xml is corrupt
i tried ALMOST VERYTHING google fixes.but nothing works.
please help.
It gave me that 'uploading in debuggable mode' thiny too but i managed to fix it.
sorry about my bad english.
I went through the same problem recently (with the very similar error message) and I also had a lot of trouble to solve, but finally I got it like this:
I used the PhoneGap Builder to generate the APK (so I recommend using the same one); Remembering that to test manages the APK with the same blank key (it's the default markup);
After generating, I used Apk-Signer (https://shatter-box.com/knowledgebase/android-apk-signing-tool-apk-signer/) to generate the key (.keystore) - this package serves, too , To sign and align the application; However, for that case I used ONLY to generate the key;
Go back to the Phone Gap, in the Android options, select 'add a key ...', then select your keystore generated in APK-Signer, and activate the rebuild;
Ready! Now just download the APK, go to google play and be happy.
I ran into a similar problem not so long ago it turned out to be an issue with #+id
A similar question has been asked before and got me through my problem, I will link the post as it is very informative.
Android style Resources compile (aapt) failing : Bad resource table: header size 0xc
Hope this helps you, wish you the best of luck.
I'm new to android too, and I had the same problem, and what worked for me was as simple as :
Zipalign the apk file by a tool called "Advanced APK tool" (download it from xda forum)
then reupload apk file to store without any problem detected,
Best of luck!
Try using a latest version of aapt, from your Android SDK directory,
<Android_SDK_directory>/build-tools/<build_tools_version>/aapt

Categories

Resources