I am working on an application that reads in data from an RSS feed. I did not develop the application, I am trying to fix a bug causing it to stop working. When I attempt to run it on my computer using an emulator my logcat displays the following:
Can anyone shed some light on the issue? It seems to be telling me It cannot find a class called NewsRssActivity but I can clearly see it listed in the project explorer window.
05-20 10:26:51.378: E/AndroidRuntime(1027): FATAL EXCEPTION: main
05-20 10:26:51.378: E/AndroidRuntime(1027): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.newsrss.Feed/com.newsrss.Feed.NewsRssActivity}: java.lang.ClassNotFoundException: com.newsrss.Feed.NewsRssActivity
05-20 10:26:51.378: E/AndroidRuntime(1027): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
05-20 10:26:51.378: E/AndroidRuntime(1027): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-20 10:26:51.378: E/AndroidRuntime(1027): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-20 10:26:51.378: E/AndroidRuntime(1027): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-20 10:26:51.378: E/AndroidRuntime(1027): at android.os.Handler.dispatchMessage(Handler.java:99)
05-20 10:26:51.378: E/AndroidRuntime(1027): at android.os.Looper.loop(Looper.java:137)
05-20 10:26:51.378: E/AndroidRuntime(1027): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-20 10:26:51.378: E/AndroidRuntime(1027): at java.lang.reflect.Method.invokeNative(Native Method)
05-20 10:26:51.378: E/AndroidRuntime(1027): at java.lang.reflect.Method.invoke(Method.java:511)
05-20 10:26:51.378: E/AndroidRuntime(1027): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-20 10:26:51.378: E/AndroidRuntime(1027): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-20 10:26:51.378: E/AndroidRuntime(1027): at dalvik.system.NativeStart.main(Native Method)
05-20 10:26:51.378: E/AndroidRuntime(1027): Caused by: java.lang.ClassNotFoundException: com.newsrss.Feed.NewsRssActivity
05-20 10:26:51.378: E/AndroidRuntime(1027): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-20 10:26:51.378: E/AndroidRuntime(1027): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-20 10:26:51.378: E/AndroidRuntime(1027): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-20 10:26:51.378: E/AndroidRuntime(1027): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
05-20 10:26:51.378: E/AndroidRuntime(1027): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
05-20 10:26:51.378: E/AndroidRuntime(1027): ... 11 more
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.newsrss.Feed" android:versionCode="2" android:versionName="1.1">
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="15"
android:maxSdkVersion="17" />
<uses-feature android:glEsVersion="0x00020000"
android:required="true" />
<permission android:name="com.newsrss.Feed.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.newsrss.Feed.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<application android:label="#string/app_name" android:icon="#drawable/app_icon"
android:theme="#style/Theme.Sherlock.Light.NoActionBar">
<activity android:name="NewsRssActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.newsrss.Feed.DetailsArticle" />
<activity android:name="com.newsrss.Feed.DetailsPodcast" />
<activity android:name="com.newsrss.Feed.DetailsJobs" />
<activity android:name="com.newsrss.Feed" />
<activity android:name="com.newsrss.Feed.Legal" />
<activity android:name="com.newsrss.Feed.SearchActivity"
android:windowSoftInputMode="adjustPan" />
<activity android:name="com.newsrss.Feed.DetailsSearch" />
<activity android:label="#string/app_name" android:name="com.facebook.LoginActivity" />
<activity android:name="com.newsrss.Feed.MapActivity" />
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="#string/app_id" />
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCHdfGghvsiLqmv6e_jUCnPfBW3FjZ7YYI" />
</application>
</manifest>
NewsRssActivity.java
package com.newsrss.Feed;
import android.app.Dialog;
import android.app.LoaderManager;
import android.app.ProgressDialog;
import android.content.*;
import android.content.pm.ActivityInfo;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
import com.facebook.Session;
import com.fortysevendeg.swipelistview.BaseSwipeListViewListener;
import com.fortysevendeg.swipelistview.SwipeListView;
import com.google.analytics.tracking.android.EasyTracker;
import com.slidingmenu.lib.SlidingMenu;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class NewsRssActivity extends shaerToSocial {
Check if your Activity is defined in the Manifest:
<activity
android:name="com.newsrss.Feed.NewsRssActivity">
</activity>
Related
I would like any help i can get. I am really bad at this and i have no idea what am doing.
Here is the logcat
And here is the error in emulator
EDIT
Here is the code in AndroidManifest
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:hardwareAccelerated="true">
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<activity
android:name="com.example"
android:label="#string/app_name"
android:hardwareAccelerated="true"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I don't really know what an activity name is but here is some code from activity.java
import java.io.IOException;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.res.AssetFileDescriptor;
import android.util.Log;
import android.view.KeyEvent;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import com.google.analytics.tracking.android.EasyTracker;
import com.google.ads.*;
import com.google.ads.AdRequest.ErrorCode;
#SuppressLint({ "SetJavaScriptEnabled", "JavascriptInterface" })
public class activity extends Activity implements AdListener {
public MediaPlayer player = new MediaPlayer();
public WebView webView;
AssetFileDescriptor afd = null;
private InterstitialAd interstitial;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
and
this.webView = ((WebView)findViewById(R.id.webView));
this.webView.getSettings().setJavaScriptEnabled(true);
this.webView.setWebChromeClient(new WebChromeClient());
this.webView.addJavascriptInterface(this, "activity");
this.webView.loadUrl("file:///android_asset/index.html");
Thanks so much for the help man
I changed
<activity android:name="com.google.ads.AdActivity"
to
<activity android:name="com.example.Activity"
saved, cleaned and tried to run it again but it still gave me appname has stopped working
Here is logcat
11-08 20:50:48.770: W/dalvikvm(1342): threadid=1: thread exiting with uncaught exception (group=0x41465700)
11-08 20:50:48.810: E/AndroidRuntime(1342): FATAL EXCEPTION: main
11-08 20:50:48.810: E/AndroidRuntime(1342): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example/com.example}: java.lang.ClassNotFoundException: Didn't find class "com.example" on path: DexPathList[[zip file "/data/app/com.example-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example-2, /system/lib]]
11-08 20:50:48.810: E/AndroidRuntime(1342): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
11-08 20:50:48.810: E/AndroidRuntime(1342): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
11-08 20:50:48.810: E/AndroidRuntime(1342): at android.app.ActivityThread.access$600(ActivityThread.java:141)
11-08 20:50:48.810: E/AndroidRuntime(1342): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
11-08 20:50:48.810: E/AndroidRuntime(1342): at android.os.Handler.dispatchMessage(Handler.java:99)
11-08 20:50:48.810: E/AndroidRuntime(1342): at android.os.Looper.loop(Looper.java:137)
11-08 20:50:48.810: E/AndroidRuntime(1342): at android.app.ActivityThread.main(ActivityThread.java:5103)
11-08 20:50:48.810: E/AndroidRuntime(1342): at java.lang.reflect.Method.invokeNative(Native Method)
11-08 20:50:48.810: E/AndroidRuntime(1342): at java.lang.reflect.Method.invoke(Method.java:525)
11-08 20:50:48.810: E/AndroidRuntime(1342): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11-08 20:50:48.810: E/AndroidRuntime(1342): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-08 20:50:48.810: E/AndroidRuntime(1342): at dalvik.system.NativeStart.main(Native Method)
11-08 20:50:48.810: E/AndroidRuntime(1342): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example" on path: DexPathList[[zip file "/data/app/com.example-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example-2, /system/lib]]
In your manifest, you specify your activity name as com.example where it should actually be the name of your activity: com.example.activity. Change this:
<activity
android:name="com.example"
To this:
<activity
android:name="com.example.activity"
I have finally finished my app and everything was working fine. I went back to add in the admob stuff and now it will not start in the emulator. it says it successfully installed the app on the emulator but it does not launch and the icon is not visible to try to manually run. I think the manifest is where my error is but I am unsure.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidsleepmachine.gamble"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.WAKE_LOCK" >
</uses-permission>
<uses-permission android:name="android.permission.Internet" >
</uses-permission>
<uses-permission android:name="android.permission.Write_EXTERNAL_STORAGE" >
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" >
</uses-permission>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"
></activity>
<activity
android:name=".Splash"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog" >
<intent-filter>
<action android:name="com.AndroidSleepMachine.gamble.SPLASH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.AndroidSleepMachine.gamble.HOME"
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=".About"
android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog" >
<intent-filter>
<action android:name="com.AndroidSleepMachine.gamble.ABOUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.androidsleepmachine.gamble.Ship" />
<activity android:name="com.androidsleepmachine.gamble.OceanThunder" />
<activity android:name="com.androidsleepmachine.gamble.Ocean" />
<activity android:name="com.androidsleepmachine.gamble.Forest" />
<activity android:name="com.androidsleepmachine.gamble.Rain" />
<activity android:name="com.androidsleepmachine.gamble.Thunderbirds" />
<activity android:name="com.androidsleepmachine.gamble.Meditation" />
<activity android:name="com.androidsleepmachine.gamble.Focus" />
<activity android:name="com.androidsleepmachine.gamble.Pain" />
</application>
</manifest>
logcat files
09-23 13:17:47.582: E/AndroidRuntime(1563): FATAL EXCEPTION: main
09-23 13:17:47.582: E/AndroidRuntime(1563): java.lang.RuntimeException: Unable to
instantiate activity
ComponentInfo{com.androidsleepmachine.gamble/com.AndroidSleepMachine.gamble.HOME}:
java.lang.ClassNotFoundException: com.AndroidSleepMachine.gamble.HOME
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread.access$600(ActivityThread.java:130)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.os.Looper.loop(Looper.java:137)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread.main(ActivityThread.java:4745)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
java.lang.reflect.Method.invokeNative(Native Method)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
java.lang.reflect.Method.invoke(Method.java:511)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
dalvik.system.NativeStart.main(Native Method)
09-23 13:17:47.582: E/AndroidRuntime(1563): Caused by:
java.lang.ClassNotFoundException: com.AndroidSleepMachine.gamble.HOME
09-23 13:17:47.582: E/AndroidRuntime(1563): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
java.lang.ClassLoader.loadClass(ClassLoader.java:501)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
java.lang.ClassLoader.loadClass(ClassLoader.java:461)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.Instrumentation.newActivity(Instrumentation.java:1053)
09-23 13:17:47.582: E/AndroidRuntime(1563): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
It looks like your main activity name is incorrect. Java is case sensitive and your application package name is
package="com.androidsleepmachine.gamble"
while your main activity class name is
com.AndroidSleepMachine.gamble.HOME
The ClassNotFoundException is being thrown because your Activity class name is incorrect in the manifest and isn't being found by the class loader.
It cannot find a class called:
com.AndroidSleepMachine.gamble.HOME
Why is "AndroidSleepMachine" using capital letters?
Why not just use:
android:name=".HOME"
...if your class is indeed called HOME.java? Case-sensitivity may be causing your issue.
com.AndroidSleepMachine.gamble.HOME is not the same as com.androidsleepmachine.gamble.HOME
I have developed test application Using worklight for android environment. When i test that on worklight server it works fine, but when i tried to run the same on android virtual device (AVD) it throws an error message like Sorry The application Test (process com.Test) has stopped unexpectedly. Please try again. and the application terminates.
I am using Eclipse 4.2 and android version for AVD is 2.3.3
What is the solution of this...???
`
06-21 10:59:28.407: W/dalvikvm(1209): Unable to resolve superclass of Lcom/Test/Test; (14)
06-21 10:59:28.407: W/dalvikvm(1209): Link of class 'Lcom/Test/Test;' failed
06-21 10:59:28.427: D/AndroidRuntime(1209): Shutting down VM
06-21 10:59:28.427: W/dalvikvm(1209): threadid=1: thread exiting with uncaught exception (group=0xb607d4f0)
06-21 10:59:28.467: E/AndroidRuntime(1209): FATAL EXCEPTION: main
06-21 10:59:28.467: E/AndroidRuntime(1209): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.Test/com.Test.Test}: java.lang.ClassNotFoundException: com.Test.Test in loader dalvik.system.PathClassLoader[/data/app/com.Test-1.apk]
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.os.Handler.dispatchMessage(Handler.java:99)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.os.Looper.loop(Looper.java:130)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-21 10:59:28.467: E/AndroidRuntime(1209): at java.lang.reflect.Method.invokeNative(Native Method)
06-21 10:59:28.467: E/AndroidRuntime(1209): at java.lang.reflect.Method.invoke(Method.java:507)
06-21 10:59:28.467: E/AndroidRuntime(1209): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-21 10:59:28.467: E/AndroidRuntime(1209): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-21 10:59:28.467: E/AndroidRuntime(1209): at dalvik.system.NativeStart.main(Native Method)
06-21 10:59:28.467: E/AndroidRuntime(1209): Caused by: java.lang.ClassNotFoundException: com.Test.Test in loader dalvik.system.PathClassLoader[/data/app/com.Test-1.apk]
06-21 10:59:28.467: E/AndroidRuntime(1209): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
06-21 10:59:28.467: E/AndroidRuntime(1209): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
06-21 10:59:28.467: E/AndroidRuntime(1209): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
06-21 10:59:28.467: E/AndroidRuntime(1209): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
06-21 10:59:28.467: E/AndroidRuntime(1209): ... 11 more
`
Manifest code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.Test"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="false"
android:normalScreens="true"
android:largeScreens="false"
android:resizeable="false"
android:anyDensity="false"
/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<!-- Push permissions -->
<permission android:name="com.Test.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.Test.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:label="#string/app_name"
android:debuggable="true"
android:icon="#drawable/icon" >
<activity android:name=".Test"
android:label="#string/app_name"
android:configChanges="orientation|keyboardHidden"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.Test.Test.NOTIFICATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Preference Activity -->
<activity
android:name="com.worklight.common.WLPreferences"
android:label="Worklight Settings">
</activity>
<!-- Push service -->
<!-- In order to use the c2dm library, an application must declare a class with the name C2DMReceiver, in its own package, extending com.google.android.c2dm.C2DMBaseReceiver
It must also include this section in the manifest, replacing "com.google.android.apps.chrometophone" with its package name. -->
<service android:name=".GCMIntentService" />
<!-- Only google service can send data messages for the app. If permission is not set - any other app can generate it -->
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<!-- Receive the actual message -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.Test" />
</intent-filter>
<!-- Receive the registration id -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.Test" />
</intent-filter>
</receiver>
</application>
<uses-sdk android:minSdkVersion="10" />
</manifest>
Test.Java
package com.Test;
import android.os.Bundle;
import com.worklight.androidgap.WLDroidGap;
public class Test extends WLDroidGap {
#Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
}
/**
* onWLInitCompleted is called when the Worklight runtime framework initialization is complete
*/
#Override
public void onWLInitCompleted(Bundle savedInstanceState){
super.loadUrl(getWebMainFilePath());
// Add custom initialization code after this line
}
}
AVD 2.3.x has a known bug which prevents it from running WebView based apps. Use OS 4.x or 2.2.
am getting this exception:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{business.premium/business.premium.Problemio}:
java.lang.ClassNotFoundException: business.premium.Problemio
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
... 11 more
java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
it says that class is not there, but it IS there. I tried to configure things in my project's build path, but not too sure what to tweak there.
And here is how I start my Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="business.premium"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomTheme"
android:name="MyApplication"
android:debuggable="true">
<activity
android:name=".Problemio"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Any thoughts on how to solve this, or what to look into? Thanks!
Its because you specified the "android:name" attribute in the application node in the manifest file.
Do not use the android:name attribute!
It, misleadingly, does not have anything to do with the name of your app and is actually the name of an extra class to load before loading your application. That's why you are getting the ClassNotFoundException.
Remove it and it should work:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:description="#string/help_text" >
This answer is taken from: java.lang.ClassNotFoundException on working app
I'm trying to create a PDF file when I press a button. I'm using iText library.
My activity:
package com.pdf;
import java.io.FileOutputStream;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
public class PDFActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void GenerarPDF(View view)throws Exception{
Document document=new Document();
PdfWriter.getInstance(document,new FileOutputStream("generando.pdf"));
document.open();
document.add(new Paragraph("Testing testing and testing"));
document.close();
}
}
My xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" android:background="#555">
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="34dp"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="#+id/Submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/editText1"
android:layout_centerHorizontal="true"
android:layout_marginTop="23dp"
android:onClick="GenerarPDF"
android:text="Button" />
</RelativeLayout>
My manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pdf"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
<uses-permission android:name="android.permission.READ_FRAME_BUFFER"/>
<uses-permission android:name="android.permission.BIND_INPUT_METHOD"/>
<uses-permission android:name="android.permission.INSTALL_LOCATION_PROVIDER"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".PDFActivity"
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>
And the log cat:
05-31 12:08:58.778: E/AndroidRuntime(662): FATAL EXCEPTION: main
05-31 12:08:58.778: E/AndroidRuntime(662): java.lang.IllegalStateException: Could not execute method of the activity
05-31 12:08:58.778: E/AndroidRuntime(662): at android.view.View$1.onClick(View.java:3044)
05-31 12:08:58.778: E/AndroidRuntime(662): at android.view.View.performClick(View.java:3511)
05-31 12:08:58.778: E/AndroidRuntime(662): at android.view.View$PerformClick.run(View.java:14105)
05-31 12:08:58.778: E/AndroidRuntime(662): at android.os.Handler.handleCallback(Handler.java:605)
05-31 12:08:58.778: E/AndroidRuntime(662): at android.os.Handler.dispatchMessage(Handler.java:92)
05-31 12:08:58.778: E/AndroidRuntime(662): at android.os.Looper.loop(Looper.java:137)
05-31 12:08:58.778: E/AndroidRuntime(662): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-31 12:08:58.778: E/AndroidRuntime(662): at java.lang.reflect.Method.invokeNative(Native Method)
05-31 12:08:58.778: E/AndroidRuntime(662): at java.lang.reflect.Method.invoke(Method.java:511)
05-31 12:08:58.778: E/AndroidRuntime(662): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-31 12:08:58.778: E/AndroidRuntime(662): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-31 12:08:58.778: E/AndroidRuntime(662): at dalvik.system.NativeStart.main(Native Method)
05-31 12:08:58.778: E/AndroidRuntime(662): Caused by: java.lang.reflect.InvocationTargetException
05-31 12:08:58.778: E/AndroidRuntime(662): at java.lang.reflect.Method.invokeNative(Native Method)
05-31 12:08:58.778: E/AndroidRuntime(662): at java.lang.reflect.Method.invoke(Method.java:511)
05-31 12:08:58.778: E/AndroidRuntime(662): at android.view.View$1.onClick(View.java:3039)
05-31 12:08:58.778: E/AndroidRuntime(662): ... 11 more
05-31 12:08:58.778: E/AndroidRuntime(662): Caused by: java.lang.NoClassDefFoundError: com.itextpdf.text.Document
05-31 12:08:58.778: E/AndroidRuntime(662): at com.pdf.PDFActivity.GenerarPDF(PDFActivity.java:22)
05-31 12:08:58.778: E/AndroidRuntime(662): ... 14 more
Added logcat error:
05-31 15:26:00.411: E/dalvikvm(792): Could not find class 'com.itextpdf.text.Document', referenced from method com.pdf.PDFActivity.GenerarPDF
I think thats the real problem, but don't know the solution.
Where exactly are you trying to create the pdf file? I used the itextpdf-5.2.1.jar and was able to successfully create the pdf in the sd card. I added the following lines of codes to your program:
public void GenerarPDF(View view)throws Exception{
Document document=new Document();
File root = new File(Environment.getExternalStorageDirectory(), "Notes");
if (!root.exists()) {
root.mkdirs();
}
File gpxfile = new File(root, "generando.pdf");
PdfWriter.getInstance(document,new FileOutputStream(gpxfile));
document.open();
document.add(new Paragraph("Testing testing and testing"));
document.close();
}
Hope this answer helps.
EDIT:
The error you mentioned in your comment (06-01 23:32:37.178: E/AndroidRuntime(535): Caused by: java.io.FileNotFoundException: /generando.pdf: open failed: EROFS (Read-only file system)
) is exactly what I get when I run the code you provided. The reason being that you are not specifying the location where the new file can be created/stored. Use the GenerarPDF(View view) in have pasted over here and the program will create the new pdf.
Another cause for this error might be that you don't have an sd card in your device.
change file root to this line
File root = new File(android.os.Environment.getExternalStorageDirectory(), "Notes");
looks like you forgot to call generatePDF() from onCreate()...
hope it helps!