Note that there are some explanatory texts on larger screens.

plurals
  1. POPhonegap android - deviceready event not fired
    primarykey
    data
    text
    <p>I had searched the web for solutions to my problem and found many related threads, unfortunately, none of the solutions provided works for my case. I am new to android development and followed the documentation found at <a href="http://docs.phonegap.com/en/2.1.0/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android" rel="noreferrer">Apache Cordova</a>! for configuration.</p> <p><strong>Problem</strong>: The deviceready event is not fired, below are my codes and configuration together with error log. Please advise me on what i had done wrong, thanks!!!</p> <p><strong>Emulator</strong></p> <pre><code>AVD Device: nexus 7 Target: Android 4.2 Memory RAM: 512 </code></pre> <p><strong>MainActivity.java</strong></p> <pre><code> package com.example.pollo; import android.os.Bundle; import org.apache.cordova.*; import android.app.Activity; public class MainActivity extends DroidGap { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.loadUrl("file:///android_asset/www/index.html"); } } </code></pre> <p><strong>index.html</strong></p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;script src="cordova-2.2.0.js"&gt;&lt;/script&gt; &lt;script&gt; function onLoad(){ console.log("Now Loading"); document.addEventListener("deviceready", myDeviceReadyListener, false); } function myDeviceReadyListener(){ console.log("Device ready"); navigator.notification.alert("Phone is ready!"); var myDiv = document.getElementById('props'); myDiv.innerHTML = 'Device Name: ' + device.name; } &lt;/script&gt; &lt;/head&gt; &lt;body onload="onLoad()"&gt; &lt;h1&gt;X App V.11&lt;/h1&gt; &lt;p id="props"&gt;Loading device properties...&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>AndroidManifest.xml</strong></p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.pollo" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="7" android:targetSdkVersion="17" /&gt; &lt;supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true" android:resizeable="true" android:anyDensity="true" /&gt; &lt;uses-permission android:name="android.permission.CAMERA" /&gt; &lt;uses-permission android:name="android.permission.VIBRATE" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;uses-permission android:name="android.permission.RECEIVE_SMS" /&gt; &lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt; &lt;uses-permission android:name="android.permission.RECORD_VIDEO"/&gt; &lt;uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /&gt; &lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt; &lt;uses-permission android:name="android.permission.WRITE_CONTACTS" /&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt; &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt; &lt;uses-permission android:name="android.permission.BROADCAST_STICKY" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:name="com.example.pollo.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p><strong>Config</strong></p> <pre><code>assets&gt;www&gt;cordova-2.2.0.js assets&gt;www&gt;index.html res&gt;xml&gt;config.xml AndroidManifest.xml libs&gt;cordova-2.2.0.jar libs&gt;android-support-v13.jar </code></pre> <p><strong>Logcat - Error Log</strong></p> <pre><code> 12-31 01:50:58.323: E/Trace(659): error opening trace file: No such file or directory (2) 12-31 01:51:45.653: E/StrictMode(552): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d1b278 that was originally bound here </code></pre> <p>The onLoad() is called but the myDeviceReadyListener() is not called~ Does it got anything to do with the emulator that i chose?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload