我已经开始与android编程。这些应用程序启动崩溃快把我逼疯了。目前我有一个Android应用程序和一个Android库项目在eclipse。我在logcat
中得到以下错误Logcat
01-22 06:00:33.167: E/AndroidRuntime(25666): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.camerafilters/com.example.camerafilters.CameraMainActivity}: android.view.InflateException: Binary XML file line #12: Error inflating class org.lucasr.twowayview.TwoWayView
01-22 06:00:33.167: E/AndroidRuntime(25666): at com.example.camerafilters.CameraMainActivity.onCreate(CameraMainActivity.java:44)`
库为TwoWayView
。这是我的activity_main.xml
文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.example.camerafilters.CameraGLSurfaceView
android:id="@+id/CameraGLSurfaceView"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="8"/>
<org.lucasr.twowayview.TwoWayView
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ShaderList"
style="@style/TwoWayView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="2"
android:drawSelectorOnTop="false"
tools:context=".CameraMainActivity" />
</LinearLayout>
这是onCreate()
函数
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//_cameraGLView = new CameraGLSurfaceView(this, null);
// Create a GLSurfaceView instance and set it
// as the ContentView for this Activity.
setContentView(R.layout.activity_main);
_cameraGLView = (CameraGLSurfaceView) findViewById(R.id.CameraGLSurfaceView);
_renderer = _cameraGLView.getRenderer();
_renderer.setPreviewDimensions(_cameraGLView.getWidth(), _cameraGLView.getHeight());
// now setup list view of shader
_setupShaderListView();
}
让我知道是否需要更多的代码。应用程序在setContentView()
函数中崩溃。我有一个项目在相同的工作空间,使用相同的配置。该项目还使用一个GLSurfaceView
和TwoWayView
列表,该项目工作良好。
这里是stacktrace
CameraFilters [Android Application]
DalvikVM[localhost:8617]
Thread [<1> main] (Suspended (exception RuntimeException))
<VM does not provide monitor information>
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2308
ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2362
ActivityThread.access$700(ActivityThread, ActivityThread$ActivityClientRecord, Intent) line: 168
ActivityThread$H.handleMessage(Message) line: 1329
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 177
ActivityThread.main(String[]) line: 5493
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 525
ZygoteInit$MethodAndArgsCaller.run() line: 1225
ZygoteInit.main(String[]) line: 1041
NativeStart.main(String[]) line: not available [native method]
Thread [<10> Binder_2] (Running)
Thread [<9> Binder_1] (Running)
Thread [<11> GLThread 22597] (Running)
更新
所以我做了更多的调试,发现这两个项目在不同的驱动器。这有什么区别吗?成功运行的项目与TwoWayView
在同一个驱动器中。当这个项目是在eclipse工作空间和不同的驱动器,然后双向视图。
更新2
我把图书馆移到同一个目录,但仍然没有运气。即使现在正在工作的那个也在工作。对这两种方案进行了进一步的考察和比较,给出了一些参考。虽然我已经做了相同的配置,但我可以在Project Properties->Android
库部分看到这个TwoWayView
,在这个项目中我不能。当我从那里删除这个库以前的项目也开始崩溃。
改成:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.example.camerafilters.CameraGLSurfaceView
android:id="@+id/CameraGLSurfaceView"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="8"/>
<org.lucasr.twowayview.TwoWayView
android:id="@+id/ShaderList"
style="@style/TwoWayView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="2"
android:drawSelectorOnTop="false"
tools:context=".CameraMainActivity" />
</LinearLayout>