我是一名新的Android程序员,最近,当我将Sdk版本设置为26或更高版本时,我的项目在运行android 8和android 9的设备上出现此崩溃。这是我的崩溃日志:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.westland/com.htmlchrome.MainActivity}: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class org.xwalk.core.XWalkView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2816)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2894)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1615)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6652)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: android.view.InflateException: Binary XML file line #10: Binary
XML file line #10: Error inflating class org.xwalk.core.XWalkView
Caused by: android.view.InflateException: Binary XML file line #10: Error
inflating class org.xwalk.core.XWalkView
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:651)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:867)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.inflate(LayoutInflater.java:519)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at com.htmlchrome.MainActivity.onCreate(MainActivity.java:164)
at android.app.Activity.performCreate(Activity.java:7084)
at android.app.Activity.performCreate(Activity.java:7075)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2769)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2894)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1615)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6652)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: java.lang.RuntimeException: java.lang.SecurityException:
Permission Denial: opening provider
com.android.providers.contacts.ContactsProvider2 from ProcessRecord{f41086b
13155:com.cowboygunfighter.westland/u0a160} (pid=13155, uid=10160) requires
android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
at org.xwalk.core.ReflectConstructor.newInstance(ReflectConstructor.java:54)
at org.xwalk.core.XWalkView.reflectionInit(XWalkView.java:788)
at org.xwalk.core.XWalkView.<init>(XWalkView.java:221)
... 26 more
Caused by: java.lang.SecurityException: Permission Denial: opening provider
com.android.providers.contacts.ContactsProvider2 from ProcessRecord{f41086b
13155:com.cowboygunfighter.westland/u0a160} (pid=13155, uid=10160) requires
android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
at android.os.Parcel.readException(Parcel.java:2005)
at android.os.Parcel.readException(Parcel.java:1951)
at android.content.IContentService$Stub$Proxy.registerContentObserver(IContentService.java:768)
at android.content.ContentResolver.registerContentObserver(ContentResolver.java:1940)
at android.content.ContentResolver.registerContentObserver(ContentResolver.java:1929)
at org.xwalk.core.internal.extension.api.contacts.Contacts.<init>(Contacts.java:42)
at org.xwalk.core.internal.extension.BuiltinXWalkExtensions.load(BuiltinXWalkExtensions.java:62)
at org.xwalk.core.internal.XWalkViewInternal.initXWalkContent(XWalkViewInternal.java:365)
at org.xwalk.core.internal.XWalkViewInternal.<init>(XWalkViewInternal.java:253)
at org.xwalk.core.internal.XWalkViewBridge.<init>(XWalkViewBridge.java:57)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at org.xwalk.core.ReflectConstructor.newInstance(ReflectConstructor.java:48)
... 28 more
我的Manifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize"
android:screenOrientation="landscape">
</activity>
<activity
android:name=".SplashActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.chartboost.sdk.CBImpressionActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:excludeFromRecents="true"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity
android:name="com.vungle.publisher.FullScreenAdActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
我的styles.xml
<!-- Base application theme. -->
<style name="SelectPopupDialog">
<item name="select_dialog_singlechoice">@android:layout/select_dialog_singlechoice</item>
<item name="select_dialog_multichoice">@android:layout/select_dialog_multichoice</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="SelectActionMenuShare">
<item name="android:icon">@drawable/ic_menu_share_holo_light</item>
</style>
<style name="SelectActionMenuWebSearch">
<item name="android:icon">@drawable/ic_search</item>
</style>
</resources>
这是我的MainActivity.java:
package com.htmlchrome;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.chartboost.sdk.Chartboost;
import com.chartboost.sdk.CBLocation;
import com.chartboost.sdk.ChartboostDelegate;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest.Builder;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import com.vungle.publisher.VunglePub;
import org.xwalk.core.JavascriptInterface;
import org.xwalk.core.XWalkView;
public class MainActivity extends AppCompatActivity {
private AdView adView;
private InterstitialAd admobExit;
private InterstitialAd interstitialAd;
private String link = "";
private boolean showAdmobExit = false;
private String url_offline = "file:///android_asset/www/index.html";
private String url_online = "";
private final VunglePub vunglePub = VunglePub.getInstance();
private XWalkView webview;
private class JSInterface {
private InterstitialAd admob;
class C05181 implements Runnable {
C05181() {
}
public void run() {
JSInterface.this.admob.loadAd(new Builder().build());
Log.e("RUN:", "loadAdmobFull");
}
}
class C05192 implements Runnable {
C05192() {
}
public void run() {
JSInterface.this.admob.show();
}
}
class C05214 implements Runnable {
C05214() {
}
public void run() {
Chartboost.showInterstitial(CBLocation.LOCATION_DEFAULT);
}
}
class C05225 implements Runnable {
C05225() {
}
public void run() {
Chartboost.showInterstitial(CBLocation.LOCATION_DEFAULT);
}
}
class C05236 implements Runnable {
C05236() {
}
public void run() {
MainActivity.this.adView.setVisibility(0);
MainActivity.this.adView.loadAd(new Builder().build());
}
}
class C05247 implements Runnable {
C05247() {
}
public void run() {
MainActivity.this.adView.setVisibility(8);
}
}
class C05258 implements Runnable {
C05258() {
}
public void run() {
MainActivity.this.vunglePub.playAd();
}
}
public JSInterface() {
this.admob = new InterstitialAd(MainActivity.this);
this.admob.setAdUnitId(MainActivity.this.getString(R.string.admob_full));
}
@JavascriptInterface
public void loadAdmobFull() {
MainActivity.this.runOnUiThread(new C05181());
}
@JavascriptInterface
public void showAdmobFull() {
MainActivity.this.runOnUiThread(new C05192());
}
@JavascriptInterface
public void showAdmobFullOnExit(final boolean isShow) {
MainActivity.this.runOnUiThread(new Runnable() {
public void run() {
MainActivity.this.showAdmobExit = isShow;
}
});
}
@JavascriptInterface
public void loadChartboot() {
MainActivity.this.runOnUiThread(new C05214());
}
@JavascriptInterface
public void showChartBoot() {
MainActivity.this.runOnUiThread(new C05225());
}
@JavascriptInterface
public void showAdmobBanner() {
MainActivity.this.runOnUiThread(new C05236());
}
@JavascriptInterface
public void hideAdmobBanner() {
MainActivity.this.runOnUiThread(new C05247());
}
@JavascriptInterface
public void showVungle() {
MainActivity.this.runOnUiThread(new C05258());
}
}
class C10261 extends AdListener {
C10261() {
}
public void onAdLoaded() {
if (MainActivity.this.interstitialAd.isLoaded()) {
MainActivity.this.interstitialAd.show();
}
}
public void onAdOpened() {
}
public void onAdFailedToLoad(int errorCode) {
}
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView((int) R.layout.activity_main);
this.webview = (XWalkView) findViewById(R.id.webview);
this.adView = (AdView) findViewById(R.id.adView);
this.vunglePub.init(this, getString(R.string.vungle_id));
this.interstitialAd = new InterstitialAd(this);
this.interstitialAd.setAdUnitId(getString(R.string.admob_full));
this.interstitialAd.loadAd(new Builder().build());
this.interstitialAd.setAdListener(new C10261());
this.link = getString(R.string.link);
this.webview.addJavascriptInterface(new JSInterface(), "JSInterface");
this.webview.load(this.link, null);
Chartboost.startWithAppId(this, getString(R.string.chartboot_id), getString(R.string.chartboot_sign));
Chartboost.onCreate(this);
Chartboost.onStart(this);
this.admobExit = new InterstitialAd(this);
this.admobExit.setAdUnitId(getString(R.string.admob_full));
this.admobExit.loadAd(new Builder().build());
}
@Override
public void onStart() {
super.onStart();
Chartboost.startWithAppId(this, getString(R.string.chartboot_id), getString(R.string.chartboot_sign));
Chartboost.onStart(this);
}
@Override
public void onResume() {
super.onResume();
Chartboost.onResume(this);
}
@Override
public void onPause() {
super.onPause();
Chartboost.onPause(this);
}
@Override
public void onStop() {
super.onStop();
Chartboost.onStop(this);
}
@Override
public void onDestroy() {
super.onDestroy();
Chartboost.onDestroy(this);
}
我知道当我将sdk版本设置为26或更高版本时会发生,但我不知道为什么会发生。谁能帮我解决这个问题?
答案 0 :(得分:0)
我来帮助您一点点。错误可能来自旧的人行横道插件,人行横道项目已被取消多年,他们不再更新了。有2种方法:您切换到另一个html5库,也许是phonegap或尝试更新到最新版本。