启动屏幕活动 - 元素必须是元素的直接子元素[WrongManifestParent]

时间:2017-01-25 00:18:27

标签: android splash-screen audio-player android-music-player

我正在使用一个名为Timber& amp;的开源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错误:(37)错误:   element必须是元素的直接子元素   [WrongManifestParent]

我尝试将SplashActivity添加到清单中的几个不同区域,但没有运气。我需要知道在AndroidManifest中添加SplashActivity才能让它真正起作用吗?

1 个答案:

答案 0 :(得分:2)

检查您的活动代码

这未关闭

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

您需要以/>

结束

或者......你需要移动其中一个关闭的标签。

</activity>
</activity>

基本上,您不能在另一个活动中拥有活动,因此WrongManifestParent

建议:撤消到可运行的状态,然后转到文件&gt;新&gt;活动,它会正确地为您触摸清单。

旁注:Timber is a already an Android library