Tim Hannah
Tim Hannah

Reputation: 172

android app compatibility

I have created an app with target api of 4.0.3 (15) I however set in the manifest that the min api is 2.3.3 (10) when i run the app on my 4.0 device it works find, when i run it on my 2.3 device it doesn't load just force closes at start up...

I know that android have problems with fragmentation between builds, i was wondering if there was an easy way of making the app work on both systems or will i have to code a 2.3 version aswell. I'm a novice coder so please be gentle with me.

08-17 18:57:15.722: D/AndroidRuntime(4535): Shutting down VM
08-17 18:57:15.722: W/dalvikvm(4535): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
08-17 18:57:15.722: E/AndroidRuntime(4535): FATAL EXCEPTION: main
08-17 18:57:15.722: E/AndroidRuntime(4535): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.reading.festival/com.reading.festival.ReadingFestival2012Activity}: java.lang.ClassNotFoundException: com.reading.festival.ReadingFestival2012Activity in loader dalvik.system.PathClassLoader[/data/app/com.reading.festival-1.apk]
08-17 18:57:15.722: E/AndroidRuntime(4535):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1785)
08-17 18:57:15.722: E/AndroidRuntime(4535):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893)
08-17 18:57:15.722: E/AndroidRuntime(4535):     at android.app.ActivityThread.access$1500(ActivityThread.java:135)
08-17 18:57:15.722: E/AndroidRuntime(4535):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
08-17 18:57:15.722: E/AndroidRuntime(4535):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-17 18:57:15.722: E/AndroidRuntime(4535):     at android.os.Looper.loop(Looper.java:150)
08-17 18:57:15.722: E/AndroidRuntime(4535):     at android.app.ActivityThread.main(ActivityThread.java:4385)
08-17 18:57:15.722: E/AndroidRuntime(4535):     at java.lang.reflect.Method.invokeNative(Native Method)
08-17 18:57:15.722: E/AndroidRuntime(4535):     at java.lang.reflect.Method.invoke(Method.java:507)
08-17 18:57:15.722: E/AndroidRuntime(4535):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
08-17 18:57:15.722: E/AndroidRuntime(4535):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
08-17 18:57:15.722: E/AndroidRuntime(4535):     at dalvik.system.NativeStart.main(Native Method)
08-17 18:57:15.722: E/AndroidRuntime(4535): Caused by: java.lang.ClassNotFoundException: com.reading.festival.ReadingFestival2012Activity in loader dalvik.system.PathClassLoader[/data/app/com.reading.festival-1.apk]
08-17 18:57:15.722: E/AndroidRuntime(4535):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
08-17 18:57:15.722: E/AndroidRuntime(4535):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
08-17 18:57:15.722: E/AndroidRuntime(4535):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-17 18:57:15.722: E/AndroidRuntime(4535):     at android.app.Instrumentation.newActivity(Instrumentation.java:1040)
08-17 18:57:15.722: E/AndroidRuntime(4535):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1777)
08-17 18:57:15.722: E/AndroidRuntime(4535):     ... 11 more

main activity

package com.reading.festival;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

public class ReadingFestivalGuide2012Activity extends Activity  {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //makes full screen and takes away title bar
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    //

    setContentView(R.layout.main);

    Button sitemap = (Button) findViewById(R.id.sitemap);
    sitemap.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent myIntent = new Intent(view.getContext(), sitemap.class);
            startActivityForResult(myIntent, 0);
        }
    });

    Button lineup = (Button) findViewById(R.id.lineup);
    lineup.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent myIntent = new Intent(view.getContext(), lineup.class);
            startActivityForResult(myIntent, 0);
                }
            });
        }
    }

Upvotes: 0

Views: 180

Answers (2)

Tim Hannah
Tim Hannah

Reputation: 172

Ok after reading through my code I have managed to work out that i was using something the the xml called that I have found out now isnt supported in api below 14 removed this and it now works

Upvotes: 0

IncrediApp
IncrediApp

Reputation: 10343

You need to check the logcat for the exact error. Your error might be that you're using a call to a "newer" piece of code which isn't available on your 2.3 device. Logcat is a must (to track exceptions and figure out what's wrong with the app) but an easy check for the problem I've mentioned can be done by changing the target SDK to 10 and checking for compilation errors.

Upvotes: 1

Related Questions