简体   繁体   中英

Unable to instantiate activity ComponentInfo android

01-05 18:35:42.754: E/AndroidRuntime(5814): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{src.mynewfolder/mynewfolder.java}: java.lang.ClassNotFoundException: mynewfolder.mynewproj in loader dalvik.system.PathClassLoader[/data/app/src.mynewfolder-1.apk]

I know that this part looks weired:

{src.mynewfolder/mynewfolder.java}

But that part here in the android manifest file xml: package="src.mynewfolder" - I have to put a "." (dot) somewhere or it says

"Application package 'AndroidManifest.xml' must have a minimum of 2 segments."

the "mynewfolder is inside src and mynewproj.java is inside mynewfolder.

It's been * horrendous trying to set up this android phonegap environment. Why is it so difficult? I have had obstacles every step of the way.

Any help would be appreciated.

EDIT:

from this site: https://groups.google.com/forum/?fromgroups=#!topic/android-developers/tXX3eFCzpvM

is says that the name of the package is to be in two parts seperated by a dot, so when i created the dicrectories again I named the package thispackage.p and all that does is create a new folder called "p" inside "thispackage".

now when I run the app the exception is this:

01-05 19:04:06.944: E/AndroidRuntime(7019): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{thispackage.p/thisproj.java}: java.lang.ClassNotFoundException: thisproj.java in loader dalvik.system.PathClassLoader[/data/app/thispackage.p-2.apk]

I've decided to forget about Phonegap and use titanium instead.

You are getting a ClassNotFoundException .
If you are using some external libraries, make sure you added them to Build Path.

It looks like you have a reference to a class called "thisproj.java" which is an invalid naming convention in java and would result in this error being thrown...

In java all classes must begin with an upper case letter and the file containing it must have the same name with the .java extension.

For example:

public class ThisProj { ... }

Should be defined in a file called ThisProj.java

When you are referring to the class you must ensure you use the exact name of the class:

// Instantiate a ThisProj object
ThisProj thisProj = new ThisProj();

// static reference
ThisProj.someMethod();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM