ActionBarSherlock - SherlockActivity issue - Couldn't find content container view - android

I've done the setup as described for ActionBarSherlock. I've also added ABS as a library project and believe this is working as expected as Eclipse is finding references to class's within it's packages. I've also set the theme as required in the code and in the AndroidManifest.xml:
Code:
import com.actionbarsherlock.app.SherlockActivity;
public class TestClass extends SherlockActivity{
Context myContext;
public void onCreate(Bundle savedInstanceState) {
setTheme(R.style.Theme_Sherlock_NoActionBar);
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.danieljgmaclean.xxx"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/px_icon"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock.Light" >
<activity
android:name="TestClass"
android:label="#string/app_name"
android:noHistory="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
However apon execution i'm getting the following exception thrown:
Caused by: java.lang.RuntimeException: Couldn't find content container view
This is being called on:
com.danieljgmaclean.xxx.TestClass.onCreate(TestClass.java:23)
I'm running the code on a 2.3.3 emulator and i've set the target build to 4.0.3 and JDK version to 1.6.
Any ideas would be appreciated.

In my case the problem was a "raw" folder inside res which contained the db of the app. So I just removed the folder and the actionbar worked again. Now the problem is that I need the raw...

Related

Why the import android.support.v7.widget.Toolbar cannot be resolved in my project

I've trying create an app which is need Toolbar. I've already add "appcompat_v7.jar" to my project which I've got no result.
I've already review some links below and they couldn't help so.
The Import android.support.v7 cannot be resolved
The import android.support.v7.app cannot be resolved
The Import android.support.v7 cannot be resolved
Here is my "AndroidManifect":
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tabex"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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>
</application>
</manifest>
Also image from Eclipse:
As you can see other import from v7 works but the Toolbar not. I've really appropriate your help.
Looking at your SDK Manager screenshot, you are using an old version of the Support Library. The Toolbar widget did not get introduced until v21, you are using v20. Upgrade to latest.
I've Upgrade my Android Support Library to Latest version which is 23.0.1 and It's work hundred percent.

Unable to instantiate activity componentinfo classnotfoundexception

I've developed an app but when I run it, it crashes and shows the error: android unable to instantiate activity componentinfo classnotfoundexception.
I've read a lot about this error. I've tried Project -> Properties -> Java Build Path -> Order & Export and ensure Android Private Libraries and all other library projects are checked.
I've also noticed that when I press ctrl and pass the mouse over, for example, .MainActivity in my Android Manifest file, it doesn't display or link me to the Activity, don't know why.
Any ideas about this problem? Thank you so much.
EDIT: Manifest added
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.isa.mememe"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</manifest>

Hello world app Eclipse not working

I have recently installed Eclipse ADT bundle, updates all the sdk tool etc. Eclipse, AVD everything is working great. I can Import other samples and it runs and works great on both my android device and AVD.
However, i am new to all this and i wanted to start with the hello world app tutorial written up by http://developer.android.com/training/basics/firstapp/creating-project.html
It basically says that when you start a new Android application project with default settings, only choosing "blank activity", that by default it will build as a Hello World App that can be immediately run straight off the bat. But this is not the case, when i try to run i get,
[2014-07-02 14:20:20 - Jeremy] No Launcher activity found!
[2014-07-02 14:20:20 - Jeremy] The launch will only sync the application package on the device!
There is no launch activity coded into the manifest.xml file like i have seen in other examples. I just really want to start from the basics, yet i can't even get to follow this tutorial because i can't get the default hello world app to work.
The manifest file as is,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.jeremy"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
</application>
</manifest>
And there is no file in the Src folder either, just it says that's where the activity class is meant to be?
Can someone please advise me how to get this basic hello world app running?
Thanking you in advance,
Jeremy
Try to create a package under 'src' folder like "com.example.jeremy" and try to create a class called MainActivity.java
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.jeremy"
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="#style/AppTheme" >
<activity
android:name="com.example.jeremy.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>
</application>
</manifest>
you have not declared the activity tag in manifest.xml

class not found exception in using actionbar sherlock

I downloaded actionbar sherlock library from the main site itself. and i tried to use it in my app.
import com.actionbarsherlock.app.SherlockActivity;
import android.os.Bundle;
public class Sherlockactivity extends SherlockActivity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
but when i started the app with the default main.xml layout, i get this exception.
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.android.sherlock/com.android.sherlock.SherlockActivity}: java.lang.ClassNotFoundException: com.android.sherlock.SherlockActivity in loader dalvik.system.PathClassLoader[/data/app/com.android.sherlock-1.apk]
my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.sherlock"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="14" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
<activity
android:name=".SherlockActivity"
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>
i just started to use support libraries. have no idea how to solve this.
Thank you
Download sherlock action bar zip.
New->android project from existed source
choose library folder from sherlock bar folder
in the properties of your project, ->android->add library and set the folder that you copy.
See Using an ActionBar in your Android app with ActionBarSherlock.

Are there problems with ActivityInstrumentationTestCase2 in Android 2.1?

After I have set up all the unit test cases for my android application I now also want to do functional testing. But I encouter one problem. As I am developping for the HTC Legend I can, by now, only use android platforms up to 2.1. But in some way it seems that the ActivityInstrumentationTestCase2 won't work.
public SupplierSelectoinTest() {
super("com.sap.catalogue.activities", SupplierSelection.class);
}
This simple piece of code gives me the following error, when I try to run the test:
java.lang.RuntimeException: Unable to resolve activity for: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.sap.catalogue.activities/com.sap.catalogue.activities.SupplierSelection }
at android.app.Instrumentation.startActivitySync(Instrumentation.java:371)
at android.test.InstrumentationTestCase.launchActivityWithIntent(InstrumentationTestCase.java:120)
at android.test.InstrumentationTestCase.launchActivity(InstrumentationTestCase.java:98)
at android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:87)
at com.sap.catalogue.test.acceptance.SupplierSelectoinTest.setUp(SupplierSelectoinTest.java:27)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
I read through all tutorials and all I get out of it is, that it should work but it doesn't. Anyway, when I switch to android 2.2 (which is no solution for now) and I use the new constructor, where I only need to hand in the activity class and not the pkg string the emulator will run the tests without complaining.
But there has to be a way to get this running in android 2.1!
In addition
These are my two Manifest.xml files. The first one, is the one of the application itself. The other one is the one of the test project.
Application Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sap.catalogue"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Catalogue"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activities.CategoryBrowser"></activity>
<activity android:name=".activities.ProductDetails"></activity>
<activity android:name=".activities.ProductSearch"></activity>
<activity android:name=".activities.ProductView"></activity>
<activity android:name=".activities.SupplierSelection"></activity>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
Test Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sap.catalogue.test"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<uses-library android:name="android.test.runner" />
</application>
<uses-sdk android:minSdkVersion="7" />
<instrumentation android:targetPackage="com.sap.catalogue" android:name="android.test.InstrumentationTestRunner" />
</manifest>
Use the top level package name.
public SupplierSelectoinTest() {
super("com.sap.catalogue", SupplierSelection.class);
}
Most probably, you didn't write the activity in the Manifest.xml. Would you share it also?
Edit:
Add this to the test Manifest.xml. I think, this will solve your problem.
<activity android:name="com.sap.catalogue.activities.SupplierSelection"></activity>

Categories

Resources