I can't get the childbrowser to work on Android.
I have followed the instructions on: https://github.com/brycecurtis/phonegap-plugins/tree/master/Android/ChildBrowser/
I have installed Eclipse and all the other stuff needed to compile an
app and all works as it should.
It is running in the emulator and I can also create an apk file.
So now I'm trying to get the childbrowser to work, like below.
I added the childbrowser.java file in my workspace/appname/
src/com/phonegap/plugins/childBrowser/ folder.
And the childbrowser.js file in my workspace/appname/assets/www/
folder.
I have linked to the phonegap.0.9.4.js and the childBrowser.js
files in my index file.
I added this in the manifest file
> <activity android:name="com.phonegap.DroidGap"
> android:label="#string/app_name">
> <intent-filter>
> </intent-filter>
> </activity>
The link that should open the childbrowser looks like this:
Open
And it still isn't working? I'm just testing in the emulator as I don't have a android phone here right now, isn't the childbrowser working in the emulator?
Or have I missed something else?
Thanks.
I use phonegap.0.9.4.js as well and it is working for me. The childBrowser should work after PhoneGap JS throws event 'deviceready'. So I added the following code.
var url="http://www.google.com";
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.plugins.childBrowser.showWebPage(url);
}
Some tips, as I encountered some issues as well:
The javascript file I downloaded is childbrowser.js, all lowercase, not childBrowser.js
Make sure that ChildBrowser.java is compiled in the correct folder. Check eclipse bin folder
For an external web page use http:// in front.
The Javascript is a different for Android and iPhone. For example on Android you do not call ChildBrowser.install(); So example code is also different for iPhone/Android/BlackBerry
Try using phonegap.0.9.5.js and let knw if you have any problem.I followed the same link its working fine.
Check Eclipse's BuildPath.
Some Eclipse versions have a Build Path entry in the context-sensitive right-click on a file/folder, some you have to go to the root folder, right-click and select 'Properties', select 'Java Build Path', then select the 'Source' tab.
Verify your src folder includes 'All', and it and it's subfolders and the ClassBrowser.java file are not Excluded.
Also, create or open the res/xml/plugins.xml file and add this line in source mode:
<plugin name="ChildBrowser" value="com.phonegap.plugins.childBrowser.ChildBrowser" />
Also note Aschwin's tips.
Change:
a href="#" onClick="window.plugins.childBrowser.showWebPage("thewebpage.html");"
To:
a href="#" onClick="window.plugins.childBrowser.showWebPage('thewebpage.html');"
The double quotes are likely what is keeping it from working. I see this is an old post, but maybe this will help someone else.
Related
I would like to extract my app in .apk format.
I add these script on my "package.json" page:
"build:development:android": "ionic cordova build android"
and "build:production:android": "ionic cordova build android --prod --release".
But, when I type the commands I have Errors.
What I should do to have my .apk file?
I am novice. Any help would be much appreciated. Thanks.
aha! I can see the problem in your code !
you are generating pages from ionic generate command! but if you see the file structure you will find that the page folder has its own module file! first delete that and then go to yourPage.ts file and delete the import of ionicPage and also remove the Annotation of ionic page.... Repeat this step for all pages which have this module file in them!
after that make sure your pages are imported in your app.module.ts
here lemme show you an example how it is done! consider I have a class called testerClass. its page structure on using
ionic g page testerClass will be as
delete that tester-class.module.ts
Step 2: AFTER deleting that you have to go into tester-class.ts and
remove the annotation and import of ionic page like shown in picture
**
NOTE!!make sure you run the build commands using admin/root pre villages (if you are not using root account just in case). in simple words search your cmd in windows search option right click and open as administrator
**
I think you encounter 2 problems and I will try to refer to them based on the screenshots.
Screenshot #1: I believe this is a permissions error, if you run the same command as an admin do you have the same result? In order to run it as an admin you will:
type 'cmd' in your search bar bottom at the windows bar
when the results emerge, right click on the command line and hit 'run as administrator'
Screenshot #2: This is a code error but it is simple to fix.
It seems that you have added the Album page via ionic generate page AlbumPage but then added that to your app.module.ts.
The result is that AlbumPage is declared on both app.module.ts and album.module.ts.
Since AlbumPage is built to be an Ionic Page (if you navigate in album.ts, right above Component annotation, you will se the IonicPage() annotation) you can remove it from the app.module.ts, and wherever you are referring to this page you can use the string of the name e.g. this.setRoot('AlbumPage'), instead of this.setRoot(AlbumPage), which also means that you do not have to import it.
I have installed QPython in my Android mobile.
I written a statement in the QEdit to read a text file from the below path
/storage/emulated/0/com.hipipal.qpyplus/script3/File1.txt
I used the below statement
fob=open('/storage/emulated/0/com.hipipal.qpyplus/script3/File1.txt','r')
fob.read()
If I run the statement, it is throwing error as:
IOError:[Errno 2] No such file or directory: '/storage/emulated/0/com.hipipal.qpyplus/script3/File1.txt'
1|uo_a116#cancro:/ $
Is the above statement correct?
fob=open('File1.txt','r')
Is not working in version 1.0.4.
fout=open('File2.txt','w')
Was working on version 0.9.6, but is not working in 1.0.4.
The "error" is Read only file system.
It looks like restrictions in the (new 1.0.4) file system library. I post a mail to the editor, but no answer at this time.
For testing, try to write absolute path to your files pointing, for example, to sdcard (/sdcard/out.txt).
I had problems on this versions (>=1.0.4) because launch process of script changes and execution directory is not the same as script directory.
I had to change my scripts to point to absolute paths.
It was tested with qpython developer.
Check this link:
https://github.com/qpython-android/qpython.org/issues/48
You can also try as simple as:
fob=open('File1.txt','r')
fob.read()
Just if the script is in the same folder of the file.
You can change the current working directory to path with script before read file:
import os
os.chdir(os.path.dirname(os.path.abspath(__file__)))
I have a problem using the Facebook Connect plugin with PhoneGap.
I have added this line to file plugins.xml:
<plugin name="com.phonegap.facebook.Connect" value="com.phonegap.facebook.ConnectPlugin" />
And this include on in file FbDialog.java:
import com.phonegap.helloworld.R;
I have these files on src:
com
/facebook/android/
AsyncFacebookRunner.java
DialogError.java
Facebook.java
FacebookError.java
FbDialog.java
Util.java
/phonegap/
facebook/ConnectPlugin.java
helloworld/HelloPhoneGapActivity.java
The ressources files close and the icon is copied. In HTML, I include some JavaScript code:
cordova-1.6.1.js
cdv-plugin-fb-connect.js
facebook_js_sdk.js
I use the default HTML example with my appId.
When I run application on my Android phone, a dialog says:
Cordova Facebook connect plugin fail on init!
and
Cordova Facebook connect plugin fail on auth.status!
If I click the login bouton, the dialog says:
Cordova Facebook connect plugin fail on login!Class not found
And the Eclipse console log is:
I tried to install this with the officiel Git readme and the
tutorial Add Facebook login to PhoneGap/Cordova Android app Easiest way.
When I compile the application, I don't get the error.
How do I fix this problem?
After the switch to Cordova, everything got renamed. You need the new class location:
<plugin name="org.apache.cordova.facebook.Connect" value="org.apache.cordova.facebook.ConnectPlugin" />
You'll have to put your plugin java (back?) to the correct location as well in org/apache/cordova/facebook/ .
Unfortunately, the error for this is pretty vague, but you can see it if you know what to look for. You can see in your logs the line with Message=Class not found in it. It would be better if this line had the name of the class. This error happens when you call the JS for a plugin, but then the right class name can't be found in the plugins.xml file. This is also why you notice that any call fails the same way.
Verify that android studio isn't giving an error like:
A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk.
If so, then edit androidmanifest. See: A valid Facebook app id must be set in the AndroidManifest.xml
Trying to make an app using phonegap 1.4.1 + phonegap's childbrowser plugin.
I've been following guides and digging a lot on the subject, but I'm stuck on an error I can't understand.
I've moved the childbrowser.java to the correct location and added this to the plugins.xml:
<plugin name="ChildBrowser" value="com.phonegap.plugins.childBrowser.ChildBrowser"/>
added this to the androidmanifest.xml:
<activity android:name="com.phonegap.DroidGap" android:label="#string/app_name">
<intent-filter>
</intent-filter>
</activity>
But I get an error on the ChildBrowser.java on this line:
package com.phonegap.plugins.childBrowser;
telling me that the declared package com.phonegap.plugins.childBrowser does not match the expected package com.phonegap.plugins.ChildBrowser.
I changed it to capital C in childbrowser.java, and the error went away, but ofc, the plugin didn't work.
i found this topic, discussing it, but no appearant fix
http://comments.gmane.org/gmane.comp.handhelds.phonegap/11993
I have tried renaming the plugin name in plugins.xml
Earlier, i was trying to whitelist some url's, but kept getting them blocked, so i'm thinking there's something wrong with my /res/xml directory? its meant to be projectroot/res/xml, right?
Any help will be greatly appreciated.
If you've created the package "com.phonegap.plugins.ChildBrowser" in your Eclipse project then you need to modify the plugins.xml line to be:
<plugin name="ChildBrowser" value="com.phonegap.plugins.ChildBrowser.ChildBrowser"/>
to match the actual package of the plugin.
Make sure the ChildBrowser java file is in the package you declared in plugins.xml, which is in root/res/xml/ folder.
You need to add the javascript file to your main page, so the page can call it's methods. Check that the javascript file contents are consistent with you java file location - for example the packages may be different.
Add the right permissions
Make sure you call the plugin from javascript the right way, for example in phonegap 1.3 it goes like this:
window.plugins.childBrowser.onLocationChange = function(loc)
{
...
I'm trying to get PhoneGap working. I've hit a hurdle getting started.
I've downloaded version 0.9.1. I've been following the instructions at http://phonegap.pbworks.com/Getting-started-with-Android-PhoneGap-in-Eclipse
Using MacOS 10.5.8. Android SDK is already installed and working with Eclipse.
My .bash_profile file looks like this:-
$PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
export PATH=${PATH}:/Applications/android-sdk-mac_86/tools
export PATH=$PATH:/Applications/phonegap-android/bin
(and I restarted my terminal window to make it take effect)
I've tried the following command:-
cd /Applications/phonegap-android/bin
ruby ./droidgap /Applications/android-sdk-mac_86 HelloPhoneGap com.myidentity.android /Users/myidentity/Documents/workspace/HelloPhoneGap/assets/www /Users/myidentity/Desktop
...and I get the following error:-
./droidgap:4:in `require': no such file to load -- /Applications/phonegap-android/bin/lib/generate.rb (LoadError)
from ./droidgap:4
Why?
I ran into this issue as well, move droidgap up one level into the phonegap base directory.
Or, you should mention the complete path:
export PATH=$path: /Applications/phonegap-android/bin/**droidgap**
I came across such issues too. go to https://github.com/jonathanstark/phonegap-android, search the generate.rb file in the lib folder there, download it, then you are good to go.