Sunday, 15 February 2015

android - You need to use a Theme.AppCompat theme (or descendant) with this activity after adding google-play-services -



android - You need to use a Theme.AppCompat theme (or descendant) with this activity after adding google-play-services -

in application i'm developing (it's first android application) utilize android-maven-plugin , maven-android-sdk-deployer. application had been working great (mainactivity uses actionbaractivity had been shown correctly) until added google-play-servies library. after i'm getting next exception (no changes in application except adding required dependencies pom.xml):

e/androidruntime( 2146): java.lang.runtimeexception: unable start activity componentinfo{com.myapp/com.myapp.acts.mainactivity}: java.lang.illegalstateexception: need utilize theme.appcompat theme (or descendant) activity. e/androidruntime( 2146): @ android.app.activitythread.performlaunchactivity(activitythread.java:2298) e/androidruntime( 2146): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2360) e/androidruntime( 2146): @ android.app.activitythread.access$800(activitythread.java:144) e/androidruntime( 2146): @ android.app.activitythread$h.handlemessage(activitythread.java:1278) e/androidruntime( 2146): @ android.os.handler.dispatchmessage(handler.java:102) e/androidruntime( 2146): @ android.os.looper.loop(looper.java:135) e/androidruntime( 2146): @ android.app.activitythread.main(activitythread.java:5221) e/androidruntime( 2146): @ java.lang.reflect.method.invoke(native method) e/androidruntime( 2146): @ java.lang.reflect.method.invoke(method.java:372) e/androidruntime( 2146): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:899) e/androidruntime( 2146): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:694) e/androidruntime( 2146): caused by: java.lang.illegalstateexception: need utilize theme.appcompat theme (or descendant) activity. e/androidruntime( 2146): @ android.support.v7.app.actionbaractivitydelegate.oncreate(actionbaractivitydelegate.java:147) e/androidruntime( 2146): @ android.support.v7.app.actionbaractivitydelegatebase.oncreate(actionbaractivitydelegatebase.java:139) e/androidruntime( 2146): @ android.support.v7.app.actionbaractivity.oncreate(actionbaractivity.java:123) e/androidruntime( 2146): @ com.metova.roboguice.appcompat.roboactionbaractivity.oncreate(roboactionbaractivity.java:45) e/androidruntime( 2146): @ com.myapp.acts.baseactionbaractivity.oncreate(baseactionbaractivity.java:23) e/androidruntime( 2146): @ com.myapp.acts.mainactivity.oncreate(mainactivity.java:62) e/androidruntime( 2146): @ android.app.activity.performcreate(activity.java:5933) e/androidruntime( 2146): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1105) e/androidruntime( 2146): @ android.app.activitythread.performlaunchactivity(activitythread.java:2251) e/androidruntime( 2146): ... 10 more

my pom.xml is:

<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.myapp</groupid> <artifactid>myapp</artifactid> <version>1.0-snapshot</version> <packaging>apk</packaging> <name>myapp</name> <properties> <android.sdk.path>/data/tools/android-sdk-linux</android.sdk.path> <project.build.sourceencoding>utf-8</project.build.sourceencoding> <platform.version>5.0_r1</platform.version> <android.plugin.version>3.8.2</android.plugin.version> <robospice.version>1.4.13</robospice.version> <picasso.version>2.3.5-snapshot</picasso.version> <android.support.version>21.0.1</android.support.version> <sdk.platform.version>21</sdk.platform.version> <commons.logging.version>1.1.3</commons.logging.version> <android-maven-plugin.version>3.7.0</android-maven-plugin.version> </properties> <dependencies> <dependency> <groupid>android.support</groupid> <artifactid>compatibility-v7-appcompat</artifactid> <version>${android.support.version}</version> <type>apklib</type> <scope>compile</scope> </dependency> <dependency> <groupid>android.support</groupid> <artifactid>compatibility-v7-appcompat</artifactid> <version>${android.support.version}</version> <type>jar</type> </dependency> <dependency> <groupid>android.support</groupid> <artifactid>compatibility-v4</artifactid> <version>${android.support.version}</version> </dependency> <dependency> <groupid>org.roboguice</groupid> <artifactid>roboguice</artifactid> <version>2.0</version> </dependency> <dependency> <groupid>com.octo.android.robospice</groupid> <artifactid>robospice</artifactid> <version>${robospice.version}</version> </dependency> <dependency> <groupid>com.octo.android.robospice</groupid> <artifactid>robospice-retrofit</artifactid> <version>${robospice.version}</version> </dependency> <dependency> <groupid>commons-logging</groupid> <artifactid>commons-logging</artifactid> <version>${commons.logging.version}</version> <scope>provided</scope> </dependency> <dependency> <groupid>com.squareup</groupid> <artifactid>otto</artifactid> <version>1.3.5</version> </dependency> <dependency> <groupid>android</groupid> <artifactid>android</artifactid> <version>${platform.version}</version> <scope>provided</scope> </dependency> <dependency> <groupid>com.google.android.maps</groupid> <artifactid>maps</artifactid> <version>21_r1</version> <scope>provided</scope> </dependency> <dependency> <groupid>com.google.android.gms</groupid> <artifactid>google-play-services</artifactid> <version>21.0.0</version> <type>apklib</type> </dependency> <dependency> <groupid>com.google.android.gms</groupid> <artifactid>google-play-services</artifactid> <version>21.0.0</version> <type>jar</type> </dependency> <dependency> <groupid>com.squareup.okhttp</groupid> <artifactid>okhttp</artifactid> <version>2.0.0</version> </dependency> <dependency> <groupid>com.squareup.okhttp</groupid> <artifactid>okhttp-urlconnection</artifactid> <version>2.0.0</version> </dependency> <dependency> <groupid>com.squareup.picasso</groupid> <artifactid>picasso</artifactid> <version>${picasso.version}</version> </dependency> <dependency> <artifactid>crouton</artifactid> <groupid>de.keyboardsurfer.android.widget</groupid> <version>1.8.5</version> <exclusions> <exclusion> <groupid>com.android.support</groupid> <artifactid>support-v4</artifactid> </exclusion> </exclusions> </dependency> <dependency> <groupid>com.google.inject</groupid> <artifactid>guice</artifactid> <classifier>no_aop</classifier> <version>4.0-beta</version> </dependency> </dependencies> <build> <finalname>${project.artifactid}</finalname> <pluginmanagement> <plugins> <plugin> <groupid>com.jayway.maven.plugins.android.generation2</groupid> <artifactid>android-maven-plugin</artifactid> <version>${android.plugin.version}</version> <extensions>true</extensions> </plugin> <plugin> <groupid>org.eclipse.m2e</groupid> <artifactid>lifecycle-mapping</artifactid> <version>1.0.0</version> <configuration> <lifecyclemappingmetadata> <pluginexecutions> <pluginexecution> <pluginexecutionfilter> <groupid>com.jayway.maven.plugins.android.generation2</groupid> <artifactid>android-maven-plugin</artifactid> <versionrange>[1.0.0,)</versionrange> <goals> <goal>consume-aar</goal> </goals> </pluginexecutionfilter> <action> <ignore /> </action> </pluginexecution> </pluginexecutions> </lifecyclemappingmetadata> </configuration> </plugin> </plugins> </pluginmanagement> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-enforcer-plugin</artifactid> </plugin> <plugin> <groupid>com.jayway.maven.plugins.android.generation2</groupid> <artifactid>android-maven-plugin</artifactid> <extensions>true</extensions> <configuration> <sdk> <platform>${sdk.platform.version}</platform> </sdk> </configuration> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> </project>

and androidmanifest.xml:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myapp" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="10" android:targetsdkversion="21" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.write_external_storage" /> <!-- maps --> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices" /> <uses-feature android:glesversion="0x00020000" android:required="true" /> <!-- /maps --> <application android:allowbackup="true" android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/apptheme" > <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <meta-data android:name="com.google.android.maps.v2.api_key" android:value="my_key" /> <activity android:name=".acts.loginactivity" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> <activity android:name=".acts.registeractivity" android:label="@string/app_name" > </activity> <activity android:name=".acts.mainactivity" android:label="@string/app_name"> </activity> <activity android:name=".acts.profiles.searchprofilesactivity" android:label="@string/title_activity_search_profiles" > <meta-data android:name="android.support.parent_activity" android:value=".acts.mainactivity" /> </activity> <service android:name="com.myapp.net.retrofitspiceservice" android:exported="false" /> </application> </manifest>

my styles.xml (in values-vxx have simillar entries):

<resources> <style name="appbasetheme" parent="@style/theme.appcompat.light"> </style> <style name="apptheme" parent="appbasetheme"> </style> </resources>

so adding these 2 dependencies causes application crash "you need utilize theme.appcompat...":

<dependency> <groupid>com.google.android.gms</groupid> <artifactid>google-play-services</artifactid> <version>21.0.0</version> <type>apklib</type> </dependency> <dependency> <groupid>com.google.android.gms</groupid> <artifactid>google-play-services</artifactid> <version>21.0.0</version> <type>jar</type> </dependency>

do have thought cause of above problem? help appreciated.

i had same problem , fixed in androidmanifest.xml switching from

<application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" >

to

<application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/theme.appcompat" >

i got hint reply next issue.

android google-play-services appcompat android-maven-plugin

No comments:

Post a Comment