2017-12-07 3 views
0

this question에 대한 답변을 기반으로 TextureView의 하위 클래스에서 작업했습니다.바이너리 XML 파일 라인 # 0 : 클래스를 부 풀릴 때 오류가 발생했습니다. TextureView

package com.example.edward.openglproject; 

public class GLTextureView extends TextureView implements TextureView.SurfaceTextureListener { 

    public GLTextureView(Context context) { 
     super(context); 
     // Do stuff 
    } 

    public GLTextureView(Context context, AttributeSet attrs) { 
     super(context, attrs); 
     // Do stuff 
    } 

    public GLTextureView(Context context, AttributeSet attrs, int defStyleAttr) { 
     super(context, attrs, defStyleAttr); 
     // Do stuff 
    } 

    public GLTextureView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 
     super(context, attrs, defStyleAttr, defStyleRes); 
     // Do stuff 
    } 

// Do other stuff 

} 

내 activity_camera.xml 파일 : 나는이 프로그램을 실행할 때마다 활동이

setContentView(R.layout.activity_camera); 

를 호출하고이 오류를 반환하는 경우

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#0099cc" 
    tools:context="com.example.edward.openglproject.CameraActivity"> 

    <com.example.edward.openglproject.Rendering.GLTextureView 
     android:id="@+id/textureView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 

    <!-- Unrelated stuff --> 
</FrameLayout> 

, 그것은 충돌 :

여기 내 코드입니다
12-07 16:49:01.249 5595-5595/com.example.edward.openglproject E/AndroidRuntime: FATAL EXCEPTION: main 
                      Process: com.example.edward.openglproject, PID: 5595 
                      java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.edward.openglproject/com.example.edward.openglproject.CameraActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.example.edward.openglproject             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817) 
                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
                       at android.app.ActivityThread.-wrap11(Unknown Source:0) 
                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
                       at android.os.Handler.dispatchMessage(Handler.java:105) 
                       at android.os.Looper.loop(Looper.java:164) 
                       at android.app.ActivityThread.main(ActivityThread.java:6541) 
                       at java.lang.reflect.Method.invoke(Native Method) 
                       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
                       Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.example.edward.openglproject.Rendering.GLTextureView 
                       Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.example.edward.openglproject.TextureView 
                       Caused by: java.lang.reflect.InvocationTargetException 
                       at java.lang.reflect.Constructor.newInstance0(Native Method) 
                       at java.lang.reflect.Constructor.newInstance(Constructor.java:334) 
                       at android.view.LayoutInflater.createView(LayoutInflater.java:647) 
                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) 
                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) 
                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) 
                       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) 
                       at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
                       at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                       at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                       at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
                       at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
                       at com.example.edward.openglproject.CameraActivity.onCreate(CameraActivity.java:296) 
                       at android.app.Activity.performCreate(Activity.java:6975) 
                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213) 
                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770) 
                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
                       at android.app.ActivityThread.-wrap11(Unknown Source:0) 
                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
                       at android.os.Handler.dispatchMessage(Handler.java:105) 
                       at android.os.Looper.loop(Looper.java:164) 
                       at android.app.ActivityThread.main(ActivityThread.java:6541) 
                       at java.lang.reflect.Method.invoke(Native Method) 
                       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 

저는이 사이트를 둘러 보았습니다. 대부분의 솔루션은 생성자를 public으로 만드는 작업을 포함합니다.

아무에게도 필요한 것을 알려 줄 수 있습니까?

+0

'activity_camera.xml'레이아웃 파일의 첫 번째 줄에 ' ? –

+1

이 줄 또한 다소 이상하게 보입니다.'Error inflating class com.example.edward.openglprojectTextureView' - 최종 패키지와 클래스 이름 사이에'.'가 없습니다. –

+0

@MichaelDodd 예'activity_camera에 해당 줄이 있습니다. xml' 파일과 누락 된'.'은 내 복사/붙여 넣기/편집이 어떻게 든 잘못 되었기 때문입니다. –

답변

0

코드 또는 XML에서 GLTextureView의 패키지 이름을 수정해야합니다. 코드에서

: com.example.edward.openglproject.GLTextureView
XML로 : com.example.edward.openglproject.rendering.GLTextureView
로그에서 : com.example.edward.openglproject.Rendering.GLTextureView

나는 또한 (안 Android one의) 원래 TextureView을 가지고 이상한 생각합니다.
로그에 : com.example.edward.openglproject.TextureView

+0

고정되었지만 여전히 동일한 오류가 있습니다. –

관련 문제