启动主题导致重启

时间:2016-01-24 18:15:14

标签: android google-play-services launching-application

我想充分利用"冷启动"时间显示品牌发布主题,完全按照in this post所述。 我遵循了每一步,但在启动应用程序时,emualtor和真实设备都会进行热重启。 我认为这与我在应用中使用的Google Play服务有关。 我尝试运行this项目,该项目也跟在上面的帖子中,并没有包含游戏服务,而且一切都很好,所以它与设备无关。 这是一些代码:

的Manifest.xml

<application
    android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:theme="@style/AppTheme.Launch">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

styles.xml

<style name="AppTheme.Launch" parent="AppTheme" >
    <item name="android:windowBackground">@drawable/bg_launch</item>
</style>

bg_launch.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">

<item android:drawable="?android:windowBackground" />
<item>
    <bitmap android:src="@drawable/ic_logo"
        android:gravity="center" />
</item>

build.gradle(插件版本:2.0.0-alpha6)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'

defaultConfig {
    applicationId "com.rocca.app"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "0.9"
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:gridlayout-v7:23.1.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.android.support:support-v4:23.1.1'
}

MainActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setUpGoogleApiClient(); //for IAB
    setUpAds();
}

activity_main.xml中

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="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:animateLayoutChanges="true"
android:id="@+id/root">

<com.google.android.gms.ads.AdView
    android:id="@+id/ad_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    ads:adSize="SMART_BANNER"
    ads:adUnitId="..." />

<android.support.v4.view.ViewPager
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/viewPager"
    android:layout_above="@+id/ad_view"/>

</RelativeLayout>

logcat的:

E/AndroidRuntime: FATAL EXCEPTION: main
                                                             Process: com.rocca.ringapp, PID: 5553
                                                             java.lang.RuntimeException: Package manager has died
                                                                 at android.app.ApplicationPackageManager.hasSystemFeature(ApplicationPackageManager.java:413)
                                                                 at org.chromium.android_webview.AwSettings.<init>(AwSettings.java:232)
                                                                 at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:232)
                                                                 at android.webkit.WebView.<init>(WebView.java:606)
                                                                 at android.webkit.WebView.<init>(WebView.java:542)
                                                                 at android.webkit.WebView.<init>(WebView.java:525)
                                                                 at android.webkit.WebView.<init>(WebView.java:512)
                                                                 at android.webkit.WebView.<init>(WebView.java:502)
                                                                 at com.google.android.gms.ads.internal.u.k.<init>(SourceFile:227)
                                                                 at com.google.android.gms.ads.internal.u.k.a(SourceFile:204)
                                                                 at com.google.android.gms.ads.internal.u.i.a(SourceFile:52)
                                                                 at com.google.android.gms.ads.internal.d.a(SourceFile:76)
                                                                 at com.google.android.gms.ads.internal.n.a(SourceFile:100)
                                                                 at com.google.android.gms.ads.internal.g.run(SourceFile:196)
                                                                 at android.os.Handler.handleCallback(Handler.java:739)
                                                                 at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                 at android.os.Looper.loop(Looper.java:148)
                                                                 at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                              Caused by: android.os.DeadObjectException
                                                                 at android.os.BinderProxy.transactNative(Native Method)
                                                                 at android.os.BinderProxy.transact(Binder.java:503)
                                                                 at android.content.pm.IPackageManager$Stub$Proxy.hasSystemFeature(IPackageManager.java:4264)
                                                                 at android.app.ApplicationPackageManager.hasSystemFeature(ApplicationPackageManager.java:411)
                                                                 at org.chromium.android_webview.AwSettings.<init>(AwSettings.java:232) 
                                                                 at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:232) 
                                                                 at android.webkit.WebView.<init>(WebView.java:606) 
                                                                 at android.webkit.WebView.<init>(WebView.java:542) 
                                                                 at android.webkit.WebView.<init>(WebView.java:525) 
                                                                 at android.webkit.WebView.<init>(WebView.java:512) 
                                                                 at android.webkit.WebView.<init>(WebView.java:502) 
                                                                 at com.google.android.gms.ads.internal.u.k.<init>(SourceFile:227) 
                                                                 at com.google.android.gms.ads.internal.u.k.a(SourceFile:204) 
                                                                 at com.google.android.gms.ads.internal.u.i.a(SourceFile:52) 
                                                                 at com.google.android.gms.ads.internal.d.a(SourceFile:76) 
                                                                 at com.google.android.gms.ads.internal.n.a(SourceFile:100) 
                                                                 at com.google.android.gms.ads.internal.g.run(SourceFile:196) 
                                                                 at android.os.Handler.handleCallback(Handler.java:739) 
                                                                 at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                 at android.os.Looper.loop(Looper.java:148) 
                                                                 at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                 at java.lang.reflect.Method.invoke(Native Method) 
                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

1 个答案:

答案 0 :(得分:0)

错误发生在android:drawable="?android:windowBackground"的bg_launch.xml中。

<item>更改为

<item>
<shape android:shape="rectangle">
    <solid android:color="@color/grey_50" />
</shape>
</item>

以某种方式使它发挥作用。