简体   繁体   English

无法实例化活动ComponentInfo android

[英]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] 01-05 18:35:42.754:E / AndroidRuntime(5814):java.lang.RuntimeException:无法在loader dalvik中实例化活动ComponentInfo {src.mynewfolder / mynewfolder.java}:java.lang.ClassNotFoundException:mynewfolder.mynewproj。 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 "." 但这部分在android清单文件xml:package =“src.mynewfolder” - 我必须放一个“。” (dot) somewhere or it says (点)在某处或它说

"Application package 'AndroidManifest.xml' must have a minimum of 2 segments." “应用程序包'AndroidManifest.xml'必须至少包含2个段。”

the "mynewfolder is inside src and mynewproj.java is inside mynewfolder. “mynewfolder在src里面,mynewproj.java在mynewfolder里面。

It's been * horrendous trying to set up this android phonegap environment. 它已经*可怕试图建立这种机器人的PhoneGap环境。 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 来自此网站: 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". 是说包的名称是由一个点分隔的两个部分,所以当我再次创建dicrectories时,我将包命名为thispackage.p,所有这一切都是在“thispackage”中创建一个名为“p”的新文件夹。

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] 01-05 19:04:06.944:E / AndroidRuntime(7019):java.lang.RuntimeException:无法实例化活动ComponentInfo {thispackage.p / thisproj.java}:java.lang.ClassNotFoundException:loader dalvik中的thisproj.java。 system.PathClassLoader [/data/app/thispackage.p-2.apk]

I've decided to forget about Phonegap and use titanium instead. 我决定忘记Phonegap并使用钛代替。

You are getting a ClassNotFoundException . 你得到一个ClassNotFoundException
If you are using some external libraries, make sure you added them to Build Path. 如果您使用的是某些外部库,请确保将它们添加到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... 看起来你有一个名为“thisproj.java”的类的引用,它在java中是一个无效的命名约定,会导致抛出此错误...

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. 在java中,所有类必须以大写字母开头,包含它的文件必须具有.java扩展名的相同名称。

For example: 例如:

public class ThisProj { ... }

Should be defined in a file called ThisProj.java 应该在名为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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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