android sdk 产品风味 - 当我使用 Intent 开始新活动时未找到活动

scr*_*yne 5 android android-intent android-gradle-plugin android-productflavors

我有一个工作应用程序,我添加了 2 种产品口味。这个应用程序在第一个屏幕上有一个菜单,允许用户选择下一个活动,我用意图加载。

这是 AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name="com.alpha.aloedu.MainActivity"
        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.alpha.aloedu.guideddrawing.GuidedLetterDrawingActivity"
        android:label="Guided Letter Drawing"
        android:screenOrientation="portrait" />
    <activity
        android:name="com.alpha.aloedu.buildvocabulary.BuildVocabularyActivity"
        android:label="Image Plus Word"
        android:screenOrientation="portrait" />
    <activity
        android:name="com.alpha.aloedu.findthepicture.FindThePictureActivity"
        android:label="Find the Picture"
        android:screenOrientation="portrait" />
    <activity
        android:name="com.alpha.aloedu.findtheletter.FindTheLetterActivity"
        android:label="Find the Letter"
        android:screenOrientation="portrait" />
    <activity
        android:name="com.alpha.aloedu.fillintheletter.FillInTheLetterActivity"
        android:label="Find the Letter"
        android:screenOrientation="portrait" />
    <activity
        android:name="com.alpha.aloedu.EndActivity"
        android:label="End Activity"
        android:screenOrientation="portrait" />

    <activity
        android:name="com.alpha.aloedu.AdminActivity"
        android:label="Admin Activity"
        android:theme="@style/AppTheme.NoActionBar"
        android:screenOrientation="portrait"
        />

</application>

<supports-screens
    android:largeScreens="true"
    android:normalScreens="true"
    android:requiresSmallestWidthDp="480"
    android:resizeable="false"
    android:smallScreens="false"
    android:xlargeScreens="true" />
Run Code Online (Sandbox Code Playgroud)

这是gradle文件的相关部分:

productFlavors {
    de {
        applicationIdSuffix ".de"
        versionName "1.1de"
    }
    fr {
        applicationIdSuffix ".fr"
        versionName "1.1fr"
    }
}
Run Code Online (Sandbox Code Playgroud)

这是源树:

在此处输入图片说明

这是我加载下一个活动的代码:

    Intent intent = new Intent();
    intent.setClassName("com.alpha.aloedu", newClassName);
    currentActivity.startActivity(intent);
    currentActivity.finish();
Run Code Online (Sandbox Code Playgroud)

我在第二行设置了一个断点,“newClassName”具有正确的值。但是,当我运行“deDebug”变体时,在第三行出现错误:

android.content.ActivityNotFoundException:无法找到显式活动类 {com.alpha.aloedu/com.alpha.aloedu.guideddrawing.GuidedLetterDrawingActivity};您是否在 AndroidManifest.xml 中声明了此活动?

GuidedLetterDrawingActivity 类确实存在于主源代码树中,也存在于 AndroidManifest.xml 中。

感谢您提供任何帮助。

Far*_*tab 0

您必须在其清单文件
...\src\ de \AndroidManifest.xml
...\src\ fr \AndroidManifest.xml中声明每种风格的活动