在android中使用min3d加载.obj文件会产生java.lang.RuntimeException:无法实例化活动ComponentInfo

时间:2014-05-05 21:49:11

标签: android opengl-es classnotfoundexception 3dsmax min3d

我正在尝试将从3ds max生成的obj文件加载到android中并进行了以下编码,但收到了我解决但无法找到错误的错误。

Min3dTest.java

package com.min3dtest;
import android.os.Bundle;  
import android.app.Activity;  
import android.content.Intent;  
public class Min3dTest extends Activity {  
  /** Called when the activity is first created. */  
  @Override  
  public void onCreate(Bundle savedInstanceState)   
  {  
    super.onCreate(savedInstanceState);  
     this.startActivity( new Intent(this,Obj3DView.class));  
  }  
} 

Obj3DView.java

 package com.min3dtest;   
    import min3d.core.Object3dContainer;  
    import min3d.core.RendererActivity;  
    import min3d.parser.IParser;  
    import min3d.parser.Parser;  
    import min3d.vos.Light;  
    public class Obj3DView extends RendererActivity {  
      private Object3dContainer faceObject3D;  
      /** Called when the activity is first created. */  
      @Override  
      public void initScene()  
      {  
        scene.lights().add(new Light());  
        scene.lights().add(new Light());  
        Light myLight = new Light();  
        myLight.position.setZ(150);  
        scene.lights().add(myLight);  
        IParser myParser = Parser.createParser(Parser.Type.OBJ, getResources(), "com.example.min3dtest:raw/updatedfloor00_obj",true);  
        myParser.parse();  
        faceObject3D = myParser.getParsedObject();  
        faceObject3D.position().x = faceObject3D.position().y = faceObject3D.position().z = 0;  
        faceObject3D.scale().x = faceObject3D.scale().y = faceObject3D.scale().z = 0.009f;  
        // Depending on the model you will need to change the scale faceObject3D.scale().x = faceObject3D.scale().y = faceObject3D.scale().z = 0.009f;  
        scene.addChild(faceObject3D);  
      }  
      @Override  
      public void updateScene() {  
        faceObject3D.rotation().x += 0.5;  
        faceObject3D.rotation().z += 1;  
      }  
    }   

Min3dTest Manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.min3dtest"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        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.min3dtest.Obj3DView"   
       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>

</manifest>

logcat的

05-06 02:28:22.854: E/dalvikvm(27605): could not disable core file generation for pid 27605: Operation not permitted
05-06 02:28:23.018: D/AndroidRuntime(27605): Shutting down VM
05-06 02:28:23.018: W/dalvikvm(27605): threadid=1: thread exiting with uncaught exception (group=0x40018560)
05-06 02:28:23.197: E/AndroidRuntime(27605): FATAL EXCEPTION: main
05-06 02:28:23.197: E/AndroidRuntime(27605): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.min3dtest/com.example.min3dtest.Obj3DView}: java.lang.ClassNotFoundException: com.example.min3dtest.Obj3DView in loader dalvik.system.PathClassLoader[/data/app/com.example.min3dtest-1.apk]
05-06 02:28:23.197: E/AndroidRuntime(27605):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1618)
05-06 02:28:23.197: E/AndroidRuntime(27605):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1716)
05-06 02:28:23.197: E/AndroidRuntime(27605):    at android.app.ActivityThread.access$1500(ActivityThread.java:124)
05-06 02:28:23.197: E/AndroidRuntime(27605):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:968)
05-06 02:28:23.197: E/AndroidRuntime(27605):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-06 02:28:23.197: E/AndroidRuntime(27605):    at android.os.Looper.loop(Looper.java:130)
05-06 02:28:23.197: E/AndroidRuntime(27605):    at android.app.ActivityThread.main(ActivityThread.java:3806)
05-06 02:28:23.197: E/AndroidRuntime(27605):    at java.lang.reflect.Method.invokeNative(Native Method)
05-06 02:28:23.197: E/AndroidRuntime(27605):    at java.lang.reflect.Method.invoke(Method.java:507)
05-06 02:28:23.197: E/AndroidRuntime(27605):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-06 02:28:23.197: E/AndroidRuntime(27605):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-06 02:28:23.197: E/AndroidRuntime(27605):    at dalvik.system.NativeStart.main(Native Method)
05-06 02:28:23.197: E/AndroidRuntime(27605): Caused by: java.lang.ClassNotFoundException: com.example.min3dtest.Obj3DView in loader dalvik.system.PathClassLoader[/data/app/com.example.min3dtest-1.apk]
05-06 02:28:23.197: E/AndroidRuntime(27605):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
05-06 02:28:23.197: E/AndroidRuntime(27605):    at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
05-06 02:28:23.197: E/AndroidRuntime(27605):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-06 02:28:23.197: E/AndroidRuntime(27605):    at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-06 02:28:23.197: E/AndroidRuntime(27605):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1610)
05-06 02:28:23.197: E/AndroidRuntime(27605):    ... 11 more
05-06 02:28:29.400: I/Process(27605): Sending signal. PID: 27605 SIG: 9

1 个答案:

答案 0 :(得分:0)

我已经设法让它正常工作,但我不能肯定地说你的情况可能是什么问题。我看到的唯一与我的例子不同的是AndroidManifest.xml 我看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.a"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="19" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity   
   android:name=".Obj3DView"   
   android:label="@string/app_name">  
    </activity> 
    <activity
        android:name="com.example.a.Min3dTest"
        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>

</manifest>