I’m currently using JSoup as external jar and the following snippet throws runtime exception in emulator and eventually app crashes:
Document doc = Jsoup.connect(“http://www.cnn.com”).get();
06-18 14:00:17.272: I/dalvikvm(424): Could not find method org.jsoup.Jsoup.connect, referenced from method com.pamir.ODeskActivity.getList
06-18 14:00:17.272: W/dalvikvm(424): VFY: unable to resolve static method 25: Lorg/jsoup/Jsoup;.connect (Ljava/lang/String;)Lorg/jsoup/Connection;
06-18 14:00:17.282: D/dalvikvm(424): VFY: replacing opcode 0×71 at 0×0007
06-18 14:00:17.892: D/AndroidRuntime(424): Shutting down VM
06-18 14:00:17.905: W/dalvikvm(424): threadid=1: thread exiting with uncaught exception (group=0×40014760)
06-18 14:00:17.912: E/AndroidRuntime(424): FATAL EXCEPTION: main
06-18 14:00:17.912: E/AndroidRuntime(424): java.lang.NoClassDefFoundError: org.jsoup.Jsoup
06-18 14:00:17.912: E/AndroidRuntime(424): at com.pamir.ODeskActivity.getList(ODeskActivity.java:24)
Here is the manifest:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".ODeskActivity"
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>
What am I doing wrong? Any help is appreciated.
Make certain your JSoup jar file is exported along with the rest of your code.
Right click Project
Java Build Path
Order and Export
Check the box next your Jsoup jar entry.
Then reload the app onto your emulator or device.
To extend what forgivengod said.
Also.
Right click Project
Click Android Tools
Click Fix Project Properties
And.
Click Project
Clean
Related
hellow
i am trying to integrate the payment gateway of stripe and i am getting this error.
My Menifest file is as below:
manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.saubhagyam.paymentstripeintegration">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<meta-data
android:name="com.google.android.gms.wallet.api.enabled"
android:value="true" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
and my logcat is:
05-03 18:08:45.184 3425-3425/? D/dalvikvm: Late-enabling CheckJNI
05-03 18:08:45.264 3425-3425/com.example.saubhagyam.paymentstripeintegration D/AndroidRuntime: Shutting down VM
05-03 18:08:45.264 3425-3425/com.example.saubhagyam.paymentstripeintegration W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x94cabb20)
05-03 18:13:45.394 3425-3425/? I/Process: Sending signal. PID: 3425 SIG: 9
I have changed the whole way of implementing by integrating the stripe input method so it is giving me the inbuilt functionality and i cna use it sucessfully.
Thanks.
I am trying to test the tic-tac-toe in eclipse. It compiles and deploys to emulator device (AVD) but no matter what version of Android I use, the application deployed says: Application Stopped. Close it. Is there any specific setting I should follow?
Note: I already setup the Eclipse environment, add libraries, etc.
Thanks!
Here is the log error:
01-16 01:07:35.994: E/AndroidRuntime(883): FATAL EXCEPTION: main
01-16 01:07:35.994: E/AndroidRuntime(883): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.google.cast.samples.tictactoe/com.google.cast.samples.tictactoe.GameActivity}: java.lang.ClassNotFoundException: Didn't find class "com.google.cast.samples.tictactoe.GameActivity" on path: DexPathList[[zip file "/data/app/com.google.cast.samples.tictactoe-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.google.cast.samples.tictactoe-1, /system/lib]]
01-16 01:07:35.994: E/AndroidRuntime(883): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
01-16 01:07:35.994: E/AndroidRuntime(883): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
01-16 01:07:35.994: E/AndroidRuntime(883): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-16 01:07:35.994: E/AndroidRuntime(883): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.cast.samples.tictactoe.GameActivity" on path: DexPathList[[zip file "/data/app/com.google.cast.samples.tictactoe-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.google.cast.samples.tictactoe-1, /system/lib]]
01-16 01:07:35.994: E/AndroidRuntime(883): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
Thanks Ali. Here is the manifest, but I see there is a match of class and activity.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.cast.samples.tictactoe"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature
android:name="android.hardware.wifi"
android:required="true" >
</uses-feature>
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat" >
<activity
android:name=".GameActivity"
android:configChanges="orientation|keyboardHidden"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Exception states that it didn't find your GameActivity class. Check your Manifest and see if the name given there as the launcher activity (GameActivity) matches with the class that you have in your package, check the package names, etc. The exception has nothing to do (at least the piece that you have shown) with Cast.
Thanks for all the help. I solved by silly configuration. I created a libs folder and copied under GoogleCastSDKAndroid.jar (marked as Private Library). Compiled and it worked perfect!
Now, I just learned the casting function can't work because AVD runs a different IP address (in my case registered a 10.0.2.15) than my wifi segment (192.168.1.x). Therefore, the AVD can't see a chrome device.
I hope this last conclusion helps other people. The first was a mistake of configuration.
I get the following error from the emulator in Eclipse when I run an Android application...
"The application has stopped unexpectedly. Please try again"
There are no error icons appearing in the project folder in Eclipse. I have already tried...
Cleaning the Project
Android Tools > Fix Project Properties
Updating the Build Path
My Error Log is saying...
"java.lang.RuntimeException: Unable to instantiate activity ComponentInfo..."
The Error Log goes onto say...
"Caused by: java.lang.ClassNotFoundException..."
Just to note that I do not have a "Build.xml" file in my project folder but instead a "apktool.yml" if this makes any difference.
Any suggestions??
EDIT:
Here's the manifest file...
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="61" android:versionName="1.2.2" package="com.__.__"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:label="#string/app_name" android:icon="#drawable/ic_launcher">
<activity android:label="#string/app_name" android:name=".MTActivity" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="#string/app_name" android:name=".RCActivity" android:screenOrientation="portrait" />
...
Errors generated LogCat...
E/AndroidRuntime(6220): FATAL EXCEPTION: main
E/AndroidRuntime(6220): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.ir.mtools/com.ir.mtools.MTActivity}: java.lang.ClassNotFoundException:
com.irtza.pulmtools.MTActivity in loader dalvik.system.PathClassLoader[/data/app/com.ir.mtools-1.apk]
E/AndroidRuntime(6220): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
E/AndroidRuntime(6220): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
E/AndroidRuntime(6220): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime(6220): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
E/AndroidRuntime(6220): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(6220): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime(6220): at android.app.ActivityThread.main(ActivityThread.java:3687)
E/AndroidRuntime(6220): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(6220): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(6220): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
E/AndroidRuntime(6220): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
E/AndroidRuntime(6220): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(6220): Caused by: java.lang.ClassNotFoundException: com.ir.mtools.MTActivity in loader dalvik.system.PathClassLoader[/data/app/com.ir.mtools-1.apk]
Whenever this happens it means your application has encountered a runtime exception, which means no errors will show up at compile time. In this case I'm guessing you have not declared the activity in the AndroidManifest.xml file, but without seeing more code that's only a guess.
java.lang.ClassNotFoundException: com.ir.mtools.MTActivity
Is com.ir.mtools.MTActivity this part of some library? if so have you included it in your build path ?
I am working on creating my own Android JAR file, this JAR will contain Activities which I need to call however I keep getting a NoClassDefFound error. It is only an issue with Activities contained in the JAR, any other objects called from the external JAR work fine.
Below are the steps I have taken when creating this JAR
I created a new library project called LibraryTest, and placed one Activity in it called LibraryActivity, which has a basic layout called librarymain.xml with some random text.
I have marked this project as a library, retrieved the JAR from the bin folder, I then created new project called TestAddLibrary. I added the JAR file to the lib folder, I then added the librarymain.xml from the LibraryTest project to the layout folder of the TestAddLibrary project.
I then added the the LibraryActivity to the manifest of the new project. Manifest looks like this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testaddlibrary"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="10" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.testaddlibrary.MainActivity"
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.example.librarytest.LibraryActivity"
>
</activity>
</application>
</manifest>
Then in the main activity of the new project, I have this
package com.example.testaddlibrary;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.example.librarytest.LibraryActivity;
public class MainActivity extends Activity
{
Button but;
Context context;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context = this;
but = (Button) findViewById(R.id.butNext);
but.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v)
{
Intent i = new Intent(MainActivity.this, LibraryActivity.class);
startActivity(i);
}
});
}
}
When I click the button to launch the LibraryActivity which is stored in the JAR file, I get this error
07-10 09:20:24.798: E/AndroidRuntime(28195): FATAL EXCEPTION: main
07-10 09:20:24.798: E/AndroidRuntime(28195): java.lang.NoClassDefFoundError: com.example.librarytest.R$layout 07-10
09:20:24.798: E/AndroidRuntime(28195): at com.example.librarytest.LibraryActivity.onCreate(LibraryActivity.java:20)
07-10 09:20:24.798: E/AndroidRuntime(28195): at android.app.Activity.performCreate(Activity.java:5104) 07-10
09:20:24.798: E/AndroidRuntime(28195): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-10 09:20:24.798: E/AndroidRuntime(28195): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-10 09:20:24.798: E/AndroidRuntime(28195): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-10 09:20:24.798: E/AndroidRuntime(28195): at android.app.ActivityThread.access$600(ActivityThread.java:141) 07-10
09:20:24.798: E/AndroidRuntime(28195): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-10 09:20:24.798: E/AndroidRuntime(28195): at android.os.Handler.dispatchMessage(Handler.java:99) 07-10
09:20:24.798: E/AndroidRuntime(28195): at android.os.Looper.loop(Looper.java:137) 07-10 09:20:24.798:
E/AndroidRuntime(28195): at android.app.ActivityThread.main(ActivityThread.java:5041) 07-10
09:20:24.798: E/AndroidRuntime(28195): at java.lang.reflect.Method.invokeNative(Native Method) 07-10
09:20:24.798: E/AndroidRuntime(28195): at java.lang.reflect.Method.invoke(Method.java:511) 07-10 09:20:24.798:
E/AndroidRuntime(28195): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-10 09:20:24.798: E/AndroidRuntime(28195): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 07-10
09:20:24.798: E/AndroidRuntime(28195): at dalvik.system.NativeStart.main(Native Method)
I have read several questions on StackOverflow regarding this issue but nothing I have read has helped. I have the latest version of ADT Eclipse plugin, I have made sure that under Order and Export, I have ticked Android dependencies and Private Libraries.
Anyone have any idea what is causing this issue? Any help would be much appreciated!!
Edit: Forgot to mention other reason I am doing this is that I require my code to be hidden so I can share this out to other people without them seeing my code
You cannot package resources into jar files.
You can package pure java files that do not refer to any resources as jars.
In your case you need to reference the library project in your android project.
Library Projects
These projects contain shareable Android source code and resources that you can reference in Android projects. This is useful when you have common code that you want to reuse. Library projects cannot be installed onto a device, however, they are pulled into the .apk file at build time.
http://developer.android.com/tools/projects/index.html
To the question in the comment the closest resource could find
You cannot export a library project to a JAR file
A library cannot be distributed as a binary file (such as a JAR file). This will be added in a future version of the SDK Tools.
How to create jar for Android Library Project
I have an app with ~11k active installs for which I sometimes receive ClassNotFoundExceptions that I can't explain. They look like this:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{name.of.my.MainActivityClass}: java.lang.ClassNotFoundException: name.of.my.MainActivityClass in loader dalvik.system.PathClassLoader[/mnt/asec/name.of.my-2/pkg.apk]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1743)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851)
at android.app.ActivityThread.access$1500(ActivityThread.java:132)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4293)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: name.of.my.MainActivityClass in loader dalvik.system.PathClassLoader[/mnt/asec/name.of.my-2/pkg.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.app.Instrumentation.newActivity(Instrumentation.java:1040)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1735)
... 11 more
I received some of these exceptions from users that updated my app (not only for the most recent version), so I think it is not a problem that is specific to some phones as the app worked for them before.
I got these exception reports for my main activity class, a receiver class and a BackupAgent class.
All of those classes are always instantiated directly from Android. My Manifest file looks like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="name.of.my"
android:versionCode="20"
android:versionName="1.10.2"
android:installLocation="auto">
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8" />
<application android:icon="#drawable/icon" android:label="#string/app_name" android:backupAgent="name.of.my.OwnBackupAgent">
<activity android:name="name.of.my.MainActivityClass"
android:label="#string/app_name"
android:theme="#style/MyTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="name.of.my.OwnReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.media.RINGER_MODE_CHANGED" />
</intent-filter>
</receiver>
</application>
</manifest>
After searching the net for some hours, the most likely explanations I found are:
it might be related to moving the app to SD card while there are still some services running (but the android dev guide says that all services are canceled in this case, and it doesn't explain why my main activity class suddenly can't be found anymore)
the .apk might be corrupted after updating via the android market. Could this be true? If yes, what can I do against it - if not, what else might be the problem?