ClassNotFoundException on PhoneGap Getting Started with Android - android

I followed the PhoneGap Getting Started with Android instructions. The only thing that isn't exactly as described in the steps is that I have cordova version 2.1.0. The application builds and installs on my phone, but gives a ClassNotFoundException just after starting.
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.phonegaptest/com.example.phonegaptest.MainActivity}: java.lang.ClassNotFoundException: com.example.phonegaptest.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.phonegaptest-2.apk]
The MainActivity is the only class in the application. Why can't it be found?
Update:
Here's my manifest:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

I fixed this, but I don't like the solution. I went into the Eclipse Build Path settings for the project, and checked the boxes to export the three jars the project depends on. This solved the problem. Then I started unchecking them to figure out which one I really needed to do that for, and after unchecking all of the boxes, the program still runs.

i was also facing similar situation after i upgraded to v22, when i added the jar file to the build path it started working

Related

My android app stops unexpectedly when I run in on the emulator

I am using Eclypse and PhoneGap to build a mobile application for some reason, when I try to create new projects a message pops up that says "Android SDK Content Loader encountered a problem". If I proceed and create my project when I run on the emulator it says that the "unfortunately, has stopped." I am not sure what the problem is, I am able to open old projects. Also, I don't know if the warning message I get at the beginning is related to the error on the emulator but decided to include it just in case.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sample.project"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="21" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity android:configChanges="orientation|keyboardHidden"
android:name=".MyPhoneGapActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Try to delete all your AVD files from your root folder or by AVD manager if you are able to get in. Then, restart Eclipse.

Failed to run aapt dump badging - Google play store

I can't upload my application to the Play Store.
When I upload the file.apk, I recive this error:
Failed to run aapt dump badging: W/ResourceType(17873):
Bad XML block: header size 28024 or total size 1702240364 is larger than data size 2004
ERROR: AndroidManifest.xml is corrupt
The application is signed with jarsigner and i used the zipalign to align this file. Also I use phonegap to create the apk.
This is the code of AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.naica.enciclopedia"
android:versionName="1.0.0"
android:versionCode="1">
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<application android:icon="#drawable/icon" android:label="#string/app_name" android:debuggable="false" android:theme="#style/MeDroidTheme">
<activity android:name=".Naica" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.phonegap.DroidGap" android:label="#string/app_name"android:configChanges="orientation|keyboardHidden">
<intent-filter></intent-filter>
</activity>
</application><uses-sdk android:minSdkVersion="7" />
</manifest>
Greetings!.
It turns out that <uses-permission android:name="android.permission.RECORD_VIDEO" /> is nowhere to be found here. Take a look at the link I provided you and remove that from the manifest. I think that this functionnality is covered by <uses-permission android:name="android.permission.CAMERA" />.

PhoneGap orientation change crash even with Manifest changes

I've seen lots of references or similar questions, but all of them teaches me to do this:
Add "android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" into the
But it's done and on orientation change, the app crashes. I tried to follow every single tip and it doesn't work.
This is my manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.guia.peixe"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is the final version of the code, when it's done, I get an error:
Description Resource Path Location Type error: Error: String types not allowed (at 'configChanges' with value 'orientation|keyboardHidden|keyboard|screenSize|locale'). AndroidManifest.xml /G‌​uia do Peixe line 34 Android AAPT Problem
But the example on Cordova's documentation points out to this, and no change I make into the string correct the error.
Thank you
That's because your XML is not valid. It should be:
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">
Note, you have the > in the wrong position.

Android Packaging: Error generating final archive resources.ap_

I'm currently trying to build a PhoneGap project I've been working on in Eclipse. However, when I try to build and run the project on the Android Emulator, I get the following error...
Error generating final archive: Failed to add
/Users/me/Projects/MyApp/bin/resources.ap_ Unknown Android Packaging Problem
I've cleaned the project several times, removed the resources.ap_ file, as well as the contents of the gen directory.
Anything else I can try? Much appreciated.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.app.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.INTERNET" />
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:configChanges="orientation|keyboardHidden"
>
<activity
android:name=".MyApp_AndroidActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.phonegap.DroidGap"
android:label="#string/app_name"
android:configChanges="orientation|keyboardHidden" >
<intent-filter> </intent-filter>
</activity>
</application>
</manifest>
Fix found. Turns out I had a tar file in my assets folder that I had left there by mistake. Removing it worked a treat!
First of all your manifest file does not have a starting application tag.Its a typo maybe..
Correct that.Secondly
Try adding the permissions
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
Add then let me know whether it works
In my case it was an image resource file with name like "some_resource_name Copy". Build goes well, but on launch this error appeared.
add
<uses-permission android:name="android.permission.SEND_SMS" />
after
<uses-permission android:name="android.permission.INTERNET" />
to manifest file.

Phonegap app crashes when switched orientation even with AndroidManifest changes

Here's my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mappp.mobile"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.hardware.camera" />
<uses-permission android:name="android.hardware.camera.autofocus" />
<uses-sdk android:minSdkVersion="13" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:debuggable="true"
android:configChanges="orientation|screenSize|keyboardHidden" >
<activity
android:label="#string/app_name"
android:name=".MAppHDActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.phonegap.DroidGap"
android:label="#string/app_name"
android:configChanges="orientation|screenSize|keyboardHidden" >
<intent-filter>
</intent-filter>
</activity>
</application>
</manifest>
I'm using Phonegap 1.3.0 and jquerymobile.
My test device is a Samsung Galaxy Tab 8.9 with HC v3.2.
I've read ALMOST every forum with the same issue. It still fails when i rotate the screen.
There's a warning right after the app crashes in debug mode: webcore: Can't get the veiwWidth after the first layout.
In your case the attribute android:configChanges="orientation|screenSize|keyboardHidden" should go to the first <activity> tag and not the <application> tag.
For the other people having similar issues simply add screenSize to android:configChanges="orientation|keyboardHidden" or change the android:minSdkVersion attribute to 12 or lower.
A more detailed explanation of this behavior can be found here: http://groups.google.com/group/phonegap/msg/c771fffc4dd9daaf
Here's my solution
Add "screenSize" to the android:configChanges in each Activity tag (within the AnroidManifest.xml).
Like this:
android:configChanges="orientation|screenSize|keyboardHidden"
It solved my problem.

Categories

Resources