This question answered many times, but I still can't fix my problem. I'm trying to play a music when my scene starts, I'm using Media class, but I get the error ReferenceError: Media is not defined. I'm using browser yet (I want to deploy it to android and ios later).
I'm using Cordova 3.5, PhoneGap 3.6.
Here's what I did so far:
1
ran the command in the command line standing in my project directory: cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-media.git
2
modified the config xml:
<feature name="Media">
<param name="android-package" value="org.apache.cordova.media.AudioHandler" />
</feature>
3
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
My js code is:
var music = new Media("sounds/main_theme.ogg");
Instead of using PhoneGap via this tutorial, rather use command line cordova via this tutorial.
Related
I have just created an react-native app and building the React Native application giving me The error below.
H:\App Data\ejob-app\android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml:2: AAPT: error: attribute 'package' in <manifest> tag is not a valid Android package name: 'com.ejob-app'.
H:\App Data\ejob-app\android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml:17: AAPT: error: attribute 'android:name' in <application> tag must be a valid Java class name.
H:\App Data\ejob-app\android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml:24: AAPT: error: attribute 'android:name' in <activity> tag must be a valid Java class name.
And Ended up with the error below..
FAILURE: Build failed with an exception.
* Where:
Build file 'H:\App Data\ejob-app\android\app\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Plugin with id 'com.ejob.app' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --
debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and
have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Here is my AndroidManifest.xml to check the required configuration.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ejob-app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name="com.ejob-app.MainApplication"
android:allowBackup="false"
android:debuggable="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.ejob-app.MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="#string/app_name"
android:windowSoftInputMode="adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
Please guide me on this, please tell me if i missing something. i am very new to react-native.
Package name should not contain dashes. Rename your package from
'com.ejob-app'
to
'com.ejob_app'
You can follow this question
I had the same problem and in my case, the problem was that when I created flutter project, I gave the org name as in.mycompany (observe, "in"). Now, it seems "in" is a keyword in Dart and so, Android Studio uses `in` in the files that it generates. However, that make Gradle unhappy, and causes it to generate message saying name must be a valid Java package name. Quite a conundrum :)
The solution is to search for this string `in`.mycompany in the whole project and change it to in.mycompany in build.gradle and AndroidManifest.xml files (there are several of such files, so just search). But leave it as `in` in the kotlin file MainActivity.kt
That fixed it for me.
Solution by #Priyshrm works, I had the same problem, the package name was changed to "'in'.companyname.appname" and this 'in' was creating problem. Just remove '' and solved
I'm using PhoneGap Build to make an app for Android and Windows Phone. I'm trying to show a notification using the Alert function in JavaScript. The app works perfectly by showing the alert when i open it in a browser or install it on my Windows Phone but it fails on Android.
I have tried using the following functions to show a notification; however none of them seem to work:
navigator.notification.alert("PhoneGap is working", function(){}, "", "");
navigator.notification.alert("PhoneGap is working");
alert('We were unable to use location services in order to determine your location.');
I also added the following to the config.xml one at a time to add the notification plugin:
<gap:plugin name="org.apache.cordova.Notification" /> // generated an error on PhoneGap Build
<feature name="Notification">
<param name="android-package" value="org.apache.cordova.dialogs.Notification" />
</feature>
<gap:plugin name="org.apache.cordova.dialogs" />
<gap:plugin name="Notification" value="org.apache.cordova.Notification" />
Any ideas where I'm going wrong?
Thank you
I am getting crazy about this. I have a pretty basic Cordova (3.5.0) app and want to load an external URL. The only thing I am doing is loading jQuery (locally) and executing this on button click:
$.ajax({
dataType:'html',
url:'http://www.google.com',
success:function(data) {
$('#ajax').html($(data).children());
}
});
Everytime on loading my app fires this error:
GET http://www.google.com/ net::ERR_CACHE_MISS jquery.min.js:4
send jquery.min.js:4
m.extend.ajax jquery.min.js:4
(anonymous function) index.html:68
m.event.dispatch jquery.min.js:3
r.handle jquery.min.js:3
All permissions are properly set in the AndroidManifest.xml
<uses-permission android:name="android.permissions.INTERNET" />
<uses-permission android:name="android.permissions.NETWORK_ACCESS" />
<uses-permission android:name="android.permissions.ACCESS_NETWORK_STATE" />
Does anyone of you had a similar issue? What does net::ERR_CACHE_MISS means?
Oh damn... sometimes you just need to step back... Beginner's mistake: it is android.permission. and not android.permissions. Resolved!
All i had to do was:
cordova platform remove android
cordova platform add android
and the "net::ERR_CACHE_MISS" error disappeared. I have no idea what the reason was.
The used syntax is wrong.
Your used:
<uses-permission android:name="android.permissions.INTERNET" />
<uses-permission android:name="android.permissions.NETWORK_ACCESS" />
<uses-permission android:name="android.permissions.ACCESS_NETWORK_STATE" />
Correct:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.NETWORK_ACCESS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Name "android.permission" is singular.
net::ERR_CACHE_MISS is not a bad error, it simply means the page loaded has not been cached, if you go to a cached page the error should not show up. Most pages now will show this error, and while annoying it shouldn't do any damage to your application.
solved by adding internet permission in manifesto file
<uses-permission android:name="android.permission.INTERNET" />
Failed to load resource: net::ERR_CACHE_MISS
This can be removed by simply running these commands
ionic cordova platform rm android --save
ionic cordova platform add android --save
I have installed Phonegap (3.0.3) and the Cordova CLI.
I am also running iOS as a platform (confirmed using $ cordova platforms ls)
I have installed the plugins ($ cordova plugins ls)
org.apache.cordova.core.dialogs
org.apache.cordova.core.vibration
However, when I run this console command ($ cordova emulate ios), I get the following error.
Undefined symbols for architecture i386:
"_AudioServicesAddSystemSoundCompletion", referenced from:
_playBeep in CDVNotification.o
"_AudioServicesCreateSystemSoundID", referenced from:
_playBeep in CDVNotification.o
"_AudioServicesDisposeSystemSoundID", referenced from:
_soundCompletionCallback in CDVNotification.o
"_AudioServicesPlaySystemSound", referenced from:
_playBeep in CDVNotification.o
-[CDVVibration vibrate:] in CDVVibration.o
"_AudioServicesRemoveSystemSoundCompletion", referenced from:
_soundCompletionCallback in CDVNotification.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **
The following build commands failed:
Ld build/MyApp.app/MyApp normal i386
(1 failure)
I have followed the directions from the API page here (http://cordova.apache.org/docs/en/edge/cordova_notification_notification.md.html#Notification) and below is my config.xml file in the MyApp > www > config.xml file which causes the error.
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.myapp.myapp" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>MyApp</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev#callback.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<plugin name="Notification" value="CDVNotification" />
<access origin="*" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
</widget>
Any suggestions what the issue might be, and how I can go about fixing it?
Add AudioToolbox framework in your Xcode project:
Your Target > Build Phases > Link Binary With Libraries
Click the '+' button
Choose AudioToolbox.framework
Did you run cordova build ios?
then cordova emulate ios
This error happen when you don't add the source to the Compile sources in build phase.
Try to add plugins with :
TargetSettings -> Build Phases -> Compile Sources -> add your .m class
Take a look at CDVNotification.h - the #import lines tell you everything you need to add to your compile sources build phase.
Foundation/Foundation.h
UIKit/UIKit.h
AudioToolbox/AudioServices.h
Add those 3, and it will compile.
UPDATE - an additional change is necessary in CDVNotification.m
playBeep() calls soundCompletionCallback()
soundCompletionCallback calls playBeep()
In order for playBeep to be error free, soundCompletionCallback must be declared. The simple solution is to declare it before playBeep, then define it after.
Add this line just before static void playBeep(int count)
// declared but not defined to avoid undeclared error in playBeep
static void soundCompletionCallback(SystemSoundID ssid, void* data);
I am trying to create an app that makes use of the camera on the device. When I run the app on my Android phone, I can get it to work no problem. However, when I package it using the Phonegap builder, I can't seem to get the camera to open.
My guess is it's a problem with the config.xml file. This is what mine looks like:
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.test.testApp"
version = "1.0.0">
<name>Test App</name>
<description>
Test Description
</description>
<author href="http://mysite.com"
email="geoff#email.com">
Geoff Baum
</author>
<gap:platforms>
<gap:platform name="android" minVersion="2.1" />
<gap:platform name="webos" />
<gap:platform name="symbian.wrt" />
<gap:platform name="blackberry" project="widgets"/>
</gap:platforms>
<icon src="icon.png" gap:role="default" />
<!--<gap:splash src="weirdo.png" />-->
<feature name="http://api.phonegap.com/1.0/geolocation"/>
<feature name="http://api.phonegap.com/1.0/network"/>
<feature name="http://api.phonegap.com/1.0/geolocation"/>
<feature name="http://api.phonegap.com/1.0/file"/>
<feature name="http://api.phonegap.com/1.0/camera"/>
<feature name="http://api.phonegap.com/1.0/media"/>
<feature name="http://api.phonegap.com/1.0/device"/>
<!--<preference name="orientation" value="default" />-->
<!--<preference name="android-minSdkVersion" value="7" /> -->
</widget>
Does that look correct? I have this file at the root level of the folder I am packaging and sending to Phonegap. Is this the proper approach? I am not sure what else I can do. Any help would be greatly appreciated. Thanks!
UPDATE:
So I tried including the Android specific JS file cordova-1.7.0.js and everything worked. So it looks like the Phonegap build is not adding the necessary files. Does anyone know anything about that? Thanks.
Any reason why you have
<feature name="http://api.phonegap.com/1.0/geolocation"/>
twice?
So the solution lay in the include files. I was still including the phonegap.js file, and it was breaking the build process. I removed the various references to that file and it fixed it.