启动画面 Activity - 元素必须是元素 [WrongManifestParent] 的直接子元素

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

我正在使用一个名为 Timber 的开源 android 项目,我一直在尝试向它添加启动画面,但没有成功。我该怎么做?

这是我的 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>

这是我的 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);
            }
        });
    }
}

每次我尝试生成签名的 apk 时,我都会 运行 进入此错误。

/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]

我尝试将 SplashActivity 添加到清单中的几个不同区域,但没有成功。我需要知道在 AndroidManifest 中的哪个位置添加 SplashActivity 才能真正让它工作?

检查您的 activity 标签

这还没有结束

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

你需要用 />

结束

或者...您需要将其中一个关闭标签上移。

</activity>
</activity>

基本上,您不能在另一个中使用 activity,因此 WrongManifestParent

建议:撤消到可运行的状态,然后转到“文件”>“新建”>“Activity”,它会为您正确触及清单。

旁注:Timber is a already an Android library