Is the error: "make: *** No rule to make target `SpecProj_scd.mk'. Stop." causing my app to crash? - eclipse

My 1st clean & build gives this error:
make: *** No rule to make target `SpecProj_scd.mk'. Stop.
Building a second time, the error is removed. Note that ndk-build, builds fine.
So I run the project on my actual device, a Tablet, and the app crashes.
LogCat:
01-29 16:48:48.081: E/Trace(3766): error opening trace file: No such file or directory (2)
01-29 16:48:48.081: D/jdwp(3766): sendBufferedRequest : len=0x39
01-29 16:48:48.110: D/dalvikvm(3766): open_cached_dex_file : /data/app/com.dece.specproj-2.apk /data/dalvik-cache/data#app#com.dece.specproj-2.apk#classes.dex
01-29 16:48:48.117: D/ActivityThread(3766): BIND_APPLICATION handled : 0 / AppBindData{appInfo=ApplicationInfo{42436e88 com.dece.specproj}}
01-29 16:48:48.128: W/dalvikvm(3766): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/dece/specproj/MainActivity;
01-29 16:48:48.128: W/dalvikvm(3766): Class init failed in newInstance call (Lcom/dece/specproj/MainActivity;)
01-29 16:48:48.128: D/AndroidRuntime(3766): Shutting down VM
01-29 16:48:48.128: W/dalvikvm(3766): threadid=1: thread exiting with uncaught exception (group=0x41e17908)
01-29 16:48:48.137: E/AndroidRuntime(3766): FATAL EXCEPTION: main
01-29 16:48:48.137: E/AndroidRuntime(3766): java.lang.ExceptionInInitializerError
01-29 16:48:48.137: E/AndroidRuntime(3766): at java.lang.Class.newInstanceImpl(Native Method)
01-29 16:48:48.137: E/AndroidRuntime(3766): at java.lang.Class.newInstance(Class.java:1319)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2099)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.app.ActivityThread.access$600(ActivityThread.java:149)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.os.Handler.dispatchMessage(Handler.java:99)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.os.Looper.loop(Looper.java:153)
01-29 16:48:48.137: E/AndroidRuntime(3766): at android.app.ActivityThread.main(ActivityThread.java:4987)
01-29 16:48:48.137: E/AndroidRuntime(3766): at java.lang.reflect.Method.invokeNative(Native Method)
01-29 16:48:48.137: E/AndroidRuntime(3766): at java.lang.reflect.Method.invoke(Method.java:511)
01-29 16:48:48.137: E/AndroidRuntime(3766): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
01-29 16:48:48.137: E/AndroidRuntime(3766): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
01-29 16:48:48.137: E/AndroidRuntime(3766): at dalvik.system.NativeStart.main(Native Method)
01-29 16:48:48.137: E/AndroidRuntime(3766): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load hellojni: findLibrary returned null
01-29 16:48:48.137: E/AndroidRuntime(3766): at java.lang.Runtime.loadLibrary(Runtime.java:365)
01-29 16:48:48.137: E/AndroidRuntime(3766): at java.lang.System.loadLibrary(System.java:535)
01-29 16:48:48.137: E/AndroidRuntime(3766): at com.dece.specproj.MainActivity.<clinit>(MainActivity.java:13)
01-29 16:48:48.137: E/AndroidRuntime(3766): ... 15 more
So I made sure and that all my directories were correctly added to the Environment Variables PATH, as well as the PATH in Eclipse, i.e. my MinGW bin, MinGW msys bin, cygwin bin, android-ndk, as well as android-sdk...and I think they are all added correctly, so the error still comes up.
I'm not sure what is causing these issues as I am new to Android NDK, so I will post what I think may play a part in this.
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := SpecProj
LOCAL_SRC_FILES := hellojni.c
include $(BUILD_SHARED_LIBRARY)
hellojni.c
#include <string.h>
#include <jni.h>
jstring Java_com_dece_MainActivity_stringFromJNI(JNIEnv* env,jobject thiz)
{
return (*env)->NewStringUTF(env, "Hello from JNI !");
}
MainActivity
package com.dece.specproj;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
public native String stringFromJNI();
static
{
System.loadLibrary("hellojni");
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
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"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.dece.specproj.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
</RelativeLayout>
AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dece.specproj"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

The core of the problem is this:
01-29 16:48:48.137: E/AndroidRuntime(3766): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load hellojni: findLibrary returned null
It is unable to find a library called libhellojni.so (which you try to load in your java file with System.loadLibrary("hellojni");. Your shared library name is set in Android.mk in this line: LOCAL_MODULE := SpecProj (resulting in a file named libSpecProj.so).
To make things work, change the line in the java file to System.loadLibrary("SpecProj");.
I don't see where the error quoted in the question title would be coming from, but it is at least not directly linked to the error you're seeing at runtime. It may indicate that something else is weirdly set up in your project build (but nothing of what you quoted in the code snippets indicate that, so it would be things outside of that).

Related

Android studio is not showing any errors but my logcat shows that there are errors

this is my logcat-
03-23 21:02:12.573 22442-22442/the.falacermusicE/AndroidRuntime:FATAL EXCEPTION: main
android.app.SuperNotCalledException: Activity {the.falacermusic/the.falacermusic.ui.activities.HomeActivity} did not call through to super.onStart()
at android.app.Activity.performStart(Activity.java:5196)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2087)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2139)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4963)
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:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
03-23 21:02:12.573 22442-22442/the.falacermusicE/AndroidRuntime:FATAL EXCEPTION: main android.app.SuperNotCalledException: Activity {the.falacermusic/the.falacermusic.ui.activities.HomeActivity} did not call through to super.onStart()
As the error states you are implementing the onStart method in your HomeActivity but you are not going throgh the super.onStart() method.

Conflict with activity tags on android manifest: Facebook and Prime31 plugins in Unity3d

I'm trying to get a project to work with both the Facebook Unity plugin and (several) Prime31 plugins. I'm trying to create my own activity that extends the Prime31 activity and also incorporates the workaround for Facebook given here: Conflict with activity tags on android manifest: Facebook and Google Play Games in Unity3d
So far, I've got a class that looks like this:
import android.content.Intent;
import android.os.Bundle;
import com.facebook.Session;
public class DQUnityPlayerActivity extends com.prime31.UnityPlayerProxyActivity
{
#Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
}
I've compiled it with javac, packed it up as a .jar file, and put it in /Assets/Plugins/Android. I modified our AndroidManifest.xml like so:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" android:installLocation="preferExternal" android:theme="#android:style/Theme.NoTitleBar" android:versionCode="1" android:versionName="1.0">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<application android:icon="#drawable/app_icon" android:label="#string/app_name" android:debuggable="true">
<activity android:name=".DQUnityPlayerActivity" android:screenOrientation="sensorLandscape" android:launchMode="singleTask" android:label="#string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
etc...
Now here's where I'm stuck: at this point, when I try to run it on my test device, the class isn't found. ADB shows me this:
E/AndroidRuntime(16863): FATAL EXCEPTION: main
E/AndroidRuntime(16863): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.dqsoft.ChampHearts/com.dqsoft.ChampHearts.DQUnityPlayerActivity}: java.lang.ClassNotFoundException: com.dqsoft.ChampHearts.DQUnityPlayerActivity in loader dalvik.system.PathClassLoader[/mnt/asec/com.dqsoft.ChampHearts-1/pkg.apk]
E/AndroidRuntime(16863): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
E/AndroidRuntime(16863): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime(16863): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime(16863): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime(16863): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(16863): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(16863): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(16863): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(16863): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(16863): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
E/AndroidRuntime(16863): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
E/AndroidRuntime(16863): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(16863): Caused by: java.lang.ClassNotFoundException: com.dqsoft.ChampHearts.DQUnityPlayerActivity in loader dalvik.system.PathClassLoader[/mnt/asec/com.dqsoft.ChampHearts-1/pkg.apk]
E/AndroidRuntime(16863): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
E/AndroidRuntime(16863): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
E/AndroidRuntime(16863): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
E/AndroidRuntime(16863): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime(16863): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
E/AndroidRuntime(16863): ... 11 more
Any idea what could be wrong?
You need to put your exported jar file inside Assets/Plugins/Android/ folder and make sure in your DQUnityPlayerActivity class you have this line:
package com.dqsoft.ChampHearts;

error with google maps v2 in tab (MapFragment in Fragment)

I have a fragmentActivity where I build a tabHost and in each tab there is a Fragment. Well, I haver four tabs 3 with info and 1 with a fragment where is included a google-map-v2 (is a fragmentMAp in a Fragment because I want to add buttons etc.), when I select one tab and pass to other everything go well, but when I select the map tab, after that other tab and again the map tab an error is throw.
My view seems like:
|__||__|__|__|
| __________ |
|| FRAGMENT ||
||_____ _ ||
|| FRAG| |_|||
|| MAP | ||
|| | ||
||_____| ||
||__________||
The error:
01-29 08:32:56.979: E/AndroidRuntime(27738): FATAL EXCEPTION: main
01-29 08:32:56.979: E/AndroidRuntime(27738): android.view.InflateException: Binary XML file line #11: Error inflating class fragment
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-29 08:32:56.979: E/AndroidRuntime(27738): at com.monumentos.vistasmovil.MonumentoMapa.onCreateView(MonumentoMapa.java:127)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.support.v4.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1264)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:672)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:461)
01-29 08:32:56.979: E/AndroidRuntime(27738): at com.monumentos.vistasmovil.Monumento.onTabChanged(Monumento.java:279)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.widget.TabHost.invokeOnTabChangeListener(TabHost.java:436)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.widget.TabHost.setCurrentTab(TabHost.java:421)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:158)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:459)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.view.View.performClick(View.java:2552)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.view.View$PerformClick.run(View.java:9229)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.os.Handler.handleCallback(Handler.java:587)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.os.Handler.dispatchMessage(Handler.java:92)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.os.Looper.loop(Looper.java:138)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.app.ActivityThread.main(ActivityThread.java:3701)
01-29 08:32:56.979: E/AndroidRuntime(27738): at java.lang.reflect.Method.invokeNative(Native Method)
01-29 08:32:56.979: E/AndroidRuntime(27738): at java.lang.reflect.Method.invoke(Method.java:507)
01-29 08:32:56.979: E/AndroidRuntime(27738): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
01-29 08:32:56.979: E/AndroidRuntime(27738): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
01-29 08:32:56.979: E/AndroidRuntime(27738): at dalvik.system.NativeStart.main(Native Method)
01-29 08:32:56.979: E/AndroidRuntime(27738): Caused by: java.lang.IllegalArgumentException: Binary XML file line #11: Duplicate id 0x7f06005c, tag null, or parent id 0x0 with another fragment for com.google.android.gms.maps.SupportMapFragment
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:285)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
01-29 08:32:56.979: E/AndroidRuntime(27738): ... 27 more
The error say:
01-29 08:32:56.979: E/AndroidRuntime(27738): Caused by: java.lang.IllegalArgumentException: Binary XML file line #11: Duplicate id 0x7f06005c, tag null, or parent id 0x0 with another fragment for com.google.android.gms.maps.SupportMapFragment
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:285)
01-29 08:32:56.979: E/AndroidRuntime(27738): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
01-29 08:32:56.979: E/AndroidRuntime(27738): ... 27 more
Here is the problem, but I dont know why only this fragment have the problem:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.monumenos_view_preview, container, false);
return view;
}
Finally I found the solution, I removed the nested MapFragment in my Fragment:
public void onDestroyView ()
{
try{
SupportMapFragment fragment = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.mapv2));
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.remove(fragment);
ft.commit();
}catch(Exception e){
}
super.onDestroyView();
}
I get the solution from here: Fragments within Fragments

How to solve OutOfMemoryError ?

I just published an app on Google play store namely " Bad Piggies Full Guide " . Today one user posted an error and the error says that :
"OutOfMemoryError
in Bitmap.nativeCreate()"
The Full Stack Traces Are :
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ashutos.cool/com.ashutos.cool.MainActivity}: android.view.InflateException: Binary XML file line #414: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2705)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2721)
at android.app.ActivityThread.access$2300(ActivityThread.java:132)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4669)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #414: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:203)
at android.app.Activity.setContentView(Activity.java:1656)
at com.ashutos.cool.MainActivity.onCreate(MainActivity.java:19)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at android.widget.ImageView.<init>(ImageView.java:108)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 23 more
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
at android.content.res.Resources.loadDrawable(Resources.java:1709)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.widget.ImageView.<init>(ImageView.java:118)
... 27 more
Can Anyone Solve this error please ?

PackageInfo versionCode and versionName null on phone, but works on emulator

I am building a private app that will not go through the Marketplace. As a result, I need to pull the current version application (not platform) information and check with the server to see if there is an update. It works great on the emulator, but when I installed the signed APK on my Droid X, it returns null. Here is the code:
PackageInfo pInfo = null;
try {
pInfo = getPackageManager().getPackageInfo("com.rubiconproject.expenses",
PackageManager.GET_META_DATA);
} catch (NameNotFoundException e) {
return;
}
String postUrl = DbAdapter.REMOTE_DB +
"/application/active-version/platform/android/version/" +
pInfo.versionCode + "." + pInfo.versionName;
EDIT:
I wrote a much smaller application, below, that displays my problem (TestingActivity.java):
package com.rubiconproject.testing;
import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.widget.TextView;
public class TestingActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
PackageInfo pInfo = null;
try {
pInfo = getPackageManager().getPackageInfo(
"com.rubiconproject.testing", PackageManager.GET_META_DATA);
} catch (NameNotFoundException e) {
return;
}
TextView tt = (TextView)findViewById(R.id.textView1);
tt.setText(pInfo.versionCode);
TextView tt2 = (TextView)findViewById(R.id.textView2);
tt2.setText(pInfo.versionName);
}
}
And the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rubiconproject.testing"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="9" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".TestingActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
adb logcat shows:
E/AndroidRuntime( 335): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rubiconproject.testing/com.rubiconproject.testing.TestingActivity}: java.lang.NullPointerException
E/AndroidRuntime( 335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
E/AndroidRuntime( 335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
E/AndroidRuntime( 335): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 335): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
E/AndroidRuntime( 335): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 335): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 335): at android.app.ActivityThread.main(ActivityThread.java:3647)
E/AndroidRuntime( 335): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 335): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 335): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 335): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 335): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 335): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 335): at com.rubiconproject.testing.TestingActivity.onCreate(TestingActivity.java:26)
E/AndroidRuntime( 335): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
E/AndroidRuntime( 335): ... 11 more
where line 26 corresponds to:
tt.setText(pInfo.versionCode);
Does anyone know why this is happening?
Does your manifest.xml contain android:versionCode and androd:versionName attributes?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.package.name"
android:versionCode="2"
android:versionName="1.1">
<application android:icon="#drawable/icon" android:label="#string/app_name">
...
</application>
</manifest>
Figured it out. The problem was between the keyboard and the chair. I was seeing null, when it fact the string was being built improperly.