I created a new Android application project in Eclipse on Mac. I set it up Android 4.4.2 sdk.
When I installed this sample project in the physical Nexus 7 Tablet, it throws the following launching error . I have not added anything yet in this project, it is just a sample project created as it is.
Unfortunately has stopped
04-13 00:16:05.395: W/dalvikvm(6761): Unable to resolve superclass of Lcom/example/myfinaltest/MainActivity; (2)
04-13 00:16:05.395: W/dalvikvm(6761): Link of class 'Lcom/example/myfinaltest/MainActivity;' failed
04-13 00:16:05.395: D/AndroidRuntime(6761): Shutting down VM
04-13 00:16:05.395: W/dalvikvm(6761): threadid=1: thread exiting with uncaught exception (group=0x415bcba8)
04-13 00:16:05.395: E/AndroidRuntime(6761): FATAL EXCEPTION: main
04-13 00:16:05.395: E/AndroidRuntime(6761): Process: com.example.myfinaltest, PID: 6761
04-13 00:16:05.395: E/AndroidRuntime(6761): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.myfinaltest/com.example.myfinaltest.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.myfinaltest.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.myfinaltest-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.myfinaltest-2, /vendor/lib, /system/lib]]
04-13 00:16:05.395: E/AndroidRuntime(6761): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
04-13 00:16:05.395: E/AndroidRuntime(6761): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
04-13 00:16:05.395: E/AndroidRuntime(6761): at android.app.ActivityThread.access$800(ActivityThread.java:135)
04-13 00:16:05.395: E/AndroidRuntime(6761): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
04-13 00:16:05.395: E/AndroidRuntime(6761): at android.os.Handler.dispatchMessage(Handler.java:102)
04-13 00:16:05.395: E/AndroidRuntime(6761): at android.os.Looper.loop(Looper.java:136)
04-13 00:16:05.395: E/AndroidRuntime(6761): at android.app.ActivityThread.main(ActivityThread.java:5017)
04-13 00:16:05.395: E/AndroidRuntime(6761): at java.lang.reflect.Method.invokeNative(Native Method)
04-13 00:16:05.395: E/AndroidRuntime(6761): at java.lang.reflect.Method.invoke(Method.java:515)
04-13 00:16:05.395: E/AndroidRuntime(6761): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-13 00:16:05.395: E/AndroidRuntime(6761): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-13 00:16:05.395: E/AndroidRuntime(6761): at dalvik.system.NativeStart.main(Native Method)
04-13 00:16:05.395: E/AndroidRuntime(6761): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.myfinaltest.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.myfinaltest-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.myfinaltest-2, /vendor/lib, /system/lib]]
04-13 00:16:05.395: E/AndroidRuntime(6761): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
04-13 00:16:05.395: E/AndroidRuntime(6761): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
04-13 00:16:05.395: E/AndroidRuntime(6761): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
04-13 00:16:05.395: E/AndroidRuntime(6761): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
04-13 00:16:05.395: E/AndroidRuntime(6761): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
04-13 00:16:05.395: E/AndroidRuntime(6761): ... 11 more
Code:
package com.example.myfinaltest;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@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;
}
@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);
}
}
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfinaltest"
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"
>
<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>
For, values/styles.xml and values-v11/styles.xml and values-v14/styles.xml
same values for all 3 xml's, however I commented App theme, because I was seeing errors building with Appcompat libs.
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
</style>
-->
<!-- Application theme.
<style name="AppTheme" parent="AppBaseTheme">
</style>
-->
</resources>