How to make simple android app with roboguice that injects a textView? - android

I'm a beginner in dependency injection and roboguice. I just want to be able to inject views and resources in my app. The problem is, I get a ClassNotFoundException when I extend my class with RoboActivity.
package tes.tes;
//imports
public class test extends RoboActivity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
Here's the stacktrace:
06-09 13:54:08.887: ERROR/AndroidRuntime(495): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{tes.tes/tes.tes.test}:java.lang.ClassNotFoundException: tes.tes.test in loader dalvik.system.PathClassLoader[/data/app/tes.tes-1.apk]
06-09 13:54:08.887: ERROR/AndroidRuntime(495): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
06-09 13:54:08.887: ERROR/AndroidRuntime(495): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
...
06-09 13:54:08.887: ERROR/AndroidRuntime(495): Caused by: java.lang.ClassNotFoundException: tes.tes.test in loader dalvik.system.PathClassLoader[/data/app/tes.tes-1.apk]
06-09 13:54:08.887: ERROR/AndroidRuntime(495): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243
...
and my manifest
coding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tes.tes"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".test"
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 think my dependencies are fine since I can see the jar files for guice, roboguice, etc..
I tried following the documentation and downloading the sample code but it was too complicated for me.
I don't know what I'm missing.
Thanks for the help.

I'm submitting a new answer because RoboGuice 2.0 has changed the way this works. Now, create an XML file in res/values/ named roboguice.xml. List your modules there, like so:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="roboguice_modules">
<item>com.example.CustomRenderModule</item>
<item>com.you.yourmodule.TexModule</item>
</string-array>
</resources>
Another example.

You're not properly extending RoboApplication. Please consider going through the complete RoboGuice installation tutorial

I followed the manual and used proper naming conventions and it worked!
although this line
#Override
protected void addApplicationModules(List<Module> modules) {
modules.add(new MyModule());
}
in MyApplication.java which extends RoboApplication has errors and says remove #Override and when I remove the #Override it says it clashes with another method located in RoboApplication. I dont know why.

Related

Flutter Android ERROR: ensureInitializationComplete must be called after startInitialization

Currently I'm trying to add a flutter app to my android app but when I try to do an Intent the app crashes and prints the following issue:
I followed this guide here
I get this error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testappandroid/io.flutter.embedding.android.FlutterActivity}: java.lang.IllegalStateException: ensureInitializationComplete must be called after startInitialization
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.IllegalStateException: ensureInitializationComplete must be called after startInitialization
at io.flutter.view.FlutterMain.ensureInitializationComplete(FlutterMain.java:168)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.initializeFlutter(FlutterActivityAndFragmentDelegate.java:177)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:140)
at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:399)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
So it says: ensureInitializationComplete must be called after startInitialization. One solution is to call FlutterMain.startInitialization(this) in the Flutter Activity. But this isn't working for me:
My Flutter Activity:
public class MainActivity extends FlutterActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
FlutterMain.startInitialization(this);
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
My android app AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.testappandroid">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="io.flutter.embedding.android.FlutterActivity"
android:theme="#style/AppTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<meta-data
android:name="io.flutter.Entrypoint"
android:value="main"
/>
</activity>
</application>
</manifest>
My flutter module AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testappflutter.host">
<!-- The INTERNET permission is required for development. Specifically,
flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="testappflutter"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in #style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
With this line of code I try to open the FlutterActivtiy. This is calling the main() function in my dart code:
Intent defaultFlutter = createDefaultIntent(activity);
activity.startActivity(defaultFlutter);
The code above should start this:
void main() => runApp(MaterialApp(
routes: {
"/": (context) => TestWidget()
}
));
So I followed step by step the guide for adding Flutter to an existing android app. Do I forget something? In my mind maybe the AndroidManifest of the flutter app needs some changes? Any ideas what I'm doing wrong?
insure that you import the right packages:
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
instead of
import io.flutter.app.FlutterActivity
in your MainActivity so your Main activity should look like this:
package com.example.example
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
class MainActivity: FlutterActivity() {
}
FlutterMain.startInitialization(this);
Add This Line Before Super.Create like
FlutterMain.startInitialization(this) //Added line
super.onCreate(savedInstanceState)
GeneratedPluginRegistrant.registerWith(this)
Despite the message ensureInitializationComplete must be called after startInitialization, it is not required to call it. Run Flutter activity this way:
FlutterMain.startInitialization(context)
startActivity(FlutterActivity.createDefaultIntent(context))
If you get the crash NoClassDefFoundError (class DefaultLifecycleObserver), add this dependency to your android module:
implementation 'android.arch.lifecycle:common-java8:1.1.0'

Different Application class per build variant crashes on some devices

I've modified my build.gradle to use different Application classes based on build-variant (debug / release).
I've added two WrapperApplication classes one in folder "debug", and the second in folder "release", both classes extend some base Application class.
In AndroidManifest I point to com.my.package.WrapperApplication and it indeed uses the correct one.
When releasing a test apk to Play, I got a pre-launch report that my new version crashed on 2 of the 13 devices tested (Moto G and Moto X).
Would love to know why is it crashing, and if something is wrong in the build, how is it working for me and for the other 11 test devices tested.
Here's the stack I received:
FATAL EXCEPTION: main
Process: com.my.package, PID: 16348
java.lang.RuntimeException: Unable to instantiate application com.my.package.WrapperApplication: java.lang.IllegalStateException: Unable to get package info for com.my.package; is package not installed?
at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4398)
at android.app.ActivityThread.access$1500(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1270)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5102)
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.IllegalStateException: Unable to get package info for com.my.package; is package not installed?
at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:376)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:329)
at android.app.LoadedApk.makeApplication(LoadedApk.java:508)
... 11 more
Thanks.
EDIT:
Previously we used the following method, but using the variant-specific folders is cleaner for our build system, so we'd love to switch to it.
Previous method:
AndroidManifest:
<application
android:name="${application}"
... />
build.gradle:
debug {
manifestPlaceholders = [application:".Application1"]
}
release {
manifestPlaceholders = [application: ".Application2"]
}
I don't know what is the reason for the issues. But we are doing a different approach:
We have base Application with common functionality and it also contains protected methods for future behaviour modification:
public class MyApp extends application {
public void onCreate() {
super.onCreate();
initLogging();
}
protected void initLogging() {}
}
We create another app in flavour or build configuration source folder and override behaviour:
public class DebugMyApp extends MyApp {
#Override
protected void initLogging() {
//init Stetho
}
}
We also create another AndroidManifest.xml in flavour or build configuration source folder where we override application name:
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="com.philips.pins.ugrow"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
​
<application
android:name=".DebugMyApp"
android:label="#string/app_name"
tools:replace="android:name,android:label">
<activity android:name="net.hockeyapp.android.UpdateActivity"/>
</application> ​
</manifest>
Sure extension of the app is not necessary and you can define two different app classes but just correctly define them in manifest files.

NotificationListenerService with RemoteController.OnClientUpdateListener crashes on API18 (4.3)

The Problem
I want to implement the new RemoteController API, which has been introduced with API19 (Kitkat,4.4). The API requires me to implement a class which extends from NotificationListenerService (introduced with API18) and implements the RemoteController.OnClientUpdateListener interface. (Further information on how to implement all this can be found here and a very helpful example project can be found here)
Everything's working as it should on my API19 (Kitkat,4.4) device and every other API<18 device. However the problem is, that the app crashes right away on API18 (Jelly bean, 4.3), because the "android.service.notification.NotificationListenerService" is being sent and starts my RemoteService, which then crashes the app instantly with the following Stacktrace:
05-24 09:32:48.945 893-893/com.example E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate service com.example.RemoteService: java.lang.ClassNotFoundException: Didn't find class "com.example.RemoteService" on path: DexPathList[[zip file "/data/app/com.example-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example-1, /system/lib]]
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2561)
at android.app.ActivityThread.access$1600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1338)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.RemoteService" on path: DexPathList[[zip file "/data/app/com.example-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example-1, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2558)
at android.app.ActivityThread.access$1600(ActivityThread.java:141
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1338)
...
This is caused by the simple fact, that RemoteController and therefore the implemented interface RemoteController.OnClientUpdateListener is not available on API18, but NotificationListenerService is. The intent is not being sent on every device
What I've tried so far
Put another layer of abstraction on it and build a simple "if (API>=19)" check.
I tried to do this by using a second empty NotificationListenerService which would just work as a kind of callthrough Service. I would put that second Service in my AndroidManifest, so that it receives the intent instead, and then I'd just put the "if (API>=19)" check in its onCreate and start my actual RemoteService from there. The result is, that my App doesn't crash any more (yay). Unfortunately it also doesn't work in API19 Kitkat any more :(. I think that's because I have to register my RemoteService as a listener in my AndroidManifest directly, or otherwise it won't receive anything.
Code snippets
RemoteService.java:
public class RemoteService extends NotificationListenerService
implements RemoteController.OnClientUpdateListener {
...
}
AndroidManifest.xml:
<manifest ...>
<application ...>
<service android:name="com.example.RemoteService"
android:label="#string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
</application>
</manifest>
The solution
Put a bool in an xml file in values and values-v19. Set it to false in values and to true in values-v19. Now set the NotificationListenerService's "android:enabled" tag to this bool.
./values/bool_switches.xml:
<resources>
<bool name="remotecontrollerservice_enabled">false</bool>
</resources>
./values-v19/bool_switches.xml:
<resources>
<bool name="remotecontrollerservice_enabled">true</bool>
</resources>
./AndroidManifest.xml:
...
<service android:name=".services.RemoteControllerService"
android:label="#string/scrobblingservice_string"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
android:enabled="#bool/remotecontrollerservice_enabled">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService"/>
</intent-filter>
</service>
...
Just disable the service with android:enabled="false", then in Application.onCreate enable it if the device is running KitKat or newer.

Using Android Emulator (eclipse) fails to start the tic-tac-toe example

I am trying to test the tic-tac-toe in eclipse. It compiles and deploys to emulator device (AVD) but no matter what version of Android I use, the application deployed says: Application Stopped. Close it. Is there any specific setting I should follow?
Note: I already setup the Eclipse environment, add libraries, etc.
Thanks!
Here is the log error:
01-16 01:07:35.994: E/AndroidRuntime(883): FATAL EXCEPTION: main
01-16 01:07:35.994: E/AndroidRuntime(883): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.google.cast.samples.tictactoe/com.google.cast.samples.tictactoe.GameActivity}: java.lang.ClassNotFoundException: Didn't find class "com.google.cast.samples.tictactoe.GameActivity" on path: DexPathList[[zip file "/data/app/com.google.cast.samples.tictactoe-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.google.cast.samples.tictactoe-1, /system/lib]]
01-16 01:07:35.994: E/AndroidRuntime(883): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
01-16 01:07:35.994: E/AndroidRuntime(883): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
01-16 01:07:35.994: E/AndroidRuntime(883): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-16 01:07:35.994: E/AndroidRuntime(883): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.cast.samples.tictactoe.GameActivity" on path: DexPathList[[zip file "/data/app/com.google.cast.samples.tictactoe-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.google.cast.samples.tictactoe-1, /system/lib]]
01-16 01:07:35.994: E/AndroidRuntime(883): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
Thanks Ali. Here is the manifest, but I see there is a match of class and activity.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.cast.samples.tictactoe"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature
android:name="android.hardware.wifi"
android:required="true" >
</uses-feature>
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat" >
<activity
android:name=".GameActivity"
android:configChanges="orientation|keyboardHidden"
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>
Exception states that it didn't find your GameActivity class. Check your Manifest and see if the name given there as the launcher activity (GameActivity) matches with the class that you have in your package, check the package names, etc. The exception has nothing to do (at least the piece that you have shown) with Cast.
Thanks for all the help. I solved by silly configuration. I created a libs folder and copied under GoogleCastSDKAndroid.jar (marked as Private Library). Compiled and it worked perfect!
Now, I just learned the casting function can't work because AVD runs a different IP address (in my case registered a 10.0.2.15) than my wifi segment (192.168.1.x). Therefore, the AVD can't see a chrome device.
I hope this last conclusion helps other people. The first was a mistake of configuration.

ActivityNotFoundException on FragmentActivity

I do have lots of plain old activity-based apps in the Play Store. Since two days I try to do my first steps with Fragments. I still don't get it. I've read mostly all docs and blogs and guides about Fragments but my stupid simple test app refuses to start with an ClassNotFoundException on MyActivity.
So here's what I did so far:
The starting FragmentActivity called MyActivity:
public class MyActivity extends FragmentActivity {
#Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.myactivity);
}
}
Here's the layout/myactivity.xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<fragment
class="com.test.app.Table1List"
android:id="#+id/table1list"
android:layout_height="match_parent"
android:layout_width="match_parent" />
</LinearLayout>
This is the ListFragment with its XML file:
public class Table1List extends ListFragment {
#Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
if (viewGroup == null) {
return null;
}
return layoutInflater.inflate(R.layout.table1list, viewGroup);
}
}
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ListView
android:drawSelectorOnTop="false"
android:fastScrollEnabled="true"
android:id="#id/android:list"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
<TextView
style="#style/TextViewMedium"
android:id="#id/android:empty"
android:text="#string/txt_noresult" />
</LinearLayout>
Call me stupid but I always do get an ActivityNotFoundException during start of the FragmentActivity called MyActivity.
Any help is highly appreciated.
EDIT:
I took the latest v4 Compatibility Package from several days ago. I issued clean projects nearly every 10 minutes - no go.
Here's the Manifest:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0"
package="com.test.app" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="11" />
<application
android:hardwareAccelerated="true"
android:icon="#drawable/ic_launcher"
android:label="#string/txt_appname" >
<activity
android:label="#string/txt_appname"
android:name="MyActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
EDIT 2: Here's the LogCat:
Unable to resolve superclass of Lcom/test/app/MyActivity; (25)
Link of class 'Lcom/test/app/MyActivity;' failed
Shutting down VM
threadid=3: thread exiting with uncaught exception (group=0x4001b188)
Uncaught handler: thread main exiting due to uncaught exception
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.test.app/com.test.app.MyActivity}: java.lang.ClassNotFoundException: com.test.app.MyActivity in loader dalvik.system.PathClassLoader#44bfda38
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
at android.app.ActivityThread.access$2200(ActivityThread.java:119)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.test.app.MyActivity in loader dalvik.system.PathClassLoader#44bfda38
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
... 11 more
EDIT 3: I did re-install the support package, created a new project with Compatability Package v4, stripped down everything to just the MyActivity and one fragment --> same error. I even tested with the previous Support v4 package (Release 6).
These are my first steps with Fragments after nearly three years with Android development (lots of apps in the market). Seems that this whole thing is broken.
This is the project tree in eclipse - any help still highly required.
I don't know if this will fix your problem but looking at your screenshot, everything looks correct to me except the Referenced Libraries item. That shouldn't be there any more because the latest ADT version 17 automatically detects all jars in the libs folder. You can get rid of the Referenced Libraries item by removing the explicit reference to the android support jar from your build path.
I had a very similar problem and was completely stumped for a while until I read this blog post which has a lot of information about this issue so it might be worth a read even if removing the Referenced Libraries doesn't work.
Something seems to be not working as expected.
Copy the compatibility jar to a folder libs and then recompile and repackage

Categories

Resources