Splash Screen Activity - The element must be a direct child of the element [WrongManifestParent]

≯℡__Kan透↙ 提交于 2019-12-25 07:48:34

问题


I am using an open source android project called Timber & I've been trying to add a splash screen to it but am having no luck. How would I go about doing it?

Here my AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.technologx.blaze.player.pro"
    android:installLocation="auto">

    <meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyDhob3qPAx8Bj_bc1pUJW6lnGQUcbPPRmY" />
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <uses-sdk tools:overrideLibrary="de.Maxr1998.trackselectorlib" />

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.BROADCAST_STICKY" />
    <uses-permission android:name="com.android.vending.BILLING" />


    <application
        android:name=".TimberApp"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.FullScreen.Light"
        tools:replace="android:allowBackup">

        <activity
            android:name="com.technologx.blaze.player.pro.SplashActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:theme="@style/TranslateThemeFull">

        <activity
            android:name=".activities.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.CATEGORY_APP_MUSIC" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />

                <data android:scheme="file" />
                <data android:mimeType="audio/*" />
                <data android:mimeType="application/ogg" />
                <data android:mimeType="application/x-ogg" />
                <data android:mimeType="application/itunes" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="http" />
                <data android:mimeType="audio/*" />
                <data android:mimeType="application/ogg" />
                <data android:mimeType="application/x-ogg" />
                <data android:mimeType="application/itunes" />
            </intent-filter>
            <intent-filter android:priority="-1">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="content" />
                <data android:mimeType="audio/*" />
                <data android:mimeType="application/ogg" />
                <data android:mimeType="application/x-ogg" />
                <data android:mimeType="application/itunes" />
            </intent-filter>
        </activity>
        </activity>

        <activity
            android:name=".activities.SettingsActivity"
            android:theme="@style/AppThemeNormalLight" />

        <activity
            android:name=".activities.PlaylistDetailActivity"
            android:theme="@style/AppTheme.FullScreen.Light" />

        <activity
            android:name=".activities.SearchActivity"
            android:theme="@style/AppThemeNormalLight" />

        <activity
            android:name=".activities.NowPlayingActivity"
            android:theme="@style/AppTheme.FullScreen.Light" />

        <activity android:name=".activities.DonateActivity"/>

        <receiver android:name=".helpers.MediaButtonIntentReceiver">
            <intent-filter>
                <action android:name="android.intent.action.MEDIA_BUTTON" />
                <action android:name="android.media.AUDIO_BECOMING_NOISY" />
            </intent-filter>
        </receiver>
        <!-- Music service -->
        <service
            android:name=".MusicService"
            android:label="@string/app_name"
            android:process=":main" />

        <service
            android:name=".WearBrowserService"
            android:exported="true">
            <intent-filter>
                <action android:name="android.media.browse.MediaBrowserService" />
            </intent-filter>
        </service>

        <receiver android:name=".widgets.desktop.StandardWidget" android:label="@string/widget_standard">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
                <action android:name="com.technologx.blaze.player.pro.metachanged" />
                <action android:name="com.technologx.blaze.player.pro.playstatechanged" />
            </intent-filter>
            <meta-data android:name="android.appwidget.provider"
                android:resource="@xml/widget_standard" />
        </receiver>

        <receiver android:name=".widgets.desktop.WhiteWidget" android:label="@string/widget_white">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
                <action android:name="com.technologx.blaze.player.pro.metachanged" />
                <action android:name="com.technologx.blaze.player.pro.playstatechanged" />
            </intent-filter>
            <meta-data android:name="android.appwidget.provider"
                android:resource="@xml/widget_white" />
        </receiver>

        <receiver android:name=".widgets.desktop.SmallWidget" android:label="@string/widget_small">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
                <action android:name="com.technologx.blaze.player.pro.metachanged" />
                <action android:name="com.technologx.blaze.player.pro.playstatechanged" />
            </intent-filter>
            <meta-data android:name="android.appwidget.provider"
                android:resource="@xml/widget_small" />
        </receiver>
        <meta-data
            android:name="io.fabric.ApiKey"
            android:value="296bae08d0c5c23efe01e9db11fd01e189ce666a" />
    </application>

</manifest>

Here's my SplashActivity:

package com.technologx.blaze.player.pro;

/**
 * Created by Technologx on 1/24/17.
 */

import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

import java.util.Random;


public class SplashActivity extends Activity {

    private Animation mFadeIn;
    private Animation mFadeInScale;
    private Animation mFadeOut;

    //  @InjectView(R.id.image)
    ImageView mImageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        mImageView = (ImageView) findViewById(R.id.image);
        int index = new Random().nextInt(2);
        if (index == 1) {
            mImageView.setImageResource(R.drawable.entrance3);
        } else {
            mImageView.setImageResource(R.drawable.entrance2);
        }

        initAnim();
        setListener();
    }

    private void initAnim() {
        mFadeIn = AnimationUtils.loadAnimation(this, R.anim.welcome_fade_in);
        mFadeIn.setDuration(500);
        mFadeInScale = AnimationUtils.loadAnimation(this,
                R.anim.welcome_fade_in_scale);
        mFadeInScale.setDuration(2000);
        mFadeOut = AnimationUtils.loadAnimation(this, R.anim.welcome_fade_out);
        mFadeOut.setDuration(500);
        mImageView.startAnimation(mFadeIn);
    }

    public void setListener() {

        mFadeIn.setAnimationListener(new AnimationListener() {

            public void onAnimationStart(Animation animation) {

            }

            public void onAnimationRepeat(Animation animation) {

            }

            public void onAnimationEnd(Animation animation) {
                mImageView.startAnimation(mFadeInScale);
            }
        });
        mFadeInScale.setAnimationListener(new AnimationListener() {

            public void onAnimationStart(Animation animation) {

            }

            public void onAnimationRepeat(Animation animation) {

            }

            public void onAnimationEnd(Animation animation) {
                finish();
                // mImageView.startAnimation(mFadeOut);
            }
        });
        mFadeOut.setAnimationListener(new AnimationListener() {

            public void onAnimationStart(Animation animation) {

            }

            public void onAnimationRepeat(Animation animation) {

            }

            public void onAnimationEnd(Animation animation) {
                // startActivity(MainActivity.class);
            }
        });
    }
}

Every time I try and generate a signed apk I run into this error.

/Users/Technologx/Desktop/Android Projects/BlazePlayer Pro/app/src/main/AndroidManifest.xml Error:(37) Error: The element must be a direct child of the element [WrongManifestParent]

I've tried adding the SplashActivity to several different areas in the manifest but have had no luck. I need to know where in the AndroidManifest to add the SplashActivity to actually get it to work?


回答1:


Check your activity tags

This isn't closed

<activity
    android:name="com.technologx.blaze.player.pro.SplashActivity"
    android:label="@string/app_name"
    android:screenOrientation="portrait"
    android:theme="@style/TranslateThemeFull">

You need to end that with />

OR... you need to move one of these close tags up.

</activity>
</activity>

Basically, you can't have an activity in another one, hence WrongManifestParent

Suggestion: Undo to a state that is runnable, then go to File > New > Activity, and it'll touch the manifest correctly for you.

Sidenote: Timber is a already an Android library



来源:https://stackoverflow.com/questions/41841312/splash-screen-activity-the-element-must-be-a-direct-child-of-the-element-wron

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!