loading activities from external dex/jar files - android

I have a lib.apk that is sent by server and received by my application and then saved on sdcard.now I want run activities of inside my library but when I try do it, it gives me error do you define activity in manifest. I added activity tag to manifest of my lib but it still didn't work. Can anyone give any idea?
manifest file of my lib
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lib"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.lib.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>
logcat error
11-20 05:16:49.918: W/System.err(6721): java.lang.reflect.InvocationTargetException
11-20 05:16:49.938: W/System.err(6721): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 05:16:49.948: W/System.err(6721): at java.lang.reflect.Method.invoke(Method.java:511)
11-20 05:16:49.948: W/System.err(6721): at com.example.myapp2.MainActivity.onCreate(MainActivity.java:29)
11-20 05:16:49.948: W/System.err(6721): at android.app.Activity.performCreate(Activity.java:5104)
11-20 05:16:49.948: W/System.err(6721): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
11-20 05:16:49.948: W/System.err(6721): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
11-20 05:16:49.958: W/System.err(6721): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
11-20 05:16:49.958: W/System.err(6721): at android.app.ActivityThread.access$600(ActivityThread.java:141)
11-20 05:16:49.958: W/System.err(6721): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
11-20 05:16:49.958: W/System.err(6721): at android.os.Handler.dispatchMessage(Handler.java:99)
11-20 05:16:49.969: W/System.err(6721): at android.os.Looper.loop(Looper.java:137)
11-20 05:16:49.969: W/System.err(6721): at android.app.ActivityThread.main(ActivityThread.java:5041)
11-20 05:16:49.969: W/System.err(6721): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 05:16:49.969: W/System.err(6721): at java.lang.reflect.Method.invoke(Method.java:511)
11-20 05:16:49.969: W/System.err(6721): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
11-20 05:16:49.978: W/System.err(6721): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
11-20 05:16:49.978: W/System.err(6721): at dalvik.system.NativeStart.main(Native Method)
11-20 05:16:49.978: W/System.err(6721): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.myapp2/com.example.lib.MainActivity}; have you declared this activity in your AndroidManifest.xml?
11-20 05:16:49.988: W/System.err(6721): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
11-20 05:16:50.000: W/System.err(6721): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
11-20 05:16:50.008: W/System.err(6721): at android.app.Activity.startActivityForResult(Activity.java:3370)
11-20 05:16:50.008: W/System.err(6721): at android.app.Activity.startActivityForResult(Activity.java:3331)
11-20 05:16:50.008: W/System.err(6721): at android.app.Activity.startActivity(Activity.java:3566)
11-20 05:16:50.019: W/System.err(6721): at android.app.Activity.startActivity(Activity.java:3534)
11-20 05:16:50.028: W/System.err(6721): at com.example.lib.Main.onCreate(Main.java:32)

You cannot run activties that have not been installed on the phone. Just having an APK on the SD-card is not enough. This APK will need to be installed on the device.

Related

Ionic Framework start error on Android

I have a project with Ionic working fine in iOS (emulator and device), web and with a problem in Android.
I have used to create the project:
ionic platform add android
I open the project with Eclipse, everything is Ok, no errors, and CordovaLib is loading fine.
When I try to deploy in my device, I have this error:
11-20 15:22:56.350: E/AndroidRuntime(10312): FATAL EXCEPTION: main
11-20 15:22:56.350: E/AndroidRuntime(10312): Process: com.ionicframework.congressapp251163, PID: 10312
11-20 15:22:56.350: E/AndroidRuntime(10312): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ionicframework.congressapp251163/com.ionicframework.congressapp251163.CordovaApp}: java.lang.NullPointerException
11-20 15:22:56.350: E/AndroidRuntime(10312): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2447)
11-20 15:22:56.350: E/AndroidRuntime(10312): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2507)
11-20 15:22:56.350: E/AndroidRuntime(10312): at android.app.ActivityThread.access$900(ActivityThread.java:172)
11-20 15:22:56.350: E/AndroidRuntime(10312): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
11-20 15:22:56.350: E/AndroidRuntime(10312): at android.os.Handler.dispatchMessage(Handler.java:102)
11-20 15:22:56.350: E/AndroidRuntime(10312): at android.os.Looper.loop(Looper.java:146)
11-20 15:22:56.350: E/AndroidRuntime(10312): at android.app.ActivityThread.main(ActivityThread.java:5692)
11-20 15:22:56.350: E/AndroidRuntime(10312): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 15:22:56.350: E/AndroidRuntime(10312): at java.lang.reflect.Method.invoke(Method.java:515)
11-20 15:22:56.350: E/AndroidRuntime(10312): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
11-20 15:22:56.350: E/AndroidRuntime(10312): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
11-20 15:22:56.350: E/AndroidRuntime(10312): at dalvik.system.NativeStart.main(Native Method)
11-20 15:22:56.350: E/AndroidRuntime(10312): Caused by: java.lang.NullPointerException
11-20 15:22:56.350: E/AndroidRuntime(10312): at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:191)
11-20 15:22:56.350: E/AndroidRuntime(10312): at org.apache.cordova.PluginManager.startupPlugins(PluginManager.java:114)
11-20 15:22:56.350: E/AndroidRuntime(10312): at org.apache.cordova.PluginManager.init(PluginManager.java:92)
11-20 15:22:56.350: E/AndroidRuntime(10312): at org.apache.cordova.CordovaWebView.loadUrlIntoView(CordovaWebView.java:383)
11-20 15:22:56.350: E/AndroidRuntime(10312): at org.apache.cordova.CordovaWebView.loadUrlIntoView(CordovaWebView.java:368)
11-20 15:22:56.350: E/AndroidRuntime(10312): at org.apache.cordova.CordovaWebView.loadUrl(CordovaWebView.java:344)
11-20 15:22:56.350: E/AndroidRuntime(10312): at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:389)
11-20 15:22:56.350: E/AndroidRuntime(10312): at com.ionicframework.congressapp251163.CordovaApp.onCreate(CordovaApp.java:33)
11-20 15:22:56.350: E/AndroidRuntime(10312): at android.app.Activity.performCreate(Activity.java:5541)
11-20 15:22:56.350: E/AndroidRuntime(10312): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
11-20 15:22:56.350: E/AndroidRuntime(10312): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2411)
11-20 15:22:56.350: E/AndroidRuntime(10312): ... 11 more
EDIT:
The plugins have not been copying to the Android Project :(
Help please ;) Thanks!!
I had the same problem,but solved using this way.After creating the project first I build the project using the command ionic build android, then import it.if its not working try this
1.Remove the platform using ionic platform remove android
2.Add the platform again,and run.

When i use Google Map Api v2 for map then i can't add google play service library

I want to show current location in map using Google Map v2. I create sha key and generate API key and also integrate with androidmanifest.xml. I download example of following link:
http://wptrafficanalyzer.in/blog/showing-current-location-in-google-maps-using-api-v2-with-supportmapfragment/
I also give internet permission and other but in my log-cat following error display.
11-20 11:09:59.190: E/dalvikvm(719): Could not find class 'com.google.android.gms.maps.model.LatLng', referenced from method in.wptrafficanalyzer.locationingooglemapv2.MainActivity.onLocationChanged
11-20 11:09:59.190: W/dalvikvm(719): VFY: unable to resolve new-instance 460 (Lcom/google/android/gms/maps/model/LatLng;) in Lin/wptrafficanalyzer/locationingooglemapv2/MainActivity;
11-20 11:09:59.190: D/dalvikvm(719): VFY: replacing opcode 0x22 at 0x0010
11-20 11:09:59.220: D/dalvikvm(719): DexOpt: unable to opt direct call 0x0cdc at 0x12 in Lin/wptrafficanalyzer/locationingooglemapv2/MainActivity;.onLocationChanged
11-20 11:09:59.482: D/AndroidRuntime(719): Shutting down VM
11-20 11:09:59.482: W/dalvikvm(719): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
11-20 11:09:59.501: E/AndroidRuntime(719): FATAL EXCEPTION: main
11-20 11:09:59.501: E/AndroidRuntime(719): java.lang.RuntimeException: Unable to start activity ComponentInfo{in.wptrafficanalyzer.locationingooglemapv2/in.wptrafficanalyzer.locationingooglemapv2.MainActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class fragment
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.ActivityThread.access$600(ActivityThread.java:130)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.os.Handler.dispatchMessage(Handler.java:99)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.os.Looper.loop(Looper.java:137)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.ActivityThread.main(ActivityThread.java:4745)
11-20 11:09:59.501: E/AndroidRuntime(719): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 11:09:59.501: E/AndroidRuntime(719): at java.lang.reflect.Method.invoke(Method.java:511)
11-20 11:09:59.501: E/AndroidRuntime(719): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-20 11:09:59.501: E/AndroidRuntime(719): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-20 11:09:59.501: E/AndroidRuntime(719): at dalvik.system.NativeStart.main(Native Method)
11-20 11:09:59.501: E/AndroidRuntime(719): Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class fragment
11-20 11:09:59.501: E/AndroidRuntime(719): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-20 11:09:59.501: E/AndroidRuntime(719): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.Activity.setContentView(Activity.java:1867)
11-20 11:09:59.501: E/AndroidRuntime(719): at in.wptrafficanalyzer.locationingooglemapv2.MainActivity.onCreate(MainActivity.java:27)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.Activity.performCreate(Activity.java:5008)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
11-20 11:09:59.501: E/AndroidRuntime(719): ... 11 more
11-20 11:09:59.501: E/AndroidRuntime(719): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
11-20 11:09:59.501: E/AndroidRuntime(719): at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
11-20 11:09:59.501: E/AndroidRuntime(719): ... 21 more
11-20 11:09:59.501: E/AndroidRuntime(719): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.SupportMapFragment
11-20 11:09:59.501: E/AndroidRuntime(719): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
11-20 11:09:59.501: E/AndroidRuntime(719): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
11-20 11:09:59.501: E/AndroidRuntime(719): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
11-20 11:09:59.501: E/AndroidRuntime(719): at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
11-20 11:09:59.501: E/AndroidRuntime(719): ... 24 more
Now what i can do for displaying map?
Maps Activity
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main
<RelativeLayout 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"
tools:context=".MainActivity" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>
Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="YourPackageName"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="YourPackageName.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="YourPackageName.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" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="YourPackageName.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.gms.version"
android:value="4030500" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="YourKey" />
</application>`enter code here`
</manifest>
Open sdk manager and download google play service under extras, you will get two libraries google-play-services_lib.jar and google-play-services.jar. You can find these libraries under google play service in extras. You have to copy these two libraries and paste under lib folder in your app and also add these libraries under java Build path.
make sure by going to google api console go to services in go down you will find google map v2 eanble it...
To add a reference to a library project, follow these steps:
1. Make sure that both the project library and the application project that depends on it are in your workspace. If one of the projects is missing, import it into your workspace.
2. In the Package Explorer, right-click the dependent project and select Properties.
3.In the Properties window, select the "Android" properties group at left and locate the Library properties at right.
4.Click Add to open the Project Selection dialog.
5.From the list of available library projects, select a project and click OK.
6.When the dialog closes, click Apply in the Properties window.
7.Click OK to close the Properties window.
how to add reference Google play Library
Android Library Projects

I am unable to start activity ComponentInfo [duplicate]

This question already has answers here:
After Google Play Service update to version 13 I got an error
(8 answers)
Closed 9 years ago.
my app crashes on line
setContentView(R.layout.activity_map);
I'm using google maps api v2, i used to run this app on former eclipse and android sdk and it worked, after reinstallation of android sdk, got this exception
11-20 16:26:28.494: E/AndroidRuntime(19705): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.poputkaonline/com.example.poputkaonline.MapActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2355)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.app.ActivityThread.access$600(ActivityThread.java:151)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1335)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.os.Handler.dispatchMessage(Handler.java:99)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.os.Looper.loop(Looper.java:155)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.app.ActivityThread.main(ActivityThread.java:5520)
11-20 16:26:28.494: E/AndroidRuntime(19705): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 16:26:28.494: E/AndroidRuntime(19705): at java.lang.reflect.Method.invoke(Method.java:511)
11-20 16:26:28.494: E/AndroidRuntime(19705): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
11-20 16:26:28.494: E/AndroidRuntime(19705): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
11-20 16:26:28.494: E/AndroidRuntime(19705): at dalvik.system.NativeStart.main(Native Method)
11-20 16:26:28.494: E/AndroidRuntime(19705): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-20 16:26:28.494: E/AndroidRuntime(19705): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:324)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.app.Activity.setContentView(Activity.java:1912)
11-20 16:26:28.494: E/AndroidRuntime(19705): at com.example.poputkaonline.MapActivity.onCreate(MapActivity.java:263)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.app.Activity.performCreate(Activity.java:5066)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2311)
11-20 16:26:28.494: E/AndroidRuntime(19705): ... 11 more
11-20 16:26:28.494: E/AndroidRuntime(19705): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
11-20 16:26:28.494: E/AndroidRuntime(19705): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
11-20 16:26:28.494: E/AndroidRuntime(19705): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
11-20 16:26:28.494: E/AndroidRuntime(19705): at com.google.android.gms.maps.internal.q.v(Unknown Source)
11-20 16:26:28.494: E/AndroidRuntime(19705): at com.google.android.gms.maps.internal.q.u(Unknown Source)
11-20 16:26:28.494: E/AndroidRuntime(19705): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
11-20 16:26:28.494: E/AndroidRuntime(19705): at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)
11-20 16:26:28.494: E/AndroidRuntime(19705): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
11-20 16:26:28.494: E/AndroidRuntime(19705): at com.google.android.gms.dynamic.a.a(Unknown Source)
11-20 16:26:28.494: E/AndroidRuntime(19705): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
11-20 16:26:28.494: E/AndroidRuntime(19705): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:269)
11-20 16:26:28.494: E/AndroidRuntime(19705): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
try to add Google play service as reference to your project...
and even add in androidmanifest.xml
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
The explanation lies within your stacktrace:
Caused by: java.lang.IllegalStateException: The meta-data tag in your
app's AndroidManifest.xml does not have the right value. Expected
4030500 but found 0. You must have the following declaration within
the <application> element: <meta-data android:name="com.google.android.gms.version"android:value="#integer/google_play_services_version" />

RSS Application Stops

I followed this RSS Reader Tutorial.
So at first I got an error in this line:
Uri uri = Uri.parse(links.get(position));
I got the error, that i have to cast it to a String like this:
Uri uri = Uri.parse((String) links.get(position));
after that it was possible to run the App.
But if I want to open a ListView Element the app is stopped every time....
Does anyone an idea of what's wrong?
and here the logcat:
11-20 19:25:19.027: E/AndroidRuntime(505): FATAL EXCEPTION: main
11-20 19:25:19.027: E/AndroidRuntime(505): java.lang.IndexOutOfBoundsException: Invalid index 2, size is 0
11-20 19:25:19.027: E/AndroidRuntime(505): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
11-20 19:25:19.027: E/AndroidRuntime(505): at java.util.ArrayList.get(ArrayList.java:311)
11-20 19:25:19.027: E/AndroidRuntime(505): at com.rss_reader.MainActivity.onListItemClick(MainActivity.java:111)
11-20 19:25:19.027: E/AndroidRuntime(505): at android.app.ListActivity$2.onItemClick(ListActivity.java:319)
11-20 19:25:19.027: E/AndroidRuntime(505): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
11-20 19:25:19.027: E/AndroidRuntime(505): at android.widget.ListView.performItemClick(ListView.java:3513)
11-20 19:25:19.027: E/AndroidRuntime(505): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812)
11-20 19:25:19.027: E/AndroidRuntime(505): at android.os.Handler.handleCallback(Handler.java:587)
11-20 19:25:19.027: E/AndroidRuntime(505): at android.os.Handler.dispatchMessage(Handler.java:92)
11-20 19:25:19.027: E/AndroidRuntime(505): at android.os.Looper.loop(Looper.java:123)
11-20 19:25:19.027: E/AndroidRuntime(505): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-20 19:25:19.027: E/AndroidRuntime(505): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 19:25:19.027: E/AndroidRuntime(505): at java.lang.reflect.Method.invoke(Method.java:507)
11-20 19:25:19.027: E/AndroidRuntime(505): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-20 19:25:19.027: E/AndroidRuntime(505): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-20 19:25:19.027: E/AndroidRuntime(505): at dalvik.system.NativeStart.main(Native Method)
after i read the description i think the Uri is maybe null because:
Throws
NullPointerException if uriString is null
but why its null? i have no idea...
edit: the link to the tutorial is the wrong... but now i found the right one.
The important information in your LogCat is:
java.lang.IndexOutOfBoundsException: Invalid index 2, size is 0
which means your links list is empty, and then:
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
at java.util.ArrayList.get(ArrayList.java:311)
at com.rss_reader.MainActivity.onListItemClick(MainActivity.java:111)
You can see that you try to read a value from links (that doesn't exist) in your onListItemClick() method on line 111, which as you said above is:
Uri uri = Uri.parse((String) links.get(position));
You must to add data to your links list with links.add() at some point...
Your culprit is here:
com.rss_reader.MainActivity.onListItemClick(MainActivity.java:111)
in line 111, of MainActivity.java
EDIT
then it means you reaching outside your data, or more precisely
java.lang.IndexOutOfBoundsException: Invalid index 2, size is 0
your links is empty while you try to get 3rd element of out it, hence IndexOutOfBounds exception. Check why links is not initialized correctly or do some other checks to ensure your position is set right for the environment.

Android : Runtime error when using Unboundid LDAP SDK

I downloaded UnboundID LDAP SDK and imported it to my Eclipse Android project. It make use of existing LDAPClient supplied with the SDK.
Build was successful. However, when I attempt to launch the application, it gives below run-time error and application would not launch.
I am new to Android and Eclipse. Hence, any help or tips shall be appreciated.
If there are any details required, please let me know. I can add it.
11-20 19:36:38.395: I/dalvikvm(636): Could not find method com.unboundid.ldap.sdk.Filter.create, referenced from method people.finder.PeopleFinder.goSearch
11-20 19:36:38.395: W/dalvikvm(636): VFY: unable to resolve static method 3247: Lcom/unboundid/ldap/sdk/Filter;.create (Ljava/lang/String;)Lcom/unboundid/ldap/sdk/Filter;
11-20 19:36:38.395: D/dalvikvm(636): VFY: replacing opcode 0x71 at 0x00d4
11-20 19:36:38.395: W/dalvikvm(636): VFY: unable to resolve exception class 451 (Lcom/unboundid/ldap/sdk/LDAPException;)
11-20 19:36:38.395: W/dalvikvm(636): VFY: unable to find exception handler at addr 0x113
11-20 19:36:38.405: W/dalvikvm(636): VFY: rejected people/finder/PeopleFinder;.goSearch (Landroid/view/View;)V
11-20 19:36:38.405: W/dalvikvm(636): VFY: rejecting opcode 0x0d at 0x0113
11-20 19:36:38.405: W/dalvikvm(636): VFY: rejected /people/finder/PeopleFinder;.goSearch (Landroid/view/View;)V
11-20 19:36:38.405: W/dalvikvm(636): Verifier rejected class people/finder/PeopleFinder;
11-20 19:36:38.405: W/dalvikvm(636): Class init failed in newInstance call (people/finder/PeopleFinder;)
11-20 19:36:38.405: D/AndroidRuntime(636): Shutting down VM
11-20 19:36:38.405: W/dalvikvm(636): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
11-20 19:36:38.415: E/AndroidRuntime(636): FATAL EXCEPTION: main
11-20 19:36:38.415: E/AndroidRuntime(636): java.lang.VerifyError: people/finder/PeopleFinder
11-20 19:36:38.415: E/AndroidRuntime(636): at java.lang.Class.newInstanceImpl(Native Method)
11-20 19:36:38.415: E/AndroidRuntime(636): at java.lang.Class.newInstance(Class.java:1319)
11-20 19:36:38.415: E/AndroidRuntime(636): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
11-20 19:36:38.415: E/AndroidRuntime(636): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
11-20 19:36:38.415: E/AndroidRuntime(636): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
11-20 19:36:38.415: E/AndroidRuntime(636): at android.app.ActivityThread.access$600(ActivityThread.java:130)
11-20 19:36:38.415: E/AndroidRuntime(636): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
11-20 19:36:38.415: E/AndroidRuntime(636): at android.os.Handler.dispatchMessage(Handler.java:99)
11-20 19:36:38.415: E/AndroidRuntime(636): at android.os.Looper.loop(Looper.java:137)
11-20 19:36:38.415: E/AndroidRuntime(636): at android.app.ActivityThread.main(ActivityThread.java:4745)
11-20 19:36:38.415: E/AndroidRuntime(636): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 19:36:38.415: E/AndroidRuntime(636): at java.lang.reflect.Method.invoke(Method.java:511)
11-20 19:36:38.415: E/AndroidRuntime(636): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-20 19:36:38.415: E/AndroidRuntime(636): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-20 19:36:38.415: E/AndroidRuntime(636): at dalvik.system.NativeStart.main(Native Method)
You need to make sure that the jar is exported when building .apk file.
In project properties, go to Java Build Path > Order and Export : fill the checkbox corresponding to the LDAP sdk

Categories

Resources