我尝试在我的Android应用程序上实现EasyRTC,但是我遇到了一些问题。我使用[此自定义视图] [1]而不是WebView来支持chrome。我只是按照他们的指南在Android手机(API 17)中构建它,这有一些问题:
12-25 11:12:01.800: E/AndroidRuntime(16111): FATAL EXCEPTION: main
12-25 11:12:01.800: E/AndroidRuntime(16111): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/com.example.myapp.VideoCallActivity}: android.view.InflateException: Binary XML file line #35: Error inflating class us.costan.chrome.ChromeView
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.app.ActivityThread.access$700(ActivityThread.java:159)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.os.Handler.dispatchMessage(Handler.java:99)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.os.Looper.loop(Looper.java:176)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.app.ActivityThread.main(ActivityThread.java:5419)
12-25 11:12:01.800: E/AndroidRuntime(16111): at java.lang.reflect.Method.invokeNative(Native Method)
12-25 11:12:01.800: E/AndroidRuntime(16111): at java.lang.reflect.Method.invoke(Method.java:525)
12-25 11:12:01.800: E/AndroidRuntime(16111): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
12-25 11:12:01.800: E/AndroidRuntime(16111): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
12-25 11:12:01.800: E/AndroidRuntime(16111): at dalvik.system.NativeStart.main(Native Method)
12-25 11:12:01.800: E/AndroidRuntime(16111): Caused by: android.view.InflateException: Binary XML file line #35: Error inflating class us.costan.chrome.ChromeView
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.view.LayoutInflater.createView(LayoutInflater.java:626)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
12-25 11:12:01.800: E/AndroidRuntime(16111): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.app.Activity.setContentView(Activity.java:1956)
12-25 11:12:01.800: E/AndroidRuntime(16111): at com.example.myapp.VideoCallActivity.onCreate(VideoCallActivity.java:15)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.app.Activity.performCreate(Activity.java:5372)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
12-25 11:12:01.800: E/AndroidRuntime(16111): ... 11 more
12-25 11:12:01.800: E/AndroidRuntime(16111): Caused by: java.lang.reflect.InvocationTargetException
12-25 11:12:01.800: E/AndroidRuntime(16111): at java.lang.reflect.Constructor.constructNative(Native Method)
12-25 11:12:01.800: E/AndroidRuntime(16111): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-25 11:12:01.800: E/AndroidRuntime(16111): at android.view.LayoutInflater.createView(LayoutInflater.java:600)
12-25 11:12:01.800: E/AndroidRuntime(16111): ... 22 more
12-25 11:12:01.800: E/AndroidRuntime(16111): Caused by: java.lang.UnsatisfiedLinkError: Native method not found: org.chromium.android_webview.AwContents.nativeInit:(Lorg/chromium/android_webview/AwWebContentsDelegate;Lorg/chromium/android_webview/AwContentsClientBridge;)I
12-25 11:12:01.800: E/AndroidRuntime(16111): at org.chromium.android_webview.AwContents.nativeInit(Native Method)
12-25 11:12:01.800: E/AndroidRuntime(16111): at org.chromium.android_webview.AwContents.<init>(AwContents.java:363)
12-25 11:12:01.800: E/AndroidRuntime(16111): at org.chromium.android_webview.AwContents.<init>(AwContents.java:323)
12-25 11:12:01.800: E/AndroidRuntime(16111): at us.costan.chrome.ChromeView.<init>(ChromeView.java:91)
12-25 11:12:01.800: E/AndroidRuntime(16111): ... 25 more
xml文件:
<us.costan.chrome.ChromeView
android:id="@+id/webView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</us.costan.chrome.ChromeView>
VideoCallActivity类中的:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_call);
ChromeView chromeView = (ChromeView) findViewById(R.id.webView);
chromeView.getSettings().setJavaScriptEnabled(true);
chromeView.loadUrl(testURL);
}
这个:
public class MyApplication extends Application{
@Override
public void onCreate() {
super.onCreate();
ChromeView.initialize(this);
}
}
答案 0 :(得分:0)
首先到第一个。你在第35行得到你的第一个错误。去eclipse转到左侧面板,右键单击并点击SHOW LINES,看看你的代码在第35行写的是什么。这是主要的问题。它可能是是一些错配代码。另一个问题是你在OnCreate方法中犯了这个错误,我相信甚至比达到onCreate更早。检查你的代码。但主要是我不应该将初始化传递给chromeview,而是在主要活动中完全声明它比如OpenGlS在它的extendin渲染类中绘制的时候(谷歌的例子)。希望这有帮助。
答案 1 :(得分:0)
哦,我想我发现了你的问题。你在xml中使用自定义视图,这意味着你必须在你的活动中声明和查看自定义视图,如us.costan.chrome.ChromeView chrome;
chrome = (us.costan.chrome.ChromeView)findViewById(R.id.webView)
setContentView(chrome)