Exception cast from a different project - android

Hey this is the weirdest problem i've ever encoutered,
I have 2 projects that's exactly the same each in a different project with a different package name.
Now i'm trying to run the 2nd project and i get a NullPointerException and when i press the error for it to send me to the line of code, it loads the same activity but in a different project.
Any idea why that happens?
This is my manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="shibby.koteret"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen" >
<activity
android:name=".TenKoteretActivity"
android:label="#string/app_name"
android:configChanges="keyboardHidden|orientation"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="#string/chosen_image" android:name="selectedImageActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait"
/>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
</manifest>
Which is exactly the same in both projects besides package name and main activity name.
This is the logcat :
06-26 21:02:38.324: E/AndroidRuntime(5237): FATAL EXCEPTION: main
06-26 21:02:38.324: E/AndroidRuntime(5237): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1886, result=-1, data=Intent { dat=content://media/external/images/media/45 }} to activity {shibby.koteret/shibby.koteret.selectedImageActivity}: java.lang.NullPointerException
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.app.ActivityThread.deliverResults(ActivityThread.java:2536)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.app.ActivityThread.handleSendResult(ActivityThread.java:2578)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.app.ActivityThread.access$2000(ActivityThread.java:117)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:965)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.os.Looper.loop(Looper.java:123)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.app.ActivityThread.main(ActivityThread.java:3687)
06-26 21:02:38.324: E/AndroidRuntime(5237): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 21:02:38.324: E/AndroidRuntime(5237): at java.lang.reflect.Method.invoke(Method.java:507)
06-26 21:02:38.324: E/AndroidRuntime(5237): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
06-26 21:02:38.324: E/AndroidRuntime(5237): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
06-26 21:02:38.324: E/AndroidRuntime(5237): at dalvik.system.NativeStart.main(Native Method)
06-26 21:02:38.324: E/AndroidRuntime(5237): Caused by: java.lang.NullPointerException
06-26 21:02:38.324: E/AndroidRuntime(5237): at shibby.koteret.selectedImageActivity.onActivityResult(selectedImageActivity.java:196)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.app.Activity.dispatchActivityResult(Activity.java:3908)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.app.ActivityThread.deliverResults(ActivityThread.java:2532)
06-26 21:02:38.324: E/AndroidRuntime(5237): ... 11 more
I don't think it's related, but as asked this is the relavent Java code (Errors on setContentView):
setContentView(R.layout.chosen_image);
ImageView imageView = (ImageView)this.findViewById(R.id.chosenImage2);
imageView.setImageBitmap(bitmap);
What i've checked :
The 2nd project packages the activity to the write project
I am not importing any thing from the 1st project package
Could this be an Eclipse error only? Anyone ever seen such a problem?
I was thinking, as the error is on an XML file, could it be somehow related to the R?

Well, what worked for me was i closed the 1st project and then Eclipse sent me to the right NullPointerException.
Still no idea why that happened, but that did the trick for me.

Related

Android Flow example crashes with ClassNotFoundException

I'm Naive in Android development. I tried to use flow/mortar for development and stuck with an exception.
Here's what I did. In Eclipse, I chose New (Crtl N) -> Android Project from existing code and imported the flow sample downloaded from the square flow website https://github.com/square/flow/.
Eclipse marked errors in all the files as the package name was not matching the file's location. So to fix the package mismatch issue, I moved the files from : \flow-master\flow-sample\src\main\java\com\example\flow to : \flow-master\flow-sample\src\com\example\flow.
After this, I got some more errors saying 'Unresolved to a Type' which I fixed by importing proper jar files. Now all the errors are cleared and I tried to install and launch the app.
The app crashes as soon as we launch with the Logcat error below:
E/AndroidRuntime(5438): FATAL EXCEPTION: main
E/AndroidRuntime(5438): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.flow/com.example.flow.MainActivity}: java.lang.ClassNotFoundException: com.example.flow.MainActivity
E/AndroidRuntime(5438): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1888)
E/AndroidRuntime(5438): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1989)
E/AndroidRuntime(5438): at android.app.ActivityThread.access$600(ActivityThread.java:126)
E/AndroidRuntime(5438): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1155)
E/AndroidRuntime(5438): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(5438): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(5438): at android.app.ActivityThread.main(ActivityThread.java:4482)
E/AndroidRuntime(5438): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(5438): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(5438): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
E/AndroidRuntime(5438): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
E/AndroidRuntime(5438): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(5438): Caused by: java.lang.ClassNotFoundException: com.example.flow.MainActivity
E/AndroidRuntime(5438): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E/AndroidRuntime(5438): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime(5438): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime(5438): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
E/AndroidRuntime(5438): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
E/AndroidRuntime(5438): ... 11 more
The error says that the file MainActivity is not found even when the file is available in the path com.example.flow.. Can someone please help me understand what the issue is?
Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flow"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18"/>
<application
android:icon="#drawable/flow_icon">
<activity
android:label="Flow"
android:name="com.example.flow.MainActivity"
android:theme="#android:style/Theme.Holo.Light.DarkActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>

Android - exception launching project on start after copying a lot of code over from another project

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

Android ClassNotFoundException on published app

I have an application thats been published awhile on Google play, I have been fixing reported bugs as they come in but recently this log below came in and I don't know what to make of it:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mammothtooth.flightinfo/com.mammothtooth.flightinfo.ui.SplashActivity}: java.lang.ClassNotFoundException: com.mammothtooth.flightinfo.ui.SplashActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/mnt/asec/com.mammothtooth.flightinfo-1/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:4277)
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:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.mammothtooth.flightinfo.ui.SplashActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/mnt/asec/com.mammothtooth.flightinfo-1/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)
Does anyone know anything about this type of error log? My SplashScreenActivity is there and its defined as the entry point of the application in the manifest as follows:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
<uses-library android:name="com.google.android.maps" />
<activity
android:label="#string/app_name"
android:name=".ui.SplashActivity"
android:theme="#android:style/Theme.NoTitleBar"
android:configChanges="keyboard|keyboardHidden|orientation"
android:screenOrientation="portrait">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Would the placing of the uses-library be an issue in the manifest?
I can't reproduce this issue on any of my android devices so any help is greatly appreciated in locating what might be the cause of this issue.

Crashing on layout.main

I have released my app to Market yesterday and I get a strange crash report telling me that it doesnt find the layout.main. If the layout wouldnt exist, I would wouldnt be able to start the app on my own device. Which is not the case. Too bad the report doesnt tell which device or Android version it is running on.
Maybe someone can download my app (mytaxicontrol - it's free) and tell me under which conditions its crashing or has an idea what the problem could be?
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mytaxicontrol/com.mytaxicontrol.MyTaxiControlActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030004
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
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:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030004
at android.content.res.Resources.getValue(Resources.java:892)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:1869)
at android.content.res.Resources.getLayout(Resources.java:731)
at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
at android.app.Activity.setContentView(Activity.java:1657)
at com.mytaxicontrol.MyTaxiControlActivity.onCreate(Unknown Source)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
In the manifest you should have added this because you do not need support for small screens devices as layout is not mentioned.
<supports-screens
android:smallScreens="false"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true" />
And your layout folder name should be
layout-normal
layout-large

ClassNotFoundException on Galaxy Tab (only)

I have a working Android application. It works on more than 500 different devices. The manifest is
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.decamps.droid.photoid" android:versionCode="5"
android:versionName="1.4">
<application android:icon="#drawable/icon" android:label="#string/app_label"
android:name="PhotoIDroid" android:description="#string/app_desc"
android:debuggable="FALSE">
But when it it launched from a Samsung Galaxy Tab, it doesn't start and crashes with:
java.lang.RuntimeException: Unable to
instantiate application
info.decamps.droid.photoid.PhotoIDroid:
java.lang.ClassNotFoundException:
info.decamps.droid.photoid.PhotoIDroid
in loader
dalvik.system.PathClassLoader[/data/app/info.decamps.droid.photoid-1.apk]
at
android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:670)
at
android.app.ActivityThread.handleBindApplication(ActivityThread.java:4483)
at
android.app.ActivityThread.access$3000(ActivityThread.java:135)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2181)
at
android.os.Handler.dispatchMessage(Handler.java:99)
at
android.os.Looper.loop(Looper.java:144)
at
android.app.ActivityThread.main(ActivityThread.java:4937)
at
java.lang.reflect.Method.invokeNative(Native
Method) at
java.lang.reflect.Method.invoke(Method.java:521)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at
dalvik.system.NativeStart.main(Native
Method) Caused by:
java.lang.ClassNotFoundException:
info.decamps.droid.photoid.PhotoIDroid
in loader
dalvik.system.PathClassLoader[/data/app/info.decamps.droid.photoid-1.apk]
at
dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at
java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at
java.lang.ClassLoader.loadClass(ClassLoader.java:532)
at
android.app.Instrumentation.newApplication(Instrumentation.java:945)
at
android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:660)
... 11 more
How an the Samsung Galaxy not find the application class?
Any clue on how to resolve this?
I have been able to reproduce tis crash on the Samsung Galaxy emulator.
I have removed the android:name attribute declaration from the AndroidManifest.xml and it now works.

Categories

Resources