I got a kml file stored in my sdcard.I want to open it through the google map in my app, so i used the below code but i am getting error saying "android illegalstateexception could not execute method of the activity"
I dont want to draw map and all just i want to open a kml file which is already stored in my sdcard and show it.
When i google it i got lot of items related to drawing map based on the datas,this i dont want.
My code :
public void showmap(View v){
File file = new File(Environment.getExternalStorageDirectory(), "10.kml");
Intent map_intent = new Intent(Intent.ACTION_VIEW);
map_intent.setClassName("com.google.earth", "com.google.earth.EarthActivity");
map_intent.setDataAndType(Uri.fromFile(file), "application/vnd.google-earth.kml+xml");
startActivity(map_intent);
}
My Android Manifest File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lyold"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.lyold.LoginActivity"
android:screenOrientation="landscape"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:screenOrientation="landscape"
android:name=".Home" />
<activity android:name="com.google.earth.EarthActivity" android:screenOrientation="landscape"/>
</application>
</manifest>
My logcat error :
04-04 18:01:05.387: E/AndroidRuntime(5846): FATAL EXCEPTION: main
04-04 18:01:05.387: E/AndroidRuntime(5846): java.lang.IllegalStateException: Could not execute method of the activity
04-04 18:01:05.387: E/AndroidRuntime(5846): at android.view.View$1.onClick(View.java:3044)
04-04 18:01:05.387: E/AndroidRuntime(5846): at android.view.View.performClick(View.java:3511)
04-04 18:01:05.387: E/AndroidRuntime(5846): at android.view.View$PerformClick.run(View.java:14105)
04-04 18:01:05.387: E/AndroidRuntime(5846): at android.os.Handler.handleCallback(Handler.java:605)
04-04 18:01:05.387: E/AndroidRuntime(5846): at android.os.Handler.dispatchMessage(Handler.java:92)
04-04 18:01:05.387: E/AndroidRuntime(5846): at android.os.Looper.loop(Looper.java:137)
04-04 18:01:05.387: E/AndroidRuntime(5846): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-04 18:01:05.387: E/AndroidRuntime(5846): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 18:01:05.387: E/AndroidRuntime(5846): at java.lang.reflect.Method.invoke(Method.java:511)
04-04 18:01:05.387: E/AndroidRuntime(5846): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-04 18:01:05.387: E/AndroidRuntime(5846): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-04 18:01:05.387: E/AndroidRuntime(5846): at dalvik.system.NativeStart.main(Native Method)
04-04 18:01:05.387: E/AndroidRuntime(5846): Caused by: java.lang.reflect.InvocationTargetException
04-04 18:01:05.387: E/AndroidRuntime(5846): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 18:01:05.387: E/AndroidRuntime(5846): at java.lang.reflect.Method.invoke(Method.java:511)
04-04 18:01:05.387: E/AndroidRuntime(5846): at android.view.View$1.onClick(View.java:3039)
04-04 18:01:05.387: E/AndroidRuntime(5846): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/10.kml typ=application/vnd.google-earth.kml+xml }
04-04 18:01:05.387: E/AndroidRuntime(5846): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
04-04 18:01:05.387: E/AndroidRuntime(5846): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
04-04 18:01:05.387: E/AndroidRuntime(5846): at android.app.Activity.startActivityForResult(Activity.java:3190)
04-04 18:01:05.387: E/AndroidRuntime(5846): at android.app.Activity.startActivity(Activity.java:3297)
04-04 18:01:05.387: E/AndroidRuntime(5846): at com.example.ashadegreen.Basement.showmap(Basement.java:106)
I am new to android.Please help me..Your help is greatly appreciated.
Check the AndroidManifest.xml FILE related permission and make sure that File Path that you are trying to open (10.kml). Other than this everything is fine in your code.
Related
First of all sorry for my bad English, I am improving it.
I am trying to test the INSTALL_REFERER boradcast but I can't make it work.
My package:
es.beedroid.beebubble
The receiver in my manifest is:
<receiver
android:name="es.beedroid.beebubble.Load$InstallReferrerReceiver"
android:exported="true" >
<intent-filter >
<action android:name="com.android.vending.INSTALL_REFERRER" >
</action>
</intent-filter>
</receiver>
To test that receiver I make this:
static void displayMessage(Context context, String message) {
Intent i = new Intent("com.android.vending.INSTALL_REFERRER");
// i.setPackage("es.beedroid.beebubble");
i.putExtra("referrer", "&huevos=hola");
context.sendBroadcast(i);
}
But when I launch the app I get the following error:
04-04 12:46:05.432: E/AndroidRuntime(20996): FATAL EXCEPTION: main
04-04 12:46:05.432: E/AndroidRuntime(20996): java.lang.RuntimeException: Unable to instantiate receiver es.beedroid.beebubble.Load$InstallReferrerReceiver: java.lang.InstantiationException: es.beedroid.beebubble.Load$InstallReferrerReceiver
04-04 12:46:05.432: E/AndroidRuntime(20996): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1874)
04-04 12:46:05.432: E/AndroidRuntime(20996): at android.app.ActivityThread.access$2400(ActivityThread.java:156)
04-04 12:46:05.432: E/AndroidRuntime(20996): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1050)
04-04 12:46:05.432: E/AndroidRuntime(20996): at android.os.Handler.dispatchMessage(Handler.java:130)
04-04 12:46:05.432: E/AndroidRuntime(20996): at android.os.Looper.loop(SourceFile:351)
04-04 12:46:05.432: E/AndroidRuntime(20996): at android.app.ActivityThread.main(ActivityThread.java:3821)
04-04 12:46:05.432: E/AndroidRuntime(20996): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 12:46:05.432: E/AndroidRuntime(20996): at java.lang.reflect.Method.invoke(Method.java:538)
04-04 12:46:05.432: E/AndroidRuntime(20996): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969)
04-04 12:46:05.432: E/AndroidRuntime(20996): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727)
04-04 12:46:05.432: E/AndroidRuntime(20996): at dalvik.system.NativeStart.main(Native Method)
04-04 12:46:05.432: E/AndroidRuntime(20996): Caused by: java.lang.InstantiationException: es.beedroid.beebubble.Load$InstallReferrerReceiver
04-04 12:46:05.432: E/AndroidRuntime(20996): at java.lang.Class.newInstanceImpl(Native Method)
04-04 12:46:05.432: E/AndroidRuntime(20996): at java.lang.Class.newInstance(Class.java:1440)
04-04 12:46:05.432: E/AndroidRuntime(20996): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1865)
04-04 12:46:05.432: E/AndroidRuntime(20996): ... 10 more
Why? Is there another way to test that function? I tried to test it with adb but it doesn't work (it never passes by the receiver) .
adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n es.beedroid.beebubble/.com.beedroid.activities.Load$InstallReferrerReceiver --es "referrer" "utm_source=test_source&utm_medium=test_medium&utm_term=test_term&utm_content=test_content&utm_campaign=test_name"
Try adding ./ to adb and use the below
./adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n es.beedroid.beebubble/es.beedroid.beebubble.Load$InstallReferrerReceiver --es "referrer" "utm_source=test_source&utm_medium=test_medium&utm_term=test_term&utm_content=test_content&utm_campaign=test_name"
Also there were white spaces which I have removed and your path said
.com.beedroid.activities.Load$InstallReferrerReceiver
which I feel should be
es.beedroid.beebubble.Load$InstallReferrerReceiver
Let me know if it does work, coz I debugged using the same way and it did.
Note - App should NOT be running when you hit this from terminal.
Happy coding:)
After attempting to run my code on my device(Nexus 4) and it crashing repeatedly,I searched the forums for answers,I have tried re factoring my code into a new Android Project, I have also removed the Android Private Dependencies from my project build-path and I have also Cleaned my code close to 15 times within the last 3 hours. I believe something maybe wrong with how I'm compiling my project main.Java and whatnot.I’m just trying to learn so if you can point me into the right direction that would be great.
MainActivity.Java
04-04 04:21:06.403: E/AndroidRuntime(2430): FATAL EXCEPTION: main
04-04 04:21:06.403: E/AndroidRuntime(2430): Process: com.foobar.app, PID: 2430
04-04 04:21:06.403: E/AndroidRuntime(2430): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.foobar.app/com.foobar.app.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.foobar.app.MainActivity" on path: DexPathList[[zip file "/data/app/com.foobar.app-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.foobar.app-2, /vendor/lib, /system/lib]]
04-04 04:21:06.403: E/AndroidRuntime(2430): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
04-04 04:21:06.403: E/AndroidRuntime(2430): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
04-04 04:21:06.403: E/AndroidRuntime(2430): at android.app.ActivityThread.access$800(ActivityThread.java:135)
04-04 04:21:06.403: E/AndroidRuntime(2430): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
04-04 04:21:06.403: E/AndroidRuntime(2430): at android.os.Handler.dispatchMessage(Handler.java:102)
04-04 04:21:06.403: E/AndroidRuntime(2430): at android.os.Looper.loop(Looper.java:136)
04-04 04:21:06.403: E/AndroidRuntime(2430): at android.app.ActivityThread.main(ActivityThread.java:5017)
04-04 04:21:06.403: E/AndroidRuntime(2430): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 04:21:06.403: E/AndroidRuntime(2430): at java.lang.reflect.Method.invoke(Method.java:515)
04-04 04:21:06.403: E/AndroidRuntime(2430): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-04 04:21:06.403: E/AndroidRuntime(2430): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-04 04:21:06.403: E/AndroidRuntime(2430): at dalvik.system.NativeStart.main(Native Method)
04-04 04:21:06.403: E/AndroidRuntime(2430): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.foobar.app.MainActivity" on path: DexPathList[[zip file "/data/app/com.foobar.app-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.foobar.app-2, /vendor/lib, /system/lib]]
04-04 04:21:06.403: E/AndroidRuntime(2430): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
04-04 04:21:06.403: E/AndroidRuntime(2430): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
04-04 04:21:06.403: E/AndroidRuntime(2430): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
04-04 04:21:06.403: E/AndroidRuntime(2430): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
04-04 04:21:06.403: E/AndroidRuntime(2430): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
04-04 04:21:06.403: E/AndroidRuntime(2430): ... 11 more
ActivityManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.foobar.app" >
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCblB2SWMJ6E0dfQSJ_W21gZ3FRNaobvIg" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="com.foobar.app.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>
<activity
android:name="com.foobar.app.MapActivity"
android:label="#string/title_activity_map" >
</activity>
<activity
android:name="com.foobar.app.GPSActivity"
android:label="#string/title_activity_gps" >
</activity>
</application>
</manifest>
Thanks for your help.
Try changing the activity name in manifest as
android:name=".MainActivity"
instead of
android:name="com.foobar.app.MainActivity"
and do a clean and rebuild your project.
If this doesn't workout try renaming the package name, it should also update the manifest.
I've been adding a map to an Android project of mine and when ever my class loads the XML file with the map fragment it crashes, I was following this tutorial
( https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key )
I'm using a Nexus 7 (Jellybean 4.1) so that shouldn't be a problem, here is my class:
package com.app.thetoolstore;
import android.app.Activity;
import android.os.Bundle;
public class Tool_map extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_activity);
}
}
And here is my XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#001" >
<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"/>
</LinearLayout>
and finally my Stack Trace:
04-04 10:01:35.551: E/AndroidRuntime(14362): FATAL EXCEPTION: main
04-04 10:01:35.551: E/AndroidRuntime(14362): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.thetoolstore/com.app.thetoolstore.Tool_map}: android.view.InflateException: Binary XML file line #29: Error inflating class fragment
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1872)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.os.Handler.dispatchMessage(Handler.java:99)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.os.Looper.loop(Looper.java:150)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.app.ActivityThread.main(ActivityThread.java:4385)
04-04 10:01:35.551: E/AndroidRuntime(14362): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 10:01:35.551: E/AndroidRuntime(14362): at java.lang.reflect.Method.invoke(Method.java:507)
04-04 10:01:35.551: E/AndroidRuntime(14362): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
04-04 10:01:35.551: E/AndroidRuntime(14362): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
04-04 10:01:35.551: E/AndroidRuntime(14362): at dalvik.system.NativeStart.main(Native Method)
04-04 10:01:35.551: E/AndroidRuntime(14362): Caused by: android.view.InflateException: Binary XML file line #29: Error inflating class fragment
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-04 10:01:35.551: E/AndroidRuntime(14362): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:250)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.app.Activity.setContentView(Activity.java:1742)
04-04 10:01:35.551: E/AndroidRuntime(14362): at com.app.thetoolstore.Tool_map.onCreate(Tool_map.java:11)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1836)
04-04 10:01:35.551: E/AndroidRuntime(14362): ... 11 more
04-04 10:01:35.551: E/AndroidRuntime(14362): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.app.thetoolstore-2.apk]
04-04 10:01:35.551: E/AndroidRuntime(14362): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
04-04 10:01:35.551: E/AndroidRuntime(14362): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
04-04 10:01:35.551: E/AndroidRuntime(14362): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.view.LayoutInflater.createView(LayoutInflater.java:471)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
04-04 10:01:35.551: E/AndroidRuntime(14362): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
04-04 10:01:35.551: E/AndroidRuntime(14362): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
04-04 10:01:35.551: E/AndroidRuntime(14362): ... 20 more
UPDATE
I solved the issue using this tutorial https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw speciffically I had issues with the libs and google-pay services.
Hmmm lots of issue
1) You need to use FragmentActivity instead of Activity
2) android:name="com.google.android.gms.maps.MapFragment" replace by android:name="com.google.android.gms.maps.SupportMapFragment"/>
3) You need to add your key in manifest file and use Google Android Map API v2
4) Refer this tutorial http://www.vogella.com/articles/AndroidGoogleMaps/article.html
am getting this exception:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{business.premium/business.premium.Problemio}:
java.lang.ClassNotFoundException: business.premium.Problemio
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
... 11 more
java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
it says that class is not there, but it IS there. I tried to configure things in my project's build path, but not too sure what to tweak there.
And here is how I start my Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="business.premium"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomTheme"
android:name="MyApplication"
android:debuggable="true">
<activity
android:name=".Problemio"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Any thoughts on how to solve this, or what to look into? Thanks!
Its because you specified the "android:name" attribute in the application node in the manifest file.
Do not use the android:name attribute!
It, misleadingly, does not have anything to do with the name of your app and is actually the name of an extra class to load before loading your application. That's why you are getting the ClassNotFoundException.
Remove it and it should work:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:description="#string/help_text" >
This answer is taken from: java.lang.ClassNotFoundException on working app
I am currently testing the roottools jar/library made by stericson in an app, but every time the app loads it force closes.
Here is the code:
package com.liamwli.root;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
import com.stericson.RootTools.*;
public class root_test extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (RootTools.isBusyboxAvailable()) {
setContentView(R.layout.main);
} else {
RootTools.offerBusyBox(this);
}
if (RootTools.isRootAvailable()) {
Toast liam = Toast.makeText(this, "Root Available",
Toast.LENGTH_SHORT);
liam.show();
} else {
// do something else
}
}
}
And here is the logcat:
04-04 21:44:47.009: I/Process(6622): Sending signal. PID: 6622 SIG: 9
04-04 21:45:40.859: I/dalvikvm(6722): Could not find method com.stericson.RootTools.RootTools.isBusyboxAvailable, referenced from method com.liamwli.root.root_test.onCreate
04-04 21:45:40.859: W/dalvikvm(6722): VFY: unable to resolve static method 16: Lcom/stericson/RootTools/RootTools;.isBusyboxAvailable ()Z
04-04 21:45:40.859: D/dalvikvm(6722): VFY: replacing opcode 0x71 at 0x0003
04-04 21:45:40.859: D/AndroidRuntime(6722): Shutting down VM
04-04 21:45:40.859: W/dalvikvm(6722): threadid=1: thread exiting with uncaught exception (group=0x40ac21f8)
04-04 21:45:40.869: E/AndroidRuntime(6722): FATAL EXCEPTION: main
04-04 21:45:40.869: E/AndroidRuntime(6722): java.lang.NoClassDefFoundError: com.stericson.RootTools.RootTools
04-04 21:45:40.869: E/AndroidRuntime(6722): at com.liamwli.root.root_test.onCreate(root_test.java:16)
04-04 21:45:40.869: E/AndroidRuntime(6722): at android.app.Activity.performCreate(Activity.java:4465)
04-04 21:45:40.869: E/AndroidRuntime(6722): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-04 21:45:40.869: E/AndroidRuntime(6722): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-04 21:45:40.869: E/AndroidRuntime(6722): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-04 21:45:40.869: E/AndroidRuntime(6722): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-04 21:45:40.869: E/AndroidRuntime(6722): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-04 21:45:40.869: E/AndroidRuntime(6722): at android.os.Handler.dispatchMessage(Handler.java:99)
04-04 21:45:40.869: E/AndroidRuntime(6722): at android.os.Looper.loop(Looper.java:137)
04-04 21:45:40.869: E/AndroidRuntime(6722): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-04 21:45:40.869: E/AndroidRuntime(6722): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 21:45:40.869: E/AndroidRuntime(6722): at java.lang.reflect.Method.invoke(Method.java:511)
04-04 21:45:40.869: E/AndroidRuntime(6722): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
04-04 21:45:40.869: E/AndroidRuntime(6722): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
04-04 21:45:40.869: E/AndroidRuntime(6722): at dalvik.system.NativeStart.main(Native Method)
I am quite new to android, and I am now very confused :(
If someone could possibly help me, I would be grateful!
In Eclipse, right click your project, navigate to "Build Path", then to "configure build path"
Now choose "add External Jar"
Navigate to the RootTools .jar file you download and choose it.
Navigate to "Order and Export" make sure the box is ticked next to the library, and move it to the top of the list.
Finish up by choosing "ok"
I resolved this by separating the imports. Instead of:
import com.stericson.RootTools.*;
I only used/needed:
import com.stericson.RootTools.RootTools;
Try adding the others individually if you need them.
import com.stericson.RootTools.Mount;
import com.stericson.RootTools.Permissions;
import com.stericson.RootTools.RootToolsException;
import com.stericson.RootTools.Symlink;
import com.stericson.RootTools.SanityCheckRootTools;
It worked for me, hope it does for you!