0

Ich lerne Android (mit Android Studio 2.1.1).Ausgewählte Aktivitätsvorlage erfordert ein vorhandenes Anwendungsthema

Ich habe ein Projekt mit einem Anwendungsmodul "app" und einem Bibliotheksmodul "mylibrary" erstellt.

Ich kann eine Basisaktivität zum App-Modul hinzufügen und sie aus der Hauptaktivität aufrufen, aber auf dem Modul mylibrary kann ich nur eine "leere" Aktivität erstellen. Jedes Mal, wenn ich versuche, eine „Grundaktivität“ hinzuzufügen bekomme ich den Fehler:

„Ausgewählte Aktivitätsvorlage eine bestehende Anwendung Theme erfordert“

Warum kann ich eine Grundaktivität in der Bibliothek Modul hinzufügen?

--- EDIT ----

Dies ist nur eine minimale Hallo-Welt-Anwendung, fast kein Code von mir geschrieben, ich bin nur verwirrt, warum Android wird mir eine Aktivität eine nicht zulassen hinzufügen Bibliotheksmodul, da es auf dem App-Modul funktioniert.

style.xml 

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 

<style name="AppTheme.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
</style> 

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

manifest: 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity 
     android:name=".MainActivity" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme.NoActionBar"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity android:name=".LibMainActivity" /> 
    <!-- 
ATTENTION: This was auto-generated to add Google Play services to your project for 
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. 
    --> 
    <meta-data 
     android:name="com.google.android.gms.version" 
     android:value="@integer/google_play_services_version" /> 

    <activity 
     android:name=".BasicActivity" 
     android:label="@string/title_activity_basic" 
     android:theme="@style/AppTheme.NoActionBar"></activity> 
</application> 

+0

Bitte fügen Sie Ihren Code hier und Manifest-Datei, style.xml auch –

Antwort

2

Versuchen Sie folgendes:

In Werte/styles.xml

<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar"> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccentRed</item> 
    </style> 

In v21/styles.xml

<style name="AppTheme" parent="AppTheme.Base"> 
    <item name="android:colorPrimary">@color/colorPrimary</item> 
    <item name="android:colorAccent">@color/colorAccentRed</item> 
    <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item> 
</style> 

das Thema Ihrer Anwendung ein (in AndroidManifest.xml)

 android:theme="@style/AppTheme" 
+0

Das hat für mich funktioniert. Äh, du hast vergessen "zu deinem Manifest hinzuzufügen" unter "Setze das Thema deiner Anwendung" – RoccoDev

Verwandte Themen