Android app crashing - unknown reason [duplicate] - android

This question already has answers here:
You need to use a Theme.AppCompat theme (or descendant) with this activity
(63 answers)
Closed 8 years ago.
I am a beginner and have been using treehouse to learn. I am very early in the course and suddenly started getting a crash message when I start the app. I am unsure what is happening. I have posted everything that I know of. Sorry if I missed something or posted too much.
Main:
package com.example.crystalball;
import android.R.string;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends ActionBarActivity {
private CrystalBall mCrystalBall = new CrystalBall();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Declare our View variables
final TextView answerLabel = (TextView) findViewById(R.id.textView1);
Button getAnswerButton = (Button) findViewById(R.id.button1);
getAnswerButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
String answer = mCrystalBall.getAnAnswer();
// Update label with dynamic answer
answerLabel.setText(answer);
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
CrystalBall:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.crystalball"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen" >
<activity
android:name="com.example.crystalball.MainActivity"
android:label="#string/app_name" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.crystalball"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen" >
<activity
android:name="com.example.crystalball.MainActivity"
android:label="#string/app_name" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Logcat:
07-28 01:50:31.530: D/AndroidRuntime(980): Shutting down VM
07-28 01:50:31.530: W/dalvikvm(980): threadid=1: thread exiting with uncaught exception (group=0xb1ae7ba8)
07-28 01:50:31.570: E/AndroidRuntime(980): FATAL EXCEPTION: main
07-28 01:50:31.570: E/AndroidRuntime(980): Process: com.example.crystalball, PID: 980
07-28 01:50:31.570: E/AndroidRuntime(980): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.crystalball/com.example.crystalball.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.ActivityThread.access$800(ActivityThread.java:135)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.os.Handler.dispatchMessage(Handler.java:102)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.os.Looper.loop(Looper.java:136)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.ActivityThread.main(ActivityThread.java:5017)
07-28 01:50:31.570: E/AndroidRuntime(980): at java.lang.reflect.Method.invokeNative(Native Method)
07-28 01:50:31.570: E/AndroidRuntime(980): at java.lang.reflect.Method.invoke(Method.java:515)
07-28 01:50:31.570: E/AndroidRuntime(980): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
07-28 01:50:31.570: E/AndroidRuntime(980): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
07-28 01:50:31.570: E/AndroidRuntime(980): at dalvik.system.NativeStart.main(Native Method)
07-28 01:50:31.570: E/AndroidRuntime(980): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
07-28 01:50:31.570: E/AndroidRuntime(980): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:111)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
07-28 01:50:31.570: E/AndroidRuntime(980): at com.example.crystalball.MainActivity.onCreate(MainActivity.java:16)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.Activity.performCreate(Activity.java:5231)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-28 01:50:31.570: E/AndroidRuntime(980): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
07-28 01:50:31.570: E/AndroidRuntime(980): ... 11 more
07-28 01:50:37.070: I/Process(980): Sending signal. PID: 980 SIG: 9

Your Activity extends ActionBarActivity.
public class MainActivity extends ActionBarActivity
Indicates you are using AppCompat in which case you need to set Theme derieved from Theme.AppCompat to the Activity
or
android:theme="#style/Theme.AppCompat" >
set the theme for the application

To simply add ActionBar Compat your activity or application should use #style/Theme.AppCompat theme in AndroidManifest.xml like this:
<activity
...
android:theme="#style/Theme.AppCompat" />
This will add actionbar in activty(or all activities if you added this theme to application)
i.e. in your manifest file,Change
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
to
android:theme="#style/Theme.AppCompat"

Please change
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
to
android:theme="#android:style/Theme.AppCompat"

Related

java.lang.RuntimeException: Unable to start activity

Hi im practicing on adding logo for app using android Studio. i added simple code as follows .
package com.example.admin.actionbardemo;
import android.app.ActionBar;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActionBar actionbar= getActionBar();
actionbar.setIcon(R.mipmap.ic_launcher);
actionbar.setDisplayUseLogoEnabled(true);
actionbar.setDisplayShowHomeEnabled(true);
}
}
error:
03-06 02:20:30.272 1381-1381/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.admin.actionbardemo, PID: 1381
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.admin.actionbardemo/com.example.admin.actionbardemo.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.admin.actionbardemo.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5001) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
at dalvik.system.NativeStart.main(Native Method) 
03-06 02:20:30.276 1381-1384/? D/dalvikvm: GC_CONCURRENT freed 205K, 10% free 3023K/3340K, paused 5ms+0ms, total 6ms
Your getActionBar() returns null. I guess you dont have one.
this is androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.admin.actionbardemo">
<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=".AddingLogo"
android:label="#string/title_activity_adding_logo"
android:theme="#style/AppTheme.NoActionBar"></activity>
</application>
i used android.support.v7.app.ActionBar actionBar=getSupportActionBar();
insted of
ActionBar actionbar= getActionBar();
one more query -my logo is in Drawable folder. which extention need for logo PNG or JPG?
The theme you're using has no ActionBar. You must either change the parent of your AppTheme in styles.xml to a theme with ActionBar or set a toolbar trough setSupportActionBar(...) before calling getSupportActionBar()

Force Close on replacing AppCompatActivity with Activity

I had an old project in Eclipse and I imported it into Android Studio to rebuild it with Material Design.
I done all things...
configured build.gradle and dependencies:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.mhrz.Minesweeper"
minSdkVersion 8
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:cardview-v7:+'
}
and styles:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#1E9618</item>
<item name="colorPrimaryDark">#146310</item>
<item name="colorAccent">#1E9618</item>
</style>
</resources>
and this is Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mhrz.Minesweeper"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".MinesweeperGame"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
and also CardView works well.
The problem is that app works correctly with this and give me Holo Design:
public class MinesweeperGame extends Activity {
but I want Material and I get FC on:
public class MinesweeperGame extends AppCompatActivity {
with this log:
01-03 16:29:38.779 12720-12720/com.mhrz.Minesweeper E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.mhrz.Minesweeper, PID: 12720
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mhrz.Minesweeper/com.mhrz.Minesweeper.MinesweeperGame}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2219)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5045)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:113)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
at com.mhrz.Minesweeper.MinesweeperGame.onCreate(MinesweeperGame.java:55)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2163)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5045)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)
Where is mistake? How to fix it?
Android system doesn't know that you want to use alternate theme for application (like yours AppTheme) until you define it in application or activity attribute inside AndroidManifest.xml file.
You need to add the android:theme="#style/AppTheme" attribute to your <application> tag in AndroidManifest.xml like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mhrz.Minesweeper"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity android:name=".MinesweeperGame"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

AdView - Missing adActivity with android:configChanges in AndroidManifest.xml

I just set up my app with the Google Play library method of adding adds (AdMob). When I run the emulator the add has the error message:
Missing adActivity with android:configChanges in AndroidManifest.xml
I located a fix at:
Missing adActivity with android:configChanges in AndroidManifest.xml
The fix stated to do the following:
"com.google.ads.AdActivity" is declared when using the admob sdk jar in the "libs" folder. >It seems you're using admob via the google play services library so change:
activity android:name="com.google.ads.AdActivity"
To
activity android:name="com.google.android.gms.ads.AdActivity"
Also make sure you add the meta-data tag:
I tried this and the CatLog said to change the meta tag back to:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
My LogCat:
02-23 14:30:27.091: E/AndroidRuntime(1278): FATAL EXCEPTION: main
02-23 14:30:27.091: E/AndroidRuntime(1278): Process: biz.midl.debtcalculator, PID: 1278
02-23 14:30:27.091: E/AndroidRuntime(1278): java.lang.RuntimeException: Unable to start activity ComponentInfo{biz.midl.debtcalculator/biz.midl.debtcalculator.MainActivity}: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4242000 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
02-23 14:30:27.091: E/AndroidRuntime(1278): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
02-23 14:30:27.091: E/AndroidRuntime(1278): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
02-23 14:30:27.091: E/AndroidRuntime(1278): at android.app.ActivityThread.access$800(ActivityThread.java:135)
02-23 14:30:27.091: E/AndroidRuntime(1278): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
02-23 14:30:27.091: E/AndroidRuntime(1278): at android.os.Handler.dispatchMessage(Handler.java:102)
02-23 14:30:27.091: E/AndroidRuntime(1278): at android.os.Looper.loop(Looper.java:136)
02-23 14:30:27.091: E/AndroidRuntime(1278): at android.app.ActivityThread.main(ActivityThread.java:5017)
02-23 14:30:27.091: E/AndroidRuntime(1278): at java.lang.reflect.Method.invokeNative(Native Method)
02-23 14:30:27.091: E/AndroidRuntime(1278): at java.lang.reflect.Method.invoke(Method.java:515)
02-23 14:30:27.091: E/AndroidRuntime(1278): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
02-23 14:30:27.091: E/AndroidRuntime(1278): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
02-23 14:30:27.091: E/AndroidRuntime(1278): at dalvik.system.NativeStart.main(Native Method)
02-23 14:30:27.091: E/AndroidRuntime(1278): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4242000 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
02-23 14:30:27.091: E/AndroidRuntime(1278): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
02-23 14:30:27.091: E/AndroidRuntime(1278): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
02-23 14:30:27.091: E/AndroidRuntime(1278): at com.google.android.gms.internal.u.a(Unknown Source)
02-23 14:30:27.091: E/AndroidRuntime(1278): at com.google.android.gms.internal.ag.U(Unknown Source)
02-23 14:30:27.091: E/AndroidRuntime(1278): at com.google.android.gms.internal.ag.a(Unknown Source)
02-23 14:30:27.091: E/AndroidRuntime(1278): at com.google.android.gms.ads.AdView.loadAd(Unknown Source)
02-23 14:30:27.091: E/AndroidRuntime(1278): at biz.midl.debtcalculator.MainActivity.onCreate(MainActivity.java:41)
02-23 14:30:27.091: E/AndroidRuntime(1278): at android.app.Activity.performCreate(Activity.java:5231)
02-23 14:30:27.091: E/AndroidRuntime(1278): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-23 14:30:27.091: E/AndroidRuntime(1278): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
02-23 14:30:27.091: E/AndroidRuntime(1278): ... 11 more
Here is my .java:
import java.text.DecimalFormat;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
public class MainActivity extends Activity {
private AdView adView;
double interestRate;
double r, r1;
int nRemaining, nStarting, nDifference, originalBalance,
outstandingBalance, originalTerm;
double minPayment, additionalPayment, newPmt;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
adView = new AdView(this);
adView.setAdUnitId("xxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //edited out my unitID
adView.setAdSize(AdSize.BANNER);
LinearLayout layout = (LinearLayout) findViewById(R.id.ll);
layout.addView(adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
Here is my Layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/ll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1" >
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
I also have my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="biz.midl.debtcalculator"
android:versionCode="1"
android:versionName="1" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
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" />
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<activity
android:name="biz.midl.debtcalculator.MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.DeviceDefault.Light.NoActionBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="biz.midl.debtcalculator.About"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.DeviceDefault.Light.NoActionBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.ABOUT" />
</intent-filter>
</activity>
</application>
</manifest>
You need to leave the meta-data tag as is:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
Additionaly, you need to replace this tag:
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
With this (as suggested in the answer you linked):
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
Since you are using the Google Play Services and not the legacy AdMob SDK you need to replace the name of the activity class from com.google.ads.AdActivity to com.google.android.gms.ads.AdActivity
This may be part of the problem. It seems you are missing....
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
in you AndroidManifest.xml
Make sure you only have the Google Play Services library included and not both Google Play Services and Admob SDK.
It looks like the value of #integer/google_play_services_version is zero. Are the Google Play Services resources being included in your app?
if you are using unity you should use this.
<!-- Google Mobile Ads Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Removing the layout declaration and leaving the programmatic one worked. There were also some unrelated issues causing problems with Eclipse.
From update of play service to version 22 you can go without making above change , I am pasting the code for future reference here
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
in androidmanifest.xml file with having google play service as lib. project instead to use admobsdk.jar file
All you have to do is add this to your AndroidManifest.xml file:
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
it's appear to the screen missing activity with android configchanges in Android manifestxml

android.view.InflateException: Binary XML file line #2: Error inflating class fragment

i do everything, research every but still not working.
i read many page from here but not :(
Error logs:
11-18 10:25:46.743: D/AndroidRuntime(24336): Shutting down VM
11-18 10:25:46.743: W/dalvikvm(24336): threadid=1: thread exiting with uncaught exception (group=0x4001d578)
11-18 10:25:46.873: E/AndroidRuntime(24336): FATAL EXCEPTION: main
11-18 10:25:46.873: E/AndroidRuntime(24336): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.gmap/com.example.gmap.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
11-18 10:25:46.873: E/AndroidRuntime(24336): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
11-18 10:25:46.873: E/AndroidRuntime(24336): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
11-18 10:25:46.873: E/AndroidRuntime(24336): at android.app.ActivityThread.access$1500(ActivityThread.java:121)
11-18 10:25:46.873: E/AndroidRuntime(24336): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
11-18 10:25:46.873: E/AndroidRuntime(24336): at android.os.Handler.dispatchMessage(Handler.java:99)
11-18 10:25:46.873: E/AndroidRuntime(24336): at android.os.Looper.loop(Looper.java:138)
11-18 10:25:46.873: E/AndroidRuntime(24336): at android.app.ActivityThread.main(ActivityThread.java:3701)
11-18 10:25:46.873: E/AndroidRuntime(24336): at java.lang.reflect.Method.invokeNative(Native Method)
11-18 10:25:46.873: E/AndroidRuntime(24336): at java.lang.reflect.Method.invoke(Method.java:507)
Main Activity:
package com.example.gmap;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.gmap"
android:versionCode="1"
android:versionName="1.0" >
<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"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="17" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.gmap.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDq-Xosuk1Wzyw9WJ4bGjjE6XIhD90QNuA"/>
</application>
</manifest>
and main xml:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
Please any body help meeee.
Change this
public class MainActivity extends Activity {
to
public class MainActivity extends FragmentActivity {
You need the below
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
In application tag its outside the tag
I got this error when the one of the permissions were missing in the AndroidManifest.xml file.
adding the following permission solved the problem:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Remove Demo Map application from your phone. Then will be work fine. That works for me.

ActionBarSherlock: java.lang.IllegalStateException on very few Devices

I got a very strange issue. Im using ActionbarSherlock in my project. And on very few Devices i get a:
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.felitec.dow/de.felitec.dow.ui.LoginActivity}: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
at android.app.ActivityThread.access$500(ActivityThread.java:122)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4123)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
at com.actionbarsherlock.internal.ActionBarSherlockCompat.generateLayout(ActionBarSherlockCompat.java:976)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:902)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:836)
at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
at de.felitec.dow.ui.LoginActivity.onCreate(LoginActivity.java:36)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
... 11 more
My LoginActivity looks like this:
public class LoginActivity extends SherlockActivity implements AuthCallback<OAuthConsumer> {
private ProgressDialog progDialog;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
}
...
And my Manifest:
<application
android:label="#string/app_name"
android:icon="#drawable/ic_app_launcher"
android:name=".MainApplication"
android:theme="#style/MainAppTheme">
<activity
android:name=".ui.SplashActivity"
android:screenOrientation="portrait"
android:theme="#style/Theme.Sherlock.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".ui.LoginActivity"
android:windowSoftInputMode="adjustPan|stateHidden"
android:screenOrientation="portrait"/>
...
And finally my style.xml:
<style name="MainAppTheme" parent="#style/Theme.Sherlock.Light.DarkActionBar">
<item name="homeAsUpIndicator">#drawable/back_indicator</item>
...
Notice that the SplashActivity works just fine. When it starts the intent for LoginActivity it crashes, and i dont really see why.
thanks in advance
Update your Manifiest file with this.
android:theme="#style/Theme.Sherlock"

Categories

Resources