Reputation: 25
I am trying to build a HelloWorld android app using cordova. I am following footsteps mentioned on follwoing page http://javaonlineguide.net/2015/06/apache-cordova-hello-world-program-for-android-platform-in-eclipse-example.html
I've been browsing the issue and I'm pretty sure I'm not having the same issues as mentioned. Both of my activities are declared in the AndroidManifest and the intent filter is there. I tried replacing in my Manifest com.example.main.MainActivity by .MainActivity but still no luck. I'm using Eclipse IDE In Java build path-> Order and Export Android Private Libraries is checked
I have tried building and cleaning project again and again. I even tried restarting Eclipse.
Here is Logcat:
07-14 06:07:36.169: E/AndroidRuntime(1133): FATAL EXCEPTION: main
07-14 06:07:36.169: E/AndroidRuntime(1133): Process: com.example.main, PID: 1133
07-14 06:07:36.169: E/AndroidRuntime(1133): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.main/com.example.main.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.main.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.main-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.main-1, /system/lib]]
07-14 06:07:36.169: E/AndroidRuntime(1133): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
07-14 06:07:36.169: E/AndroidRuntime(1133): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
07-14 06:07:36.169: E/AndroidRuntime(1133): at android.app.ActivityThread.access$800(ActivityThread.java:135)
07-14 06:07:36.169: E/AndroidRuntime(1133): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
07-14 06:07:36.169: E/AndroidRuntime(1133): at android.os.Handler.dispatchMessage(Handler.java:102)
07-14 06:07:36.169: E/AndroidRuntime(1133): at android.os.Looper.loop(Looper.java:136)
07-14 06:07:36.169: E/AndroidRuntime(1133): at android.app.ActivityThread.main(ActivityThread.java:5001)
07-14 06:07:36.169: E/AndroidRuntime(1133): at java.lang.reflect.Method.invokeNative(Native Method)
07-14 06:07:36.169: E/AndroidRuntime(1133): at java.lang.reflect.Method.invoke(Method.java:515)
07-14 06:07:36.169: E/AndroidRuntime(1133): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
07-14 06:07:36.169: E/AndroidRuntime(1133): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
07-14 06:07:36.169: E/AndroidRuntime(1133): at dalvik.system.NativeStart.main(Native Method)
07-14 06:07:36.169: E/AndroidRuntime(1133): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.main.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.main-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.main-1, /system/lib]]
07-14 06:07:36.169: E/AndroidRuntime(1133): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
07-14 06:07:36.169: E/AndroidRuntime(1133): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
07-14 06:07:36.169: E/AndroidRuntime(1133): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
07-14 06:07:36.169: E/AndroidRuntime(1133): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
07-14 06:07:36.169: E/AndroidRuntime(1133): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2101)
Here is AndroidManifest.xml :
<?xml version='1.0' encoding='utf-8'?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.main"
android:hardwareAccelerated="true"
android:versionCode="1"
android:versionName="0.0.1" >
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:hardwareAccelerated="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:supportsRtl="true" >
<activity
android:name="MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:label="@string/activity_name"
android:launchMode="singleTop"
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
android:windowSoftInputMode="adjustResize" >
<intent-filter android:label="@string/launcher_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="23" />
</manifest>
Here is MainActivity.java
package com.example.main;
import android.os.Bundle;
import org.apache.cordova.*;
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
}
Upvotes: 0
Views: 7765
Reputation: 1855
In your manifest, do this if the name is already '.MainActivity'
and still showing error.
Eg :
<activity
android:name="com.pakgename.MainActivity"
...
</activity>
Upvotes: 0
Reputation: 6673
I have stopped the Instant run from Android studio and its working.
File->Setting->Build->Instant Run->Disble checkbox of Enable instant run to hotswap code/resource changes
Upvotes: 5
Reputation: 25
All I needed to do was build application using Cordova.
I was building project in Eclipse but with that I also needed to build project using command :
E:\Software\Demo\VMSapp>cordova build
This command updates APK file.
Upvotes: 0
Reputation: 20920
because you are declare this way
<activity
android:name="MainActivity"
just put .
to MainActivity
like this
<activity
android:name=".MainActivity"
Upvotes: 1
Reputation: 2451
In your manifest, in your activity tag, add a '.' before MainActivity
`android:name=".MainActivity"`
You can consider android.name
as a continuation of package
name. So, without the dot it would be com.example.mainMainActivity
which is wrong. The correct structure would be com.example.main.MainActivity
Upvotes: 0