I'm trying to use OpenCV on android
I created my android project, added javacv.jar and iavacpp.jar to the build path, created the lib folder and copied the *.so files from javacv-arm.jar to libs/armeabi.
All jar & *.so files are version 2.4.2.
When I run the app, I created a test button. When it is clicked I'm calling this line:
IplImage image = cvLoadImage("file:///android_asset//"+"pic1.jpg");
and get the following crash
03-12 19:22:12.189: E/AndroidRuntime(4524): FATAL EXCEPTION: main
03-12 19:22:12.189: E/AndroidRuntime(4524): java.lang.ExceptionInInitializerError
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.myapp.MainActivity.runTest(MainActivity.java:260)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.myapp.MainActivity$3.onClick(MainActivity.java:174)
03-12 19:22:12.189: E/AndroidRuntime(4524): at android.view.View.performClick(View.java:4084)
03-12 19:22:12.189: E/AndroidRuntime(4524): at android.view.View$PerformClick.run(View.java:16966)
03-12 19:22:12.189: E/AndroidRuntime(4524): at android.os.Handler.handleCallback(Handler.java:615)
03-12 19:22:12.189: E/AndroidRuntime(4524): at android.os.Handler.dispatchMessage(Handler.java:92)
03-12 19:22:12.189: E/AndroidRuntime(4524): at android.os.Looper.loop(Looper.java:137)
03-12 19:22:12.189: E/AndroidRuntime(4524): at android.app.ActivityThread.main(ActivityThread.java:4745)
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.reflect.Method.invoke(Method.java:511)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-12 19:22:12.189: E/AndroidRuntime(4524): at dalvik.system.NativeStart.main(Native Method)
03-12 19:22:12.189: E/AndroidRuntime(4524): Caused by: java.lang.ExceptionInInitializerError
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.Class.classForName(Native Method)
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.Class.forName(Class.java:217)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacpp.Loader.load(Loader.java:334)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
03-12 19:22:12.189: E/AndroidRuntime(4524): ... 13 more
03-12 19:22:12.189: E/AndroidRuntime(4524): Caused by: java.lang.ExceptionInInitializerError
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.Class.classForName(Native Method)
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.Class.forName(Class.java:217)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacpp.Loader.load(Loader.java:334)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:96)
03-12 19:22:12.189: E/AndroidRuntime(4524): ... 17 more
03-12 19:22:12.189: E/AndroidRuntime(4524): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1891]: 124 could not load needed library 'libopencv_core.so' for 'libjniopencv_core.so' (load_library[1093]: Library 'libopencv_core.so' not found)
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.Runtime.loadLibrary(Runtime.java:370)
03-12 19:22:12.189: E/AndroidRuntime(4524): at java.lang.System.loadLibrary(System.java:535)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:444)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacpp.Loader.load(Loader.java:368)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacpp.Loader.load(Loader.java:315)
03-12 19:22:12.189: E/AndroidRuntime(4524): at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:131)
03-12 19:22:12.189: E/AndroidRuntime(4524): ... 21 more
03-12 19:22:12.243: D/dalvikvm(4524): GC_CONCURRENT freed 2368K, 16% free 16864K/20039K, paused 12ms+3ms, total 50ms
Am I missing libopencv_core.so? If so, where can I find it built for version 2.4.2?
Thanks!
I'm sure by now you've figured it out. download javacv-0.5-cppjars.zip, inside it extract the contents of opencv-2.4.5-android-arm.jar. you'll find libopencv_core.so in there and several other .so files
Related
I got message "No apps can perform this action" in my testing phone but in tablet, it work fine. My testing phone is android version 4.2.2 and my tablet is android version 4.4.4. Here is my code.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
String[] mimetypes = {"application/pdf","text/plain","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.wordprocessingml.document"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
startActivityForResult(Intent.createChooser(intent, "Select File"), 3);
If I change in something like that,
startActivityForResult(intent, 3);
I got this errors from my phone, but still fine in tablet.
03-12 09:22:40.015: E/test(10739): Exception
03-12 09:22:40.026: E/AndroidRuntime(10739): FATAL EXCEPTION: main
03-12 09:22:40.026: E/AndroidRuntime(10739): java.lang.IllegalStateException: Could not execute method of the activity
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.view.View$1.onClick(View.java:3688)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.view.View.performClick(View.java:4293)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.view.View$PerformClick.run(View.java:17535)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.os.Handler.handleCallback(Handler.java:725)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.os.Handler.dispatchMessage(Handler.java:92)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.os.Looper.loop(Looper.java:153)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.ActivityThread.main(ActivityThread.java:5299)
03-12 09:22:40.026: E/AndroidRuntime(10739): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 09:22:40.026: E/AndroidRuntime(10739): at java.lang.reflect.Method.invoke(Method.java:511)
03-12 09:22:40.026: E/AndroidRuntime(10739): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
03-12 09:22:40.026: E/AndroidRuntime(10739): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
03-12 09:22:40.026: E/AndroidRuntime(10739): at dalvik.system.NativeStart.main(Native Method)
03-12 09:22:40.026: E/AndroidRuntime(10739): Caused by: java.lang.reflect.InvocationTargetException
03-12 09:22:40.026: E/AndroidRuntime(10739): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 09:22:40.026: E/AndroidRuntime(10739): at java.lang.reflect.Method.invoke(Method.java:511)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.view.View$1.onClick(View.java:3683)
03-12 09:22:40.026: E/AndroidRuntime(10739): ... 11 more
03-12 09:22:40.026: E/AndroidRuntime(10739): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.OPEN_DOCUMENT cat=[android.intent.category.OPENABLE] typ=*/* (has extras) }
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1423)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Activity.internalStartActivityForResult(Activity.java:3427)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Activity.access$200(Activity.java:660)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Activity$2.onStartActivity(Activity.java:3417)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Activity.startActivityForBusiness(Activity.java:5441)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Activity.startActivityForResult(Activity.java:3413)
03-12 09:22:40.026: E/AndroidRuntime(10739): at android.app.Activity.startActivityForResult(Activity.java:3367)
That should work in both device and what should I do.Help me, Please.!!
The Intent Intent.ACTION_OPEN_DOCUMENT is only supported on devices with Android 4.4 (KitKat) and above.
Have a look at the Storage Access Framework docs, and specifically the one on ACTION_OPEN_DOCUMENT.
In Android 4.3 or lower, use ACTION_PICK or ACTION_GET_CONTENT as substitude.
In addition, when you invoke build-in "ACTION", you must verify there is more than one activity to receive it, if not your app may crash. Use the following code snippet to do this:
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
boolean isIntentSafe = activities.size() > 0;
if (isIntentSafe) {
startActivity(intent);
}
I've got this provider defined in Manifest.
<provider
android:name="com.jon.aqclient.sync.StubProvider"
android:authorities="com.jon.aqclient.provider"
android:exported="false"
android:syncable="true" />
The app package is com.jon.aqclient, and the class is inside sync package, so the class is in com.jon.aqclient.sync.StubProvider. I had the application running perfectly, but after trying Proguard for the first time and mavenizing the project it crashes with a classnotfoundexception.
I've de-mavenized the project, I tried with -keep public class com.jon.aqclient.sync, and now commenting the Proguard line in the project.properties file as follows.
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
# proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
I've cleaned the project and nothing. And a strange thing is that if I change the provider definition in Manifest to StubProviderNew, without any other change, the error is the same, classnotfoundexception com.jon.aqclient.sync.StubProvider, and not StubProviderNew.
Where is the project reading that class name? How can I clear totally these?
Please help!
EDIT:
Stack trace:
03-12 15:04:56.259: E/AndroidRuntime(7506): FATAL EXCEPTION: main
03-12 15:04:56.259: E/AndroidRuntime(7506): java.lang.RuntimeException: Unable to get provider com.jon.aqclient.sync.StubProvider: java.lang.ClassNotFoundException: com.jon.aqclient.sync.StubProvider in loader dalvik.system.PathClassLoader[/system/framework/android.test.runner.jar:/data/app/com.jon.aqclient-2.apk]
03-12 15:04:56.259: E/AndroidRuntime(7506): at android.app.ActivityThread.installProvider(ActivityThread.java:3709)
03-12 15:04:56.259: E/AndroidRuntime(7506): at android.app.ActivityThread.installContentProviders(ActivityThread.java:3461)
03-12 15:04:56.259: E/AndroidRuntime(7506): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3417)
03-12 15:04:56.259: E/AndroidRuntime(7506): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
03-12 15:04:56.259: E/AndroidRuntime(7506): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:977)
03-12 15:04:56.259: E/AndroidRuntime(7506): at android.os.Handler.dispatchMessage(Handler.java:99)
03-12 15:04:56.259: E/AndroidRuntime(7506): at android.os.Looper.loop(Looper.java:130)
03-12 15:04:56.259: E/AndroidRuntime(7506): at android.app.ActivityThread.main(ActivityThread.java:3835)
03-12 15:04:56.259: E/AndroidRuntime(7506): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 15:04:56.259: E/AndroidRuntime(7506): at java.lang.reflect.Method.invoke(Method.java:507)
03-12 15:04:56.259: E/AndroidRuntime(7506): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
03-12 15:04:56.259: E/AndroidRuntime(7506): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
03-12 15:04:56.259: E/AndroidRuntime(7506): at dalvik.system.NativeStart.main(Native Method)
03-12 15:04:56.259: E/AndroidRuntime(7506): Caused by: java.lang.ClassNotFoundException: com.jon.aqclient.sync.StubProvider in loader dalvik.system.PathClassLoader[/system/framework/android.test.runner.jar:/data/app/com.jon.aqclient-2.apk]
03-12 15:04:56.259: E/AndroidRuntime(7506): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
03-12 15:04:56.259: E/AndroidRuntime(7506): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
03-12 15:04:56.259: E/AndroidRuntime(7506): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
03-12 15:04:56.259: E/AndroidRuntime(7506): at android.app.ActivityThread.installProvider(ActivityThread.java:3694)
03-12 15:04:56.259: E/AndroidRuntime(7506): ... 12 more
Pff, I've solved it. It was a Maven thing. I didn't know if was Maven or Proguard, but it where the main changes I did before the error appeared.
Maven changed the default output folder to target/... and not bo bin/classes... so the device couldn't find the classes.
To solve it I had to go to Project->Properties->Source and at the bottom put as Default output folder {project}/bin/classes.
This is my first time here in this site. I already did searched the web on how to populate sqlite database into expandable listview but i failed.
I follow
these steps on how to create an expandable listview and modify some codes to make it dynamic.
Here is my modified code. This is only to set parent text on expandable listview:
public void setGroupParents() {
String selectQuery = "select * from " + DbHelper.TABLE_NAME + " ORDER BY "+DbHelperTablon.KEY_FNAME+" ASC ";
SQLiteDatabase db = mHelper.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
parentItems.add(cursor.getString(1));
} while (cursor.moveToNext());
}
cursor.close();
db.close();
return;
}
When i tried to run the emulator, the program crashed.
I am a newbie in android development and i need any help from you experts.. Thanks in advance.
Oh.. im sorry. This is the results of my LogCat... This is only the error portion..
03-12 07:25:10.059: ERROR/AndroidRuntime(367): FATAL EXCEPTION: main
03-12 07:25:10.059: ERROR/AndroidRuntime(367): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Sample/com.Sample.MainListview}: java.lang.NullPointerException
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.os.Handler.dispatchMessage(Handler.java:99)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.os.Looper.loop(Looper.java:123)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.app.ActivityThread.main(ActivityThread.java:3647)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at java.lang.reflect.Method.invoke(Method.java:507)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at dalvik.system.NativeStart.main(Native Method)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): Caused by: java.lang.NullPointerException
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at com.Sample.MainListview.setGroupParents(MainListview.java:56)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at com.Sample.MainListview.onCreate(MainListview.java:39)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
03-12 07:25:10.059: ERROR/AndroidRuntime(367): ... 11 more
03-12 07:25:12.428: ERROR/InputDispatcher(59): channel '40703be0 com.Sample/com.Sample.Drawer (server)' ~ Consumer closed input channel or an error occurred. events=0x8
03-12 07:25:12.428: ERROR/InputDispatcher(59): channel '40703be0 com.Sample/com.Sample.Drawer (server)' ~ Channel is unrecoverably broken and will be disposed!
well i guess if you initiate the database object outside your class your problem might be solved...
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I've created an application in eclipse and it was working fine and then suddenly it keeps giving me the error message 'unfortunately app has stopped' could anyone explain where my problem lies from my log cat report as i am new to this and dont really understand what the log cat means?
03-12 12:31:03.465: D/AndroidRuntime(4997): Shutting down VM
03-12 12:31:03.465: W/dalvikvm(4997): threadid=1: thread exiting with uncaught exception (group=0x416a8930)
03-12 12:31:03.465: E/AndroidRuntime(4997): FATAL EXCEPTION: main
03-12 12:31:03.465: E/AndroidRuntime(4997): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.softwaresearchapp/com.example.softwaresearchapp.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.softwaresearchapp/com.example.softwaresearchapp.SoftwareSearchActivity}; have you declared this activity in your AndroidManifest.xml?
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.os.Handler.dispatchMessage(Handler.java:99)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.os.Looper.loop(Looper.java:137)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.main(ActivityThread.java:5039)
03-12 12:31:03.465: E/AndroidRuntime(4997): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 12:31:03.465: E/AndroidRuntime(4997): at java.lang.reflect.Method.invoke(Method.java:511)
03-12 12:31:03.465: E/AndroidRuntime(4997): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-12 12:31:03.465: E/AndroidRuntime(4997): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-12 12:31:03.465: E/AndroidRuntime(4997): at dalvik.system.NativeStart.main(Native Method)
03-12 12:31:03.465: E/AndroidRuntime(4997): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.softwaresearchapp/com.example.softwaresearchapp.SoftwareSearchActivity}; have you declared this activity in your AndroidManifest.xml?
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.resolveActivityInfo(ActivityThread.java:1993)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:285)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:749)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.widget.TabHost.setCurrentTab(TabHost.java:413)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.widget.TabHost.addTab(TabHost.java:240)
03-12 12:31:03.465: E/AndroidRuntime(4997): at com.example.softwaresearchapp.MainActivity.onCreate(MainActivity.java:27)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.Activity.performCreate(Activity.java:5104)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-12 12:31:03.465: E/AndroidRuntime(4997): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-12 12:31:03.465: E/AndroidRuntime(4997): ... 11 more
03-12 12:31:22.666: I/Process(4997): Sending signal. PID: 4997 SIG: 9`
your logcat clearly said
Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.softwaresearchapp/com.example.softwaresearchapp.SoftwareSearchActivity}; have you declared this activity in your AndroidManifest.xml?
Add SoftwareSearchActivity into manifest.xml like
<activity
android:name="com.example.softwaresearchapp.SoftwareSearchActivity"
android:configChanges="keyboardHidden|orientation"
android:label="SoftwareSearch"
/>
Look at this line:
3-12 12:31:03.465: E/AndroidRuntime(4997): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.softwaresearchapp/com.example.softwaresearchapp.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.softwaresearchapp/com.example.softwaresearchapp.SoftwareSearchActivity}; have you declared this activity in your AndroidManifest.xml?
Specifically: Unable to find explicit activity class {com.example.softwaresearchapp/com.example.softwaresearchapp.SoftwareSearchActivity}; have you declared this activity in your AndroidManifest.xml?
Well, have you?
Each activity in your app must be declared in the manifest file. I imagine the minimum information you would want to provide would be the name and label e.g.
<activity
android:name=".SoftwareSearchActivity"
android:label="#string/title_activity_software_search"
/>
You are getting ActivityNotFoundException. Please check for Activity entry for com.example.softwaresearchapp.SoftwareSearchActivity in manifest file.
I have made an app that uses Google Android Maps API V2 and I have followed every step in the guide provided by Google but it doesn't work unfortunely and it crashes every time I try to start it up. So I'm wondering what is the problem?
MainActivity.java
package com.android.maptest;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
Maptest Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.maptest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="16" />
<permission
android:name="com.android.maptest.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.android.maptest.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:debuggable="true" >
<activity
android:name="com.android.maptest.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="api_key" />
</application>
</manifest>
Logcat
03-12 09:46:13.150: D/AndroidRuntime(1547): Shutting down VM
03-12 09:46:13.150: W/dalvikvm(1547): threadid=1: thread exiting with uncaught exception (group=0x410e22a0)
03-12 09:46:13.155: E/AndroidRuntime(1547): FATAL EXCEPTION: main
03-12 09:46:13.155: E/AndroidRuntime(1547): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.maptest/com.android.maptest.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
03-12 09:46:13.155: E/AndroidRuntime(1547): at
android.app.ActivityThread.access$600(ActivityThread.java:140)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.os.Handler.dispatchMessage(Handler.java:99)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.os.Looper.loop(Looper.java:137)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.main(ActivityThread.java:4898)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.reflect.Method.invoke(Method.java:511)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
03-12 09:46:13.155: E/AndroidRuntime(1547): at dalvik.system.NativeStart.main(Native Method)
03-12 09:46:13.155: E/AndroidRuntime(1547): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Activity.setContentView(Activity.java:1924)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.maptest.MainActivity.onCreate(MainActivity.java:11)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Activity.performCreate(Activity.java:5206)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
03-12 09:46:13.155: E/AndroidRuntime(1547): ... 11 more
03-12 09:46:13.155: E/AndroidRuntime(1547): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Fragment.instantiate(Fragment.java:584)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Fragment.instantiate(Fragment.java:552)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Activity.onCreateView(Activity.java:4849)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
03-12 09:46:13.155: E/AndroidRuntime(1547): ... 20 more
03-12 09:46:13.155: E/AndroidRuntime(1547): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment
03-12 09:46:13.155: E/AndroidRuntime(1547): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Fragment.instantiate(Fragment.java:574)
03-12 09:46:13.155: E/AndroidRuntime(1547): ... 23 more
03-12 09:51:21.560: I/Process(1547): Sending signal. PID: 1547 SIG: 9
Here a blog post I wrote on how to integrate Google Maps into you application:
Creating Google Map Application
From your error it look like you did not perform correctly steps 2-3 of the blog guide,
for adding Google Play services library into your application.
If you follow carefully the steps written in the guide you will end up with the end result you can see at the end of the post.
I assumed that you have already get Google Maps Android API v2 key and have Google Play services. If you not have already installed it then please follow below steps to solve this problem_
Step 1. you can found it in Android SDK Manager under Extras tick check box of -Google Play services install it and after complete installation, restart your Eclipse.
Step 2. Add library named_ google-play-services_lib found under the extras folder of your Android SDK setup folder to your Android project_
Path of google service lib_
{Your_Android_SDK_direct}\extras\google\google_play_services\libproject\google-play-services_lib
Ex. Location of this lib on My system_
C:\Program Files\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib
I hope this will solve your ploblem.
For me adding:
import com.google.android.gms.maps.SupportMapFragment;
And changing the xml to
<fragment
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/header" />
resolved the problem. I hope you resolve it too!
Looks like you didn't add the Google Play Services library to your project.
It's located at {Android SDK}\extras\google\google_play_services
Add it as Android Library Project to Eclipse and then add it to your project.